This commit is contained in:
Thomas 2020-09-10 15:56:33 +02:00
parent e8427b883d
commit df0b18f535
2 changed files with 25 additions and 19 deletions

View File

@ -115,6 +115,17 @@ public class DisplayNotificationsFragment extends Fragment {
rootView = null;
}
@Override
public void onResume() {
super.onResume();
if( getActivity() != null && getActivity() != null) {
View action_button = getActivity().findViewById(R.id.action_button);
if( action_button != null) {
action_button.setVisibility(View.GONE);
}
}
}
@Override
public void onCreate(Bundle saveInstance) {
super.onCreate(saveInstance);

View File

@ -84,6 +84,9 @@ public class DisplayStatusFragment extends Fragment implements AccountsHorizonta
private boolean check_ScrollingUp;
private String forAccount;
private ConstraintLayout top_account_container;
private FeedsVM viewModelFeeds;
private SearchVM viewModelSearch;
private AccountsVM viewModelAccounts;
public DisplayStatusFragment() {
}
@ -156,16 +159,15 @@ public class DisplayStatusFragment extends Fragment implements AccountsHorizonta
lv_status.addItemDecoration(new GridSpacingItemDecoration(spanCount, spacing, true));
lv_status.setLayoutManager(gLayoutManager);
}
viewModelAccounts = new ViewModelProvider(DisplayStatusFragment.this).get(AccountsVM.class);
viewModelFeeds = new ViewModelProvider(DisplayStatusFragment.this).get(FeedsVM.class);
viewModelSearch = new ViewModelProvider(DisplayStatusFragment.this).get(SearchVM.class);
swipeRefreshLayout.setOnRefreshListener(this::pullToRefresh);
//Load data depending of the value
if (search_peertube == null) { //Not a Peertube search
FeedsVM viewModel = new ViewModelProvider(this).get(FeedsVM.class);
viewModel.getVideos(type, "0", targetedId, null).observe(DisplayStatusFragment.this.requireActivity(), this::manageVIewVideos);
viewModelFeeds.getVideos(type, "0", targetedId, forAccount).observe(DisplayStatusFragment.this.requireActivity(), this::manageVIewVideos);
} else {
SearchVM viewModel = new ViewModelProvider(this).get(SearchVM.class);
viewModel.getVideos("0", search_peertube).observe(DisplayStatusFragment.this.requireActivity(), this::manageVIewVideos);
viewModelSearch.getVideos("0", search_peertube).observe(DisplayStatusFragment.this.requireActivity(), this::manageVIewVideos);
}
lv_accounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
@ -175,8 +177,7 @@ public class DisplayStatusFragment extends Fragment implements AccountsHorizonta
int visibleItemCount = mLayoutManager.getChildCount();
int totalItemCount = mLayoutManager.getItemCount();
if (firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
AccountsVM viewModel = new ViewModelProvider(DisplayStatusFragment.this).get(AccountsVM.class);
viewModel.getAccounts(max_id_accounts, null, AccountsVM.accountFetch.SUBSCRIPTION).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageViewAccounts(apiResponse));
viewModelAccounts.getAccounts(max_id_accounts, null, AccountsVM.accountFetch.SUBSCRIPTION).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageViewAccounts(apiResponse));
}
}
}
@ -202,8 +203,6 @@ public class DisplayStatusFragment extends Fragment implements AccountsHorizonta
}
}
}
FeedsVM viewModelFeeds = new ViewModelProvider(DisplayStatusFragment.this).get(FeedsVM.class);
SearchVM viewModelSearch = new ViewModelProvider(DisplayStatusFragment.this).get(SearchVM.class);
if (mLayoutManager != null) {
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
if (dy > 0) {
@ -213,7 +212,7 @@ public class DisplayStatusFragment extends Fragment implements AccountsHorizonta
if (!flag_loading) {
flag_loading = true;
if (search_peertube == null) { //Not a Peertube search
viewModelFeeds.getVideos(type, max_id, null, null).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
viewModelFeeds.getVideos(type, max_id, null, forAccount).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
} else {
viewModelSearch.getVideos(max_id, search_peertube).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
}
@ -232,11 +231,9 @@ public class DisplayStatusFragment extends Fragment implements AccountsHorizonta
if (!flag_loading) {
flag_loading = true;
if (search_peertube == null) { //Not a Peertube search
FeedsVM viewModel = new ViewModelProvider(DisplayStatusFragment.this).get(FeedsVM.class);
viewModel.getVideos(type, max_id, null, null).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
viewModelFeeds.getVideos(type, max_id, null, forAccount).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
} else {
SearchVM viewModel = new ViewModelProvider(DisplayStatusFragment.this).get(SearchVM.class);
viewModel.getVideos(max_id, search_peertube).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
viewModelSearch.getVideos(max_id, search_peertube).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
}
nextElementLoader.setVisibility(View.VISIBLE);
}
@ -403,11 +400,9 @@ public class DisplayStatusFragment extends Fragment implements AccountsHorizonta
accountsHorizontalListAdapter.notifyItemRangeRemoved(0, accounts.size());
}
if (search_peertube == null) { //Not a Peertube search
FeedsVM viewModel = new ViewModelProvider(this).get(FeedsVM.class);
viewModel.getVideos(type, "0", targetedId, null).observe(this.requireActivity(), this::manageVIewVideos);
viewModelFeeds.getVideos(type, "0", targetedId, forAccount).observe(this.requireActivity(), this::manageVIewVideos);
} else {
SearchVM viewModel = new ViewModelProvider(this).get(SearchVM.class);
viewModel.getVideos("0", search_peertube).observe(this.requireActivity(), this::manageVIewVideos);
viewModelSearch.getVideos("0", search_peertube).observe(this.requireActivity(), this::manageVIewVideos);
}
}