Issue
I have two async task running in a fragment, let's call F1.
The fragment takes 4/5 seconds to load data when it is visible (I have put a progress bar there)
what I want to achieve is:
to run those async task in the fragment as soon as I open the application (loads a different fragment) so that I don't have to show the progress bar when I open that particular fragment (F1), and retain the data until (i) refresh button is clicked or (ii) application is closed/restarted.
I have tried to put the execute() of the async task inside a method and try to call the method from my main fragment. But I am getting error there, because my post execute method has some view attached to it.
protected void onPostExecute(String s) {
super.onPostExecute(s);
recyclerView.getItemAnimator().setChangeDuration(0);
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), mNoOfColumns));
adapterDod=new AdapterDotd(getActivity(),data);
adapterDod.notifyDataSetChanged();
if(AsyncTaskCount == AsyncTaskRequested) {
lottieAnimationView.setVisibility(View.GONE);
}
recyclerView.invalidate();
recyclerView.setAdapter(adapterDod);
}
Solution
i advice you to work with fragment
inside viewpager
that allows you to do load your fragment
data without being visible
Answered By - ismail alaoui
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.