Skip to content
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

Cards can't be swiped when changes are made after setAdapter() #85

Open
hong-yew opened this issue Dec 22, 2015 · 1 comment
Open

Cards can't be swiped when changes are made after setAdapter() #85

hong-yew opened this issue Dec 22, 2015 · 1 comment

Comments

@hong-yew
Copy link

To reproduce:

After setAdapter(), add a card to the adapter using the adapter's add(), which internally will call notifyDataSetChange(). However, after this point, the card cannot be swiped.

The problem lies in mTopCard being set to null when adapter nofityDataSetChange() gets called, the CardContainer's data listener onChanged() calls clearStack() which clears sets mTopCard = null.

After that mTopCard is always null unless setAdapter() is called again, which shouldn't have to be.

Suggest to move the code in setAdapter()

if (getChildCount() != 0) {
           mTopCard = getChildAt(getChildCount() - 1);
            mTopCard.setLayerType(LAYER_TYPE_HARDWARE, null);
        }

to ensureFull() which is just the line above. This will ensure that notifyDataSetChange() will work as intended without having to call setAdapter() again (which the code shouldn't have access to the view element to call).

@hong-yew hong-yew changed the title Cards can't be swiped when change are made after setAdapter() Cards can't be swiped when changes are made after setAdapter() Dec 22, 2015
@RobinJespersen
Copy link

Thx, works nice for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants