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 was archived by the owner on Mar 26, 2019. It is now read-only.
I have the following code to collect my items to show in my RV:
// Spanned
public RecyclerView.LayoutManager getLayoutManager() {
if (!mMainView || mDataHolder.getViewMode(mActivity).equals("grid")) { // We force the grid view in subset
final Integer numColumns = UserPreferencesHandler.<Integer>readValue(mActivity, UserPreferencesHandler.PREF_KEY_NUM_COLUMNS);
SpannedGridLayoutManager layoutManager = new SpannedGridLayoutManager(SpannedGridLayoutManager.Orientation.VERTICAL, numColumns);
layoutManager.setSpanSizeLookup(new SpannedGridLayoutManager.SpanSizeLookup(position -> {
try {
switch (RVAdapterTimeline.this.getItemViewType(position)) {
case RVAdapter.VIEW_TYPE_HEADER:
try {
return new SpanSize(numColumns, 1);
} catch (ClassCastException e) {
return new SpanSize(1, 1);
}
default:
LineItem lineitem = mItems.get(position);
if (lineitem != null && lineitem.mediaItem != null && lineitem.mediaItem.getRating() != null && lineitem.mediaItem.getRating() == 5) {
return new SpanSize(2, 2);
}
return new SpanSize(1, 1);
}
} catch (IndexOutOfBoundsException e) {
MyApplication.toastSomething(mActivity, e); // Seen on firebase
return new SpanSize(1, 1);
}
}));
return layoutManager;
} else {
return new LinearLayoutManager(mActivity, LinearLayoutManager.VERTICAL, false);
}
}
There are header items with a full column span: return new SpanSize(numColumns, 1);
Other items are with span width 2 or 2. The number of columns is 5.
After collecting the items, they are used for the RV adapter. The problem is that the order in the rendered RV is not the same as the items. Result: Pic
Could you please fix that? I can confirm 100% that the default GridLayoutManager is working with these items.
I have the following code to collect my items to show in my RV:
There are header items with a full column span:
return new SpanSize(numColumns, 1);Other items are with span width 2 or 2. The number of columns is 5.
After collecting the items, they are used for the RV adapter. The problem is that the order in the rendered RV is not the same as the items. Result:
Pic
Could you please fix that? I can confirm 100% that the default GridLayoutManager is working with these items.