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

IllegalArgumentException: you can't move above of maxItemCount #34

Open
csbenz opened this issue Apr 3, 2017 · 11 comments
Open

IllegalArgumentException: you can't move above of maxItemCount #34

csbenz opened this issue Apr 3, 2017 · 11 comments

Comments

@csbenz
Copy link

csbenz commented Apr 3, 2017

I'm getting the following error from users on many api's and many different devices. Any idea why?

Fatal Exception: java.lang.IllegalArgumentException: you can't move above of maxItemCount
       at com.beloo.widget.chipslayoutmanager.layouter.AbstractPositionIterator.move(AbstractPositionIterator.java:17)
       at com.beloo.widget.chipslayoutmanager.ChipsLayoutManager.fillWithLayouter(ChipsLayoutManager.java:852)
       at com.beloo.widget.chipslayoutmanager.ChipsLayoutManager.fill(ChipsLayoutManager.java:815)
       at com.beloo.widget.chipslayoutmanager.ChipsLayoutManager.onLayoutChildren(ChipsLayoutManager.java:719)
       at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
       at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3025)
       at android.view.View.measure(View.java:18799)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1458)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:746)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
       at android.view.View.measure(View.java:18799)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:18799)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:898)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
       at android.view.View.measure(View.java:18799)
       at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1658)
       at android.view.View.measure(View.java:18799)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:898)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
       at android.view.View.measure(View.java:18799)
       at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
       at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
       at android.view.View.measure(View.java:18799)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:18799)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
       at android.view.View.measure(View.java:18799)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:18799)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:18799)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1458)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:746)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
       at android.view.View.measure(View.java:18799)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2899)
       at android.view.View.measure(View.java:18799)
       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2108)
       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1224)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1460)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1115)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6023)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
       at android.view.Choreographer.doCallbacks(Choreographer.java:670)
       at android.view.Choreographer.doFrame(Choreographer.java:606)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5461)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
@qmetzler-luna
Copy link

Just came across the same crash. Did you find a clue on where to look?

@csbenz
Copy link
Author

csbenz commented Apr 28, 2017

@qmetzler-luna Unfortunately not

@corvinav
Copy link

corvinav commented Aug 7, 2017

Have the same problem. Did you find solution?

@corvinav
Copy link

corvinav commented Aug 7, 2017

OMG
this works for me:
<android.support.v7.widget.RecyclerView
android:id="@+id/chips_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="8dp"
android:paddingBottom="8dp"
/>
this doesn't work:
<android.support.v7.widget.RecyclerView
android:id="@+id/chips_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

@wanbyte
Copy link

wanbyte commented Aug 12, 2017

Having same issue here. Please who managed to find a solution to this?

@wanbyte
Copy link

wanbyte commented Aug 12, 2017

Ok. I think I found a work around on this.

I basically opened the AbstractPositionIterator.java file and rewrote the move method from

public void move(@IntRange(from = 0) int pos) { if (pos >= itemCount) throw new IllegalArgumentException("you can't move above of maxItemCount"); if (pos < 0) throw new IllegalArgumentException("can't move to negative position"); this.pos = pos; }

to

public void move(@IntRange(from = 0) int pos) { if (pos >= itemCount) { pos = itemCount; } if (pos < 0) throw new IllegalArgumentException("can't move to negative position"); this.pos = pos; }

and that fixed it for me.

@alexjiexiaoqi
Copy link

alexjiexiaoqi commented Apr 26, 2018

it sames that the pos belong to the previous data. For example, you put datas which size is 20, and scroll it to the bottom, so the current pos is 20, but now you want to update the recycleview, you put another datas which size is 10, so the pos 20 is big than 10. so you'd betther scroll the recycleview to the start positon.

public void setDatas(List list) {
/**
first scroll current pos to 0, then change the datas to update recycleview
*/
recyclerView.scrollToPosition(0);
datas = list;
mAdapter.setData(datas);
}

@Pradeepkumar2091
Copy link

having the same problem.

This issue occurs, when first-time data added to list and then immediately cleared, After clearing data list then again adding data to list.

How can I fix this issue?

@gipson1001
Copy link

I place recyclerview in NestedScrollView to fix it, you can try

@AmritpalSingh5
Copy link

Just setAdapter() every time instead of notifyDataSetChange() . it solved my crash.

@JaydipRadadiya
Copy link

Just setAdapter() every time instead of notifyDataSetChange() . it solved my crash.

Thank you @AmritpalSingh5 it working perfectly!!

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

9 participants