From dd6574fbf46d0a77fd086f4bc6f3623e4fddd1eb Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 13 Jul 2021 19:33:33 -0400 Subject: [PATCH] fix saved collection cover media logic https://t.me/barinsta_app/22792 --- .../adapters/viewholder/TopicClusterViewHolder.java | 6 +++++- .../instagrabber/fragments/CollectionPostsFragment.java | 5 ++++- .../repositories/responses/saved/SavedCollection.kt | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java index 4097d114..6bb61d2d 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java @@ -29,6 +29,7 @@ import awais.instagrabber.adapters.SavedCollectionsAdapter; import awais.instagrabber.databinding.ItemDiscoverTopicBinding; import awais.instagrabber.repositories.responses.discover.TopicCluster; import awais.instagrabber.repositories.responses.saved.SavedCollection; +import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.utils.ResponseBodyUtils; public class TopicClusterViewHolder extends RecyclerView.ViewHolder { @@ -130,7 +131,10 @@ public class TopicClusterViewHolder extends RecyclerView.ViewHolder { } // binding.title.setTransitionName("title-" + topicCluster.getCollectionId()); binding.cover.setTransitionName("cover-" + topicCluster.getCollectionId()); - final String thumbUrl = ResponseBodyUtils.getThumbUrl(topicCluster.getCoverMediaList().get(0)); + final Media coverMedia = topicCluster.getCoverMediaList() == null + ? topicCluster.getCoverMedia() + : topicCluster.getCoverMediaList().get(0); + final String thumbUrl = ResponseBodyUtils.getThumbUrl(coverMedia); if (thumbUrl == null) { binding.cover.setImageURI((String) null); } else { diff --git a/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java b/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java index d6d3087f..5296e303 100644 --- a/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java @@ -415,7 +415,10 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay } private void setupCover() { - final String coverUrl = ResponseBodyUtils.getImageUrl(savedCollection.getCoverMediaList().get(0)); + final Media coverMedia = savedCollection.getCoverMediaList() == null + ? savedCollection.getCoverMedia() + : savedCollection.getCoverMediaList().get(0); + final String coverUrl = ResponseBodyUtils.getImageUrl(coverMedia); final DraweeController controller = Fresco .newDraweeControllerBuilder() .setOldController(binding.cover.getController()) diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt b/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt index 02732c94..814a510b 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt @@ -8,5 +8,5 @@ class SavedCollection(val collectionId: String, val collectionType: String, val collectionMediaCount: Int, // coverMedia or coverMediaList: only one is defined - val coverMedia: Media, - val coverMediaList: List) : Serializable \ No newline at end of file + val coverMedia: Media?, + val coverMediaList: List?) : Serializable \ No newline at end of file