This commit is contained in:
Thomas 2020-12-13 11:48:56 +01:00
parent 500584b9ef
commit a3714a4ecf
3 changed files with 14 additions and 7 deletions

View File

@ -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.AccountData;
import app.fedilab.fedilabtube.client.data.ChannelData;
import app.fedilab.fedilabtube.client.data.PlaylistData;
import app.fedilab.fedilabtube.client.data.VideoData;
@ -84,12 +85,14 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
private TimelineVM.TimelineType timelineType;
private boolean sepiaSearch;
private ChannelData.Channel forChannel;
private AccountData.Account forAccount;
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, ChannelData.Channel forChannel, AccountData.Account forAccount) {
this.videos = videos;
this.timelineType = timelineType;
this.sepiaSearch = sepiaSearch || timelineType == SEPIA_SEARCH;
this.forChannel = forChannel;
this.forAccount = forAccount;
}
@ -129,13 +132,17 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
ownVideos = Helper.isVideoOwner(context, video);
}
String instance = null;
if (sepiaSearch) {
instance = video.getAccount().getHost();
} else if (forChannel != null) {
instance = forChannel.getHost();
} else if (forAccount != null) {
instance = forAccount.getHost();
}
holder.binding.peertubeAccountName.setText(video.getChannel().getAcct());
Helper.loadGiF(context, instance, video.getChannel().getAvatar() != null ? video.getChannel().getAvatar().getPath() : null, holder.binding.peertubeProfile);
@ -176,8 +183,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
Intent intent = new Intent(context, ShowChannelActivity.class);
Bundle b = new Bundle();
b.putParcelable("channel", video.getChannel());
b.putBoolean("sepia_search", sepiaSearch);
if (sepiaSearch) {
b.putBoolean("sepia_search", sepiaSearch || forChannel != null);
if (sepiaSearch || forChannel != null) {
b.putString("peertube_instance", video.getAccount().getHost());
}
intent.putExtras(b);

View File

@ -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, null);
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true, null, 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, null);
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true, null, null);
binding.lvVideos.setAdapter(peertubeAdapater);
} else
peertubeAdapater.notifyItemRangeInserted(previousPosition, videoData.data.size());

View File

@ -143,7 +143,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
binding.loader.setVisibility(View.VISIBLE);
binding.loadingNextVideos.setVisibility(View.GONE);
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch, forChannel);
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch, forChannel, account);
peertubeAdapater.playlistListener = this;
peertubeAdapater.relationShipListener = this;
binding.lvVideos.setAdapter(peertubeAdapater);
@ -360,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, forChannel);
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch, forChannel, account);
peertubeAdapater.playlistListener = DisplayVideosFragment.this;
peertubeAdapater.relationShipListener = DisplayVideosFragment.this;
binding.lvVideos.setAdapter(peertubeAdapater);