mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-26 08:37:29 +00:00
Fix item decoration add/remove logic and one null check
This commit is contained in:
parent
e3cc99f62f
commit
82e960d9fe
@ -216,6 +216,7 @@ public class PostsRecyclerView extends RecyclerView {
|
|||||||
if (progressPercent != 100) continue;
|
if (progressPercent != 100) continue;
|
||||||
final String url = progress.getString(DownloadWorker.URL);
|
final String url = progress.getString(DownloadWorker.URL);
|
||||||
final List<FeedModel> feedModels = feedViewModel.getList().getValue();
|
final List<FeedModel> feedModels = feedViewModel.getList().getValue();
|
||||||
|
if (feedModels == null) continue;
|
||||||
for (int i = 0; i < feedModels.size(); i++) {
|
for (int i = 0; i < feedModels.size(); i++) {
|
||||||
final FeedModel feedModel = feedModels.get(i);
|
final FeedModel feedModel = feedModels.get(i);
|
||||||
final List<String> displayUrls = getDisplayUrl(feedModel);
|
final List<String> displayUrls = getDisplayUrl(feedModel);
|
||||||
@ -254,11 +255,16 @@ public class PostsRecyclerView extends RecyclerView {
|
|||||||
post(() -> {
|
post(() -> {
|
||||||
TransitionManager.beginDelayedTransition(this, transition);
|
TransitionManager.beginDelayedTransition(this, transition);
|
||||||
feedAdapter.notifyDataSetChanged();
|
feedAdapter.notifyDataSetChanged();
|
||||||
|
final int itemDecorationCount = getItemDecorationCount();
|
||||||
if (!layoutPreferences.getHasGap()) {
|
if (!layoutPreferences.getHasGap()) {
|
||||||
|
if (itemDecorationCount == 1) {
|
||||||
removeItemDecoration(gridSpacingItemDecoration);
|
removeItemDecoration(gridSpacingItemDecoration);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (itemDecorationCount == 0) {
|
||||||
addItemDecoration(gridSpacingItemDecoration);
|
addItemDecoration(gridSpacingItemDecoration);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (layoutPreferences.getType() == PostsLayoutPreferences.PostsLayoutType.LINEAR) {
|
if (layoutPreferences.getType() == PostsLayoutPreferences.PostsLayoutType.LINEAR) {
|
||||||
if (layoutManager.getSpanCount() != 1) {
|
if (layoutManager.getSpanCount() != 1) {
|
||||||
layoutManager.setSpanCount(1);
|
layoutManager.setSpanCount(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user