Fix some issues
This commit is contained in:
parent
33ac822957
commit
500584b9ef
|
@ -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<RecyclerView.ViewHolde
|
|||
private Context context;
|
||||
private TimelineVM.TimelineType timelineType;
|
||||
private boolean sepiaSearch;
|
||||
private ChannelData.Channel forChannel;
|
||||
|
||||
|
||||
public PeertubeAdapter(List<VideoData.Video> videos, TimelineVM.TimelineType timelineType, boolean sepiaSearch) {
|
||||
public PeertubeAdapter(List<VideoData.Video> 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<RecyclerView.ViewHolde
|
|||
String instance = null;
|
||||
if (sepiaSearch) {
|
||||
instance = video.getAccount().getHost();
|
||||
} else if (forChannel != null) {
|
||||
instance = forChannel.getHost();
|
||||
}
|
||||
|
||||
holder.binding.peertubeAccountName.setText(video.getChannel().getAcct());
|
||||
|
|
|
@ -96,7 +96,7 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
|
|||
binding.loader.setVisibility(View.VISIBLE);
|
||||
binding.loadingNextVideos.setVisibility(View.GONE);
|
||||
|
||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true);
|
||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true, null);
|
||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
|
|||
|
||||
//If no item were inserted previously the adapter is created
|
||||
if (previousPosition == 0) {
|
||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true);
|
||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true, null);
|
||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||
} else
|
||||
peertubeAdapater.notifyItemRangeInserted(previousPosition, videoData.data.size());
|
||||
|
|
|
@ -70,7 +70,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private GridLayoutManager gLayoutManager;
|
||||
private boolean flag_loading;
|
||||
private boolean flag_loading, flag_loading_account;
|
||||
private Context context;
|
||||
private PeertubeAdapter peertubeAdapater;
|
||||
private AccountsHorizontalListAdapter accountsHorizontalListAdapter;
|
||||
|
@ -136,13 +136,14 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
//forChannel = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null;
|
||||
max_id_accounts = null;
|
||||
flag_loading = true;
|
||||
flag_loading_account = false;
|
||||
firstLoad = true;
|
||||
check_ScrollingUp = false;
|
||||
|
||||
binding.loader.setVisibility(View.VISIBLE);
|
||||
binding.loadingNextVideos.setVisibility(View.GONE);
|
||||
|
||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch);
|
||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch, forChannel);
|
||||
peertubeAdapater.playlistListener = this;
|
||||
peertubeAdapater.relationShipListener = this;
|
||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||
|
@ -152,6 +153,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
= new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
||||
binding.lvAccounts.setLayoutManager(layoutManager);
|
||||
binding.lvAccounts.setAdapter(accountsHorizontalListAdapter);
|
||||
|
||||
if (!Helper.isTablet(context)) {
|
||||
mLayoutManager = new LinearLayoutManager(context);
|
||||
binding.lvVideos.setLayoutManager(mLayoutManager);
|
||||
|
@ -170,10 +172,11 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
binding.lvAccounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
|
||||
if (dy > 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);
|
||||
|
|
Loading…
Reference in New Issue