You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.
I was trying to change the LayoutManager from GridLayoutManager to LinearLayoutManager, It works fine until you scroll to the last item. According to the StackTrace this method is what's causing the Issue.
` private int getLastVisibleItemPosition(RecyclerView.LayoutManager layoutManager) {
int lastVisibleItemPosition = -1;
if (layoutManagerType == null) {
if (layoutManager instanceof GridLayoutManager) {
layoutManagerType = LAYOUT_MANAGER_TYPE.GRID;
} else if (layoutManager instanceof LinearLayoutManager) {
layoutManagerType = LAYOUT_MANAGER_TYPE.LINEAR;
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
layoutManagerType = LAYOUT_MANAGER_TYPE.STAGGERED_GRID;
} else {
throw new RuntimeException("Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
}
}
switch (layoutManagerType) {
case LINEAR:
lastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
break;
case GRID:
lastVisibleItemPosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
break;
case STAGGERED_GRID:
lastVisibleItemPosition = caseStaggeredGrid(layoutManager);
break;
}
return lastVisibleItemPosition;
}`
It looks like layoutManagerType is only set when it's null, which means the first time only, that means it remains as GridLayoutManager when I set the LayoutManager the second time to LinearLayoutManager
The text was updated successfully, but these errors were encountered:
It would be nice to have the bloc : if (layoutManagerType == null) { if (layoutManager instanceof GridLayoutManager) { layoutManagerType = LAYOUT_MANAGER_TYPE.GRID; } else if (layoutManager instanceof LinearLayoutManager) { layoutManagerType = LAYOUT_MANAGER_TYPE.LINEAR; } else if (layoutManager instanceof StaggeredGridLayoutManager) { layoutManagerType = LAYOUT_MANAGER_TYPE.STAGGERED_GRID; } else { throw new RuntimeException("Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager"); } }
in the method setLayoutManager() instead...
I have done a fork in which I made the change, I am a beginner at using GitHub (and git), but if you're interested it's there under the tag v1.1.5 : https://github.com/Kobatsu/SuperRecyclerView
It can be imported easily in Android Studio using JitPack (https://jitpack.io/)
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I was trying to change the LayoutManager from GridLayoutManager to LinearLayoutManager, It works fine until you scroll to the last item. According to the StackTrace this method is what's causing the Issue.
` private int getLastVisibleItemPosition(RecyclerView.LayoutManager layoutManager) {
It looks like layoutManagerType is only set when it's null, which means the first time only, that means it remains as GridLayoutManager when I set the LayoutManager the second time to LinearLayoutManager
The text was updated successfully, but these errors were encountered: