New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robobinding firePropertyChange not working with v21 buildTool? #217

Open
sl378 opened this Issue May 4, 2015 · 13 comments

Comments

Projects
None yet
5 participants
@sl378

sl378 commented May 4, 2015

I have been using robobinding for most of my listviews, and it works like magic. I love it
but I recently updated my sdk and buildtools to
compileSdkVersion 22
buildToolsVersion '21.1.1'

the update of the list seems to have stopped working when I want to refresh the data that the list holds
mChangeSupport.firePropertyChange("listSource");

If this is a compatibility issue, is there an update coming to fix it or is there some other reason that caused it

ps: I'm not using aspectJ plugin

Thanks

@sl378

This comment has been minimized.

sl378 commented May 4, 2015

Could be related to issue #212? I'm not sure

because it's not updating the list even when I'm still on
com.android.tools.build:gradle:1.0.0

@weicheng113

This comment has been minimized.

Member

weicheng113 commented May 5, 2015

Hi Alex, i am not sure what the problem is. But if you have some time, could you please make a smallest example to show the problem please, so that i can recreate the issue locally?

@sl378

This comment has been minimized.

sl378 commented May 6, 2015

Hi Cheng,
I think the problem occurred after I updated these two items (highlighted in the screenshot below) in the sdk manager, I'm not sure which exact one that caused it. The reason is beacause my colleague has not got the problem yet since he's not updated to the latest version.

Here's an example of the code, which was working perfectly until then.

@PresentationModel
public abstract class BaseListPresentationModel implements HasPresentationModelChangeSupport {
    //These attribute string are for firePropertyChange(); they correspond to the value of
    public static final String ATTR_FOOTER_INTEGER_VISIBILITY = "footerVisibility";
    public static final String ATTR_HEADER_VISIBILITY = "headerVisibility";
    protected int mFooterVisibility = View.GONE;
    protected String mFooterText;
    protected final List<Object> mListObjects;
    protected PresentationModelChangeSupport mChangeSupport;
    protected String mEndPoint;
    protected boolean mHeaderVisibility;

    /**
     * Set up presentation model
     * @param endpoint used to determine the item_layout resource you don't have to specify them in the <Listview>
     * @param listObjects the data that is bound to <ListView>
     * @param footerText the footer text string eg. load more company
     */
    public BaseListPresentationModel(String endpoint, List<Object> listObjects, String footerText) {
        mListObjects = listObjects;
        mFooterText = footerText;
        mEndPoint = endpoint;
        mChangeSupport = new PresentationModelChangeSupport(this);
    }

    @Override
    public PresentationModelChangeSupport getPresentationModelChangeSupport() {
        return mChangeSupport;
    }

    /**
     * bind:footer="{footer}
     * @param footerText - footer string
     * @return a ListFooterPresentationModel instance
     */
    public ListFooterPresentationModel getFooter(String footerText){
        return ListFooterPresentationModel.newInstance(footerText);
    }

    /**
     * Can be called by the child class to toggle the footer
     *
     * @param visibility - true to show, false to hide
     */
    public void changeFooterVisibility(boolean visibility){
        if(visibility){
            mFooterVisibility = View.VISIBLE;
        }else{
            mFooterVisibility = View.GONE;
        }
        mChangeSupport.firePropertyChange(ATTR_FOOTER_INTEGER_VISIBILITY);
    }
    public void showEmptyFooter(){
        mFooterVisibility = View.INVISIBLE;
        mChangeSupport.firePropertyChange(ATTR_FOOTER_INTEGER_VISIBILITY);
    }
    public void changeHeaderVisibility(boolean visibility){
        mHeaderVisibility  = visibility;
        mChangeSupport.firePropertyChange(ATTR_HEADER_VISIBILITY);
    }

    public int getFooterVisibility(){
        return mFooterVisibility;
    }
    public int getDynamicItemLayout(){        
            return R.layout.company_list_row;        
    }

    public boolean getHeaderVisibility(){
        return mHeaderVisibility;
    }
    public void refresh(){
        mFooterVisibility = View.GONE;
        mChangeSupport.firePropertyChange("listSource");
        mChangeSupport.firePropertyChange("footerVisibility");
    }
}

<ListView android:id="@id/android:list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:drawSelectorOnTop="false"
        android:dividerHeight="0dp"
        android:paddingBottom="@dimen/card_list_first_top"
        android:paddingTop="@dimen/card_list_first_top"
        android:divider="@null"
        android:clipToPadding="false"
        android:background="@color/faint_grey"
        bind:source="{listSource}"
        bind:itemLayout="{dynamicItemLayout}"
        bind:footerLayout="@layout/footer_layout"
        bind:footerPresentationModel="{footer}"
        bind:footerVisibility="{footerVisibility}"
        bind:headerLayout="@layout/view_header_placeholder"
        bind:headerVisibility="{headerVisibility}">
    </ListView>

And the function refresh() is not updating the data change as it used to anymore

screen-shot-2015-05-06-at-10 08 47-am

If there's anything else you need, please let me know

Thank you.

@robobindingacc

This comment has been minimized.

robobindingacc commented May 6, 2015

Hi Alex, I can't see any problem from your example. Have you tried to set some break points and debug? That would be the quickest way to locate the issue, as it doesn't look a complicated issue. Alternatively, i will request you to create a smallest example that i can download and import to my local to recreate the problem.

Cheng

@sl378

This comment has been minimized.

sl378 commented May 6, 2015

Thanks @weicheng113 will get back to you asap

@sl378

This comment has been minimized.

sl378 commented May 6, 2015

Hi @weicheng113,
I have just created a test project at here https://github.com/sl378/RobobindingTest

It's just a simple activity with a list, and it's suppose to add more items to the list if you click the button.
I still can't get it to work.

Looking forward to hear your findings

@robobindingacc

This comment has been minimized.

robobindingacc commented May 6, 2015

Hi Alex,

I was trying to run the example, but my machine is having a problem. Probably we can have a chat through Skype or QQ(looks you can speak Chinese :)) and try to locate the problem sooner? you can send your details to my email(weicheng112@gmail.com) if you would like to.

Cheng

@sl378

This comment has been minimized.

sl378 commented May 6, 2015

Sure, will jump on qq soon, I have contacted you from there before I think

@KurtWagner

This comment has been minimized.

KurtWagner commented May 13, 2015

Using the test project from @sl378 I've confirmed that downgrading from Android Support Library 22.1 to 22 fixes the problem.

@weicheng113

This comment has been minimized.

Member

weicheng113 commented Jul 23, 2015

Fixed and tested.

@gustinoco

This comment has been minimized.

gustinoco commented Mar 7, 2017

HELLO, my device api 16 (4.1.2 android) not woking firepropertychange only in listview, but in anothers devices android, this working normally. How to proceed??

@weicheng113

This comment has been minimized.

Member

weicheng113 commented Mar 7, 2017

@gustinoco , Could you make a smallest example project to reproduce the issue please? I will find some time to look into it. Thanks.

@weicheng113 weicheng113 reopened this Mar 7, 2017

@gustinoco

This comment has been minimized.

gustinoco commented Mar 8, 2017

@weicheng113 I create on https://github.com/gustinoco/robobinding_minimal i create a minimal test and it works. I found the cause problem, i'm use the Callygraph and the code in MainActivity

@override
protected void attachBaseContext(Context newBase) { super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
`` }

this code is a causing problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment