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

[Developer version] Crash when touch Recyclerview #167

Closed
mdtuyen opened this issue Aug 21, 2016 · 6 comments
Closed

[Developer version] Crash when touch Recyclerview #167

mdtuyen opened this issue Aug 21, 2016 · 6 comments
Labels

Comments

@mdtuyen
Copy link

mdtuyen commented Aug 21, 2016

FATAL EXCEPTION: main
Process: com.gchat.messenger.beta, PID: 10293
java.lang.IllegalStateException: Layout state should be one of 100 but it is 10
at android.support.v7.widget.RecyclerView$State.assertLayoutStep(RecyclerView.java:10477)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3277)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3080)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1478)
at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1542)
at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2649)
at android.view.View.dispatchTouchEvent(View.java:8975)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2698)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2410)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2559)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1767)
at android.app.Activity.dispatchTouchEvent(Activity.java:2866)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2520)
at com.android.internal.policy.impl.MultiPhoneWindow$MultiPhoneDecorView.dispatchTouchEvent(MultiPhoneWindow.java:537)
at android.view.View.dispatchPointerEvent(View.java:9180)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4708)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4546)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4074)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4127)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4093)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4203)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4101)
at android.view.ViewRootImpl$AsyncInputStage.apply(V

@davideas
Copy link
Owner

davideas commented Aug 21, 2016

Sorry @mdtuyen, my last Snapshot was published on 31/7 and I didn't change existing behaviors.
I don't know, try to downgrade or upgrade Support Library.
Please don't open issue not related to this library, thanks.

@mdtuyen
Copy link
Author

mdtuyen commented Aug 22, 2016

Sorry, I don't know why but when I connect your project to new my project the error occur (old project work fine). The bug have been resolve by remove attribute primaryTextSelector () . I have no time to check more.

I have a question that: I use endless feature for your library with header. Here is my code:

 public void onLoadMore() {
        if (mAdapter.hasSearchText()) {
            mAdapter.onLoadMoreComplete(null);
            return;
        }
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                final List<AbstractFlexibleItem> newItems = new ArrayList<>(2);
                int count = new Random().nextInt(7);
                int totalItemsOfType = mAdapter.getItemCountOfTypes(R.layout.recycler_expandable_item);
                HeaderItem item = (HeaderItem) DatabaseService.getInstance().getDatabaseList().get(DatabaseService.getInstance().getDatabaseList().size() - 1);
                for (int i = 1; i <= count; i++) {
                    newItems.add(DatabaseService.newSimpleItem(totalItemsOfType + i, item));
                }
                mAdapter.onLoadMoreComplete(newItems);
                String message = (newItems.size() > 0 ?
                        "Simulated: " + newItems.size() + " new items arrived :-)" :
                        "Simulated: No more items to load :-(");
                Toast.makeText(ApplicationLoader.applicationContext, message, Toast.LENGTH_SHORT).show();
            }
        }, 3000);
    }

The new I tem added to the header but when I collape header it not collape the new item added.

@davideas
Copy link
Owner

@mdtuyen, I suspect that HeaderItem it's not expandable. As you see from my code I create newExpandableItem with subItems already inside. And only the main item is added to the list. You forgot?

@mdtuyen
Copy link
Author

mdtuyen commented Aug 22, 2016

I have two type item: headeritem with expandable feature, and simple item. I want make a recyclerview with sticky header, endless, expandable and have some fix item header at top.

@davideas
Copy link
Owner

davideas commented Aug 22, 2016

So you need a AbstractExpandableHeaderItem and a SubItem of type AbstractFlexibleItem.
In the onLoadMore() you create AbstractExpandableHeaderItem with the sub items inside and add the main item to the Adapter list onLoadMoreComplete(newItems).

For the fixed header you can name it as you want, I will call here FixedTopHeaderItem of type AbstractFlexibleItem. Then you add it only to the top of the Adapter list (not to the database!) every time you create the list or clear the search text -> addItem(0, fixedTopHeaderItem) (this is kind of call addHeader() in others libraries).

Read carefully my comments of the methods and the Wiki pages.

@mdtuyen mdtuyen closed this as completed Aug 23, 2016
@davideas
Copy link
Owner

@mdtuyen, please be aware that, Endless Scrolling is going to be changed very soon. In order to support the new features and a better logic, the behaviors and callbacks methods will be refactored.

Please check issue #233 for the latest developments.

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

No branches or pull requests

2 participants