-3

I want to make a smooth transaction between fragments when chosen from the NavigationDrawer. Many of the fragments are rather heavy with its own sub-fragments etc and will cause stutter if just loaded like normal from the main activity/navigation drawer.

What is the best practice here? Right now I'm thinking of creating a "LoadingActiviy" with a transparent background and progressbar inside it. Starting it before fragment is called and finish() it from within the fragment when its finished with all its stuff. So: Create, destroy, create, destroy for every change of page.

Is this a good way of doing it? Feels wrong somehow.

MHopstad
  • 333
  • 2
  • 16

1 Answers1

0

What you're doing is a workaround, not a solution! You're saying that your fragments are heavy so make it not heavy! If fragment takes long to load it usually means that you do a lot of work on the main thread, by offloading your work to other threads your fragment can start right away and show a progress bar if necessary until the job is done.

Alireza Ahmadi
  • 5,122
  • 7
  • 40
  • 67