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);