0

On my fragments that are not loading a lot of data they load very quickly and the drawer closes quick.

However when loading a fragment with a lot of data there is a delay when drawer is closed.

I have setup a progress bar on the main layout to show and put the data loading into a view.post(new Runnable() but the drawer still has a delay when closing. Maybe im not doing something right?

on the fragments OnCreateView method i have this

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_icon_request_list, container, false);

    if (view != null) {
        progressBar = (ProgressBar) getActivity().findViewById(R.id.base_progressSpinner);
        progressBar.setVisibility(View.VISIBLE);
        view.post(new Runnable() {

            @Override
            public void run() {
                try {
                    initCards();
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }
            }
        });
    }
    return view;
}

initCards() is the method doing all the work. There is no work being done on onCreate or onActivityCreated

What am I doing wrong?

BigDX
  • 3,519
  • 5
  • 38
  • 52

1 Answers1

0

you can try using delay , like below :

new Handler().postDelayed(new Runnable() {
    public void run() {
        initCard();
    }
}, 1000);