Merge pull request #5876 from ByteHamster/fix-column-change

Fix column change on subscriptions screen
This commit is contained in:
ByteHamster 2022-05-07 21:10:54 +02:00 committed by GitHub
commit 2fa734282d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 9 deletions

View File

@ -146,13 +146,8 @@ public class SubscriptionFragment extends Fragment
}
subscriptionRecycler = root.findViewById(R.id.subscriptions_grid);
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(),
prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns()),
RecyclerView.VERTICAL,
false);
subscriptionRecycler.setLayoutManager(gridLayoutManager);
setColumnNumber(prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns()));
subscriptionRecycler.addItemDecoration(new SubscriptionsRecyclerAdapter.GridDividerItemDecorator());
gridLayoutManager.setSpanCount(prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns()));
registerForContextMenu(subscriptionRecycler);
subscriptionAddButton = root.findViewById(R.id.subscriptions_add);
progressBar = root.findViewById(R.id.progLoading);
@ -239,9 +234,9 @@ public class SubscriptionFragment extends Fragment
}
private void setColumnNumber(int columns) {
GridLayoutManager gridLayoutManager = (GridLayoutManager) subscriptionRecycler.getLayoutManager();
gridLayoutManager.setSpanCount(columns);
subscriptionAdapter.notifyDataSetChanged();
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(),
columns, RecyclerView.VERTICAL, false);
subscriptionRecycler.setLayoutManager(gridLayoutManager);
prefs.edit().putInt(PREF_NUM_COLUMNS, columns).apply();
refreshToolbarState();
}