Fix issue

This commit is contained in:
Thomas 2020-09-26 16:52:41 +02:00
parent d878ac780c
commit 2044a85b58
1 changed files with 14 additions and 15 deletions

View File

@ -46,7 +46,6 @@ import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.data.AccountData.Account;
import app.fedilab.fedilabtube.client.data.PlaylistData;
import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.drawer.AccountsHorizontalListAdapter;
import app.fedilab.fedilabtube.drawer.PeertubeAdapter;
@ -69,7 +68,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
private String max_id, max_id_accounts;
private List<VideoData.Video> peertubes;
private List<Account> accounts;
private TimelineVM.TimelineType timelineType;
private TimelineVM.TimelineType type;
private RelativeLayout mainLoader, nextElementLoader, textviewNoAction;
private boolean firstLoad;
private SwipeRefreshLayout swipeRefreshLayout;
@ -103,11 +102,11 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
if (bundle != null) {
search_peertube = bundle.getString("search_peertube", null);
channelId = bundle.getString("channelId", null);
timelineType = (TimelineVM.TimelineType) bundle.get("timelineType");
type = (TimelineVM.TimelineType) bundle.get("timelineType");
}
if (getArguments() != null && timelineType == null) {
timelineType = DisplayVideosFragment.fromBundle(getArguments()).getType();
if (getArguments() != null && type == null) {
type = DisplayVideosFragmentArgs.fromBundle(getArguments()).getType();
}
forAccount = null;
@ -157,7 +156,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
swipeRefreshLayout.setOnRefreshListener(this::pullToRefresh);
//Load data depending of the value
if (search_peertube == null) { //Not a Peertube search
viewModelFeeds.getVideos(timelineType, "0").observe(DisplayVideosFragment.this.requireActivity(), this::manageVIewVideos);
viewModelFeeds.getVideos(type, "0").observe(DisplayVideosFragment.this.requireActivity(), this::manageVIewVideos);
} else {
viewModelSearch.getVideos("0", search_peertube).observe(DisplayVideosFragment.this.requireActivity(), this::manageVIewVideos);
}
@ -176,10 +175,10 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
});
if (timelineType != TimelineVM.TimelineType.OVERVIEW) {
if (type != TimelineVM.TimelineType.OVERVIEW) {
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (timelineType == TimelineVM.TimelineType.SUBSCRIBTIONS) {
if (type == TimelineVM.TimelineType.SUBSCRIBTIONS) {
if (dy > 0) {
if (check_ScrollingUp) {
top_account_container.setVisibility(View.GONE);
@ -204,10 +203,10 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
if (!flag_loading) {
flag_loading = true;
if (search_peertube == null) { //Not a Peertube search
if( timelineType != TimelineVM.TimelineType.USER_VIDEOS){
if( type != TimelineVM.TimelineType.USER_VIDEOS){
viewModelFeeds.getVideosInChannel(channelId, max_id).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
}else {
viewModelFeeds.getVideos(timelineType, max_id).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
viewModelFeeds.getVideos(type, max_id).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
}
} else {
viewModelSearch.getVideos(max_id, search_peertube).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
@ -227,10 +226,10 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
if (!flag_loading) {
flag_loading = true;
if (search_peertube == null) { //Not a Peertube search
if( timelineType != TimelineVM.TimelineType.USER_VIDEOS){
if( type != TimelineVM.TimelineType.USER_VIDEOS){
viewModelFeeds.getVideosInChannel(channelId, max_id).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
}else {
viewModelFeeds.getVideos(timelineType, max_id).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
viewModelFeeds.getVideos(type, max_id).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
}
} else {
viewModelSearch.getVideos(max_id, search_peertube).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
@ -246,7 +245,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
}
});
}
if (timelineType == TimelineVM.TimelineType.SUBSCRIBTIONS) {
if (type == TimelineVM.TimelineType.SUBSCRIBTIONS) {
AccountsVM viewModel = new ViewModelProvider(this).get(AccountsVM.class);
viewModel.getAccounts(RetrofitPeertubeAPI.DataType.SUBSCRIBER, max_id).observe(DisplayVideosFragment.this.requireActivity(), this::manageViewAccounts);
}
@ -402,10 +401,10 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
}
if (search_peertube == null) { //Not a Peertube search
if( timelineType != TimelineVM.TimelineType.USER_VIDEOS){
if( type != TimelineVM.TimelineType.USER_VIDEOS){
viewModelFeeds.getVideosInChannel(channelId, "0").observe(this.requireActivity(), this::manageVIewVideos);
}else {
viewModelFeeds.getVideos(timelineType, "0").observe(this.requireActivity(), this::manageVIewVideos);
viewModelFeeds.getVideos(type, "0").observe(this.requireActivity(), this::manageVIewVideos);
}
} else {
viewModelSearch.getVideos("0", search_peertube).observe(this.requireActivity(), this::manageVIewVideos);