1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 14:47:29 +00:00

Fix item decoration add/remove logic and one null check

This commit is contained in:
Ammar Githam 2020-11-19 01:51:08 +09:00
parent e3cc99f62f
commit 82e960d9fe

View File

@ -216,6 +216,7 @@ public class PostsRecyclerView extends RecyclerView {
if (progressPercent != 100) continue;
final String url = progress.getString(DownloadWorker.URL);
final List<FeedModel> feedModels = feedViewModel.getList().getValue();
if (feedModels == null) continue;
for (int i = 0; i < feedModels.size(); i++) {
final FeedModel feedModel = feedModels.get(i);
final List<String> displayUrls = getDisplayUrl(feedModel);
@ -254,10 +255,15 @@ public class PostsRecyclerView extends RecyclerView {
post(() -> {
TransitionManager.beginDelayedTransition(this, transition);
feedAdapter.notifyDataSetChanged();
final int itemDecorationCount = getItemDecorationCount();
if (!layoutPreferences.getHasGap()) {
removeItemDecoration(gridSpacingItemDecoration);
if (itemDecorationCount == 1) {
removeItemDecoration(gridSpacingItemDecoration);
}
} else {
addItemDecoration(gridSpacingItemDecoration);
if (itemDecorationCount == 0) {
addItemDecoration(gridSpacingItemDecoration);
}
}
if (layoutPreferences.getType() == PostsLayoutPreferences.PostsLayoutType.LINEAR) {
if (layoutManager.getSpanCount() != 1) {