mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-23 05:16:58 +00:00
close #1271
This commit is contained in:
parent
256a2ae88d
commit
4161c7bc4d
@ -15,10 +15,14 @@ import androidx.navigation.fragment.FragmentNavigator;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import awais.instagrabber.activities.MainActivity;
|
||||
import awais.instagrabber.adapters.DiscoverTopicsAdapter;
|
||||
import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration;
|
||||
import awais.instagrabber.databinding.FragmentDiscoverBinding;
|
||||
import awais.instagrabber.repositories.responses.discover.TopicCluster;
|
||||
import awais.instagrabber.repositories.responses.discover.TopicalExploreFeedResponse;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.viewmodels.TopicClusterViewModel;
|
||||
@ -93,8 +97,18 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
@Override
|
||||
public void onSuccess(final TopicalExploreFeedResponse result) {
|
||||
if (result == null) return;
|
||||
topicClusterViewModel.getList().postValue(result.getClusters());
|
||||
final List<TopicCluster> clusters = result.getClusters();
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
if (clusters.size() == 1 && result.getItems().size() > 0) {
|
||||
final TopicCluster cluster = clusters.get(0);
|
||||
if (cluster.getCoverMedia() == null)
|
||||
cluster.setCoverMedia(result.getItems().get(0).getMedia());
|
||||
topicClusterViewModel.getList().postValue(Collections.singletonList(cluster));
|
||||
return;
|
||||
}
|
||||
if (clusters.size() > 1 || result.getItems().size() == 0) {
|
||||
topicClusterViewModel.getList().postValue(clusters);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,7 @@ public class TopicCluster implements Serializable {
|
||||
private final boolean canMute;
|
||||
private final boolean isMuted;
|
||||
private final int rankedPosition;
|
||||
private final Media coverMedia;
|
||||
private Media coverMedia;
|
||||
|
||||
public TopicCluster(final String id,
|
||||
final String title,
|
||||
@ -56,4 +56,8 @@ public class TopicCluster implements Serializable {
|
||||
public Media getCoverMedia() {
|
||||
return coverMedia;
|
||||
}
|
||||
|
||||
public void setCoverMedia(final Media coverMedia) {
|
||||
this.coverMedia = coverMedia;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user