From 500584b9ef208db30d9fa8de7fc31d8ad4938e79 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 13 Dec 2020 09:32:33 +0100 Subject: [PATCH] Fix some issues --- .../fedilabtube/drawer/PeertubeAdapter.java | 8 ++++++-- .../fragment/DisplaySepiaSearchFragment.java | 4 ++-- .../fragment/DisplayVideosFragment.java | 14 +++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java index f38056d..800be16 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java @@ -55,6 +55,7 @@ import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.ShowChannelActivity; import app.fedilab.fedilabtube.client.APIResponse; import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; +import app.fedilab.fedilabtube.client.data.ChannelData; import app.fedilab.fedilabtube.client.data.PlaylistData; import app.fedilab.fedilabtube.client.data.VideoData; import app.fedilab.fedilabtube.client.entities.PlaylistExist; @@ -82,12 +83,13 @@ public class PeertubeAdapter extends RecyclerView.Adapter videos, TimelineVM.TimelineType timelineType, boolean sepiaSearch) { + public PeertubeAdapter(List videos, TimelineVM.TimelineType timelineType, boolean sepiaSearch, ChannelData.Channel forChannel) { this.videos = videos; this.timelineType = timelineType; this.sepiaSearch = sepiaSearch || timelineType == SEPIA_SEARCH; + this.forChannel = forChannel; } @@ -130,6 +132,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter 0) { + if (dx > 0) { int visibleItemCount = layoutManager.getChildCount(); int totalItemCount = layoutManager.getItemCount(); - if (firstVisibleItem + visibleItemCount == totalItemCount && context != null) { + if (firstVisibleItem + visibleItemCount == totalItemCount && context != null && !flag_loading_account) { + flag_loading_account = true; viewModelAccounts.getAccounts(RetrofitPeertubeAPI.DataType.SUBSCRIBER, max_id_accounts).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageViewAccounts(apiResponse)); } } @@ -294,6 +297,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta private void manageViewAccounts(APIResponse apiResponse) { + flag_loading_account = false; if (apiResponse != null && apiResponse.getChannels() != null && apiResponse.getChannels().size() > 0) { if (binding.topAccountContainer.getVisibility() == View.GONE) { binding.topAccountContainer.setVisibility(View.VISIBLE); @@ -356,7 +360,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta //If no item were inserted previously the adapter is created if (previousPosition == 0) { - peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch); + peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch, forChannel); peertubeAdapater.playlistListener = DisplayVideosFragment.this; peertubeAdapater.relationShipListener = DisplayVideosFragment.this; binding.lvVideos.setAdapter(peertubeAdapater);