I am working with some fragments but the transition animations when switching from one to another is very laggy and sometimes it even skips the entire animation (which I've read that sometimes is an outcome of poor fragment performance).
The very intriguing thing is that all my data fetching and computation in that fragment is done completely async using coroutines set on computation threads. And the array lists containing the data are not even long or having many parameters. The only thing that I do on the UI thead is to set the final list on the RecyclerView Adapter and notifyDataSetChanged() -> that's all! So my conclusion is that the ViewHolder inflation itself is what causes the lag. The layout XMLs for the ViewHolders are as well very lite (a drawable res and three strings).
In terms of fragment transactions, I replace the current fragment with the new one in my FrameLayout and commit using a custom set of XML object animators.
I've seen some answers saying that I should delay setting the items on the Adapter for about 2 seconds, but hell, it would look really really bad for an end user to navigate in that fragment and wait 2 seconds on a white screen before the data suddenly shows up. I want a smooth 60fps transition to the new fragment, with the data already displayed.
Is this thing even possible on Android? I am not an apple fan, but as far as animations flow and smoothness, iOS devices wreck havoc on the mess that is Android at this subject.
I need any kinds of advices or even examples to show me how to fix this issue.
Thank you!