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.ShowChannelActivity;
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
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.PlaylistData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
||||||
|
@ -82,12 +83,13 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||||
private Context context;
|
private Context context;
|
||||||
private TimelineVM.TimelineType timelineType;
|
private TimelineVM.TimelineType timelineType;
|
||||||
private boolean sepiaSearch;
|
private boolean sepiaSearch;
|
||||||
|
private ChannelData.Channel forChannel;
|
||||||
|
|
||||||
|
public PeertubeAdapter(List<VideoData.Video> videos, TimelineVM.TimelineType timelineType, boolean sepiaSearch, ChannelData.Channel forChannel) {
|
||||||
public PeertubeAdapter(List<VideoData.Video> videos, TimelineVM.TimelineType timelineType, boolean sepiaSearch) {
|
|
||||||
this.videos = videos;
|
this.videos = videos;
|
||||||
this.timelineType = timelineType;
|
this.timelineType = timelineType;
|
||||||
this.sepiaSearch = sepiaSearch || timelineType == SEPIA_SEARCH;
|
this.sepiaSearch = sepiaSearch || timelineType == SEPIA_SEARCH;
|
||||||
|
this.forChannel = forChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,6 +132,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||||
String instance = null;
|
String instance = null;
|
||||||
if (sepiaSearch) {
|
if (sepiaSearch) {
|
||||||
instance = video.getAccount().getHost();
|
instance = video.getAccount().getHost();
|
||||||
|
} else if (forChannel != null) {
|
||||||
|
instance = forChannel.getHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.binding.peertubeAccountName.setText(video.getChannel().getAcct());
|
holder.binding.peertubeAccountName.setText(video.getChannel().getAcct());
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
|
||||||
binding.loader.setVisibility(View.VISIBLE);
|
binding.loader.setVisibility(View.VISIBLE);
|
||||||
binding.loadingNextVideos.setVisibility(View.GONE);
|
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);
|
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 no item were inserted previously the adapter is created
|
||||||
if (previousPosition == 0) {
|
if (previousPosition == 0) {
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true, null);
|
||||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||||
} else
|
} else
|
||||||
peertubeAdapater.notifyItemRangeInserted(previousPosition, videoData.data.size());
|
peertubeAdapater.notifyItemRangeInserted(previousPosition, videoData.data.size());
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
||||||
|
|
||||||
private LinearLayoutManager mLayoutManager;
|
private LinearLayoutManager mLayoutManager;
|
||||||
private GridLayoutManager gLayoutManager;
|
private GridLayoutManager gLayoutManager;
|
||||||
private boolean flag_loading;
|
private boolean flag_loading, flag_loading_account;
|
||||||
private Context context;
|
private Context context;
|
||||||
private PeertubeAdapter peertubeAdapater;
|
private PeertubeAdapter peertubeAdapater;
|
||||||
private AccountsHorizontalListAdapter accountsHorizontalListAdapter;
|
private AccountsHorizontalListAdapter accountsHorizontalListAdapter;
|
||||||
|
@ -136,13 +136,14 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
||||||
//forChannel = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null;
|
//forChannel = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null;
|
||||||
max_id_accounts = null;
|
max_id_accounts = null;
|
||||||
flag_loading = true;
|
flag_loading = true;
|
||||||
|
flag_loading_account = false;
|
||||||
firstLoad = true;
|
firstLoad = true;
|
||||||
check_ScrollingUp = false;
|
check_ScrollingUp = false;
|
||||||
|
|
||||||
binding.loader.setVisibility(View.VISIBLE);
|
binding.loader.setVisibility(View.VISIBLE);
|
||||||
binding.loadingNextVideos.setVisibility(View.GONE);
|
binding.loadingNextVideos.setVisibility(View.GONE);
|
||||||
|
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch, forChannel);
|
||||||
peertubeAdapater.playlistListener = this;
|
peertubeAdapater.playlistListener = this;
|
||||||
peertubeAdapater.relationShipListener = this;
|
peertubeAdapater.relationShipListener = this;
|
||||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||||
|
@ -152,6 +153,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
||||||
= new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
= new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
||||||
binding.lvAccounts.setLayoutManager(layoutManager);
|
binding.lvAccounts.setLayoutManager(layoutManager);
|
||||||
binding.lvAccounts.setAdapter(accountsHorizontalListAdapter);
|
binding.lvAccounts.setAdapter(accountsHorizontalListAdapter);
|
||||||
|
|
||||||
if (!Helper.isTablet(context)) {
|
if (!Helper.isTablet(context)) {
|
||||||
mLayoutManager = new LinearLayoutManager(context);
|
mLayoutManager = new LinearLayoutManager(context);
|
||||||
binding.lvVideos.setLayoutManager(mLayoutManager);
|
binding.lvVideos.setLayoutManager(mLayoutManager);
|
||||||
|
@ -170,10 +172,11 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
||||||
binding.lvAccounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
binding.lvAccounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||||
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
|
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
|
||||||
if (dy > 0) {
|
if (dx > 0) {
|
||||||
int visibleItemCount = layoutManager.getChildCount();
|
int visibleItemCount = layoutManager.getChildCount();
|
||||||
int totalItemCount = layoutManager.getItemCount();
|
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));
|
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) {
|
private void manageViewAccounts(APIResponse apiResponse) {
|
||||||
|
flag_loading_account = false;
|
||||||
if (apiResponse != null && apiResponse.getChannels() != null && apiResponse.getChannels().size() > 0) {
|
if (apiResponse != null && apiResponse.getChannels() != null && apiResponse.getChannels().size() > 0) {
|
||||||
if (binding.topAccountContainer.getVisibility() == View.GONE) {
|
if (binding.topAccountContainer.getVisibility() == View.GONE) {
|
||||||
binding.topAccountContainer.setVisibility(View.VISIBLE);
|
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 no item were inserted previously the adapter is created
|
||||||
if (previousPosition == 0) {
|
if (previousPosition == 0) {
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch, forChannel);
|
||||||
peertubeAdapater.playlistListener = DisplayVideosFragment.this;
|
peertubeAdapater.playlistListener = DisplayVideosFragment.this;
|
||||||
peertubeAdapater.relationShipListener = DisplayVideosFragment.this;
|
peertubeAdapater.relationShipListener = DisplayVideosFragment.this;
|
||||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||||
|
|
Loading…
Reference in New Issue