2

I have recently re-written an app for a client. The original was made up of about 20 activities and has now changed to a single activity and about 7 fragments with ViewModels for each fragment. Its a pretty small app in general so I simply swap fragments on in the activity.

I am at this point because the user complained about the length of time it takes after clicking a button to open the next view. Of course I take into account users action before the transaction and prevent opening multiples of the same fragment. There is still a noticeable latency in the app allowing the user to click away on a screen for 1-2 seconds before the transition happens.

This is my first venture with MVVM architecture components and I have been noticing that fragment inflation seems to be a bit slower than I am used to.

Comparing the original app, an activity -> activity transaction took about .75s. When working with MVP doing a fragment -> fragment its roughly .25s transaction. Using a very similar model to MVP with MVVM the fragment -> fragment transaction is about 1.2s

Looking at the logs I don't see a long lapse of time unaccounted for but I do find that when binding the viewmodel it seems to take nearly .5s.

Note: the only thing being done in onCreateView() is the boilerplate for inflating and binding. onViewCreated() is where observing is declared and there are no large running tasks like DAO operations or API requests on load of the views.

What is the average fragment inflation time you have found and is it longer using MVVM architecture components?

Would the use of ViewPager help here?

DevinM
  • 1,112
  • 1
  • 12
  • 29

0 Answers0