I have activity with two tabs. Both tab uses different fragments. When a particular event occur like user click on item, I am opening another fragment in same activity.
I know how to add fragment dynamically and I also know how to animate it.
Here, how I added fragment to frameLayout in my activity:
transaction.setCustomAnimations(R.animator.object_slide_in_up, R.animator.activity_hold) transaction.add(R.id.flSellerHome, fragment) transaction.commit() Everything works fine in emulator and newer phones. I have tested with emulator with api 25, it works fine now flickering occur, When I am testing it with real device with api 23 it flicker little, so it doesn't affect, after then when I tested it with api 19, it flickers too much.
So my question is any best practise for doing animation.
Notes
My third fragment which is dynamically added contains recylerview with around 20 items from local db, and I also done db fatching in background thread.
No loads on main thread. recyclerview is also simple with one Image and three texts.
Image is also loaded using Glide and also I have override function of glide**
any help is appreciated..
4 Answers
Answers 1
I found problem is with recyclerview data updation.
I am loading data in background thread, but when notifying recyclerview, it stucks for small amout of time.
So what I have done is. I have delayed data load for same amount of time which is for animation.
I don't know it is good idea or bad idea. But it is too late for my project so I used this workaround.
Answers 2
The problem is with the RecyclerView which can update.
Answers 3
I wanted to write comment to your answer, but I dont have enough rep, but I want try to advice you something, so sorry for this.
I am loading data in background thread, but when notifying recyclerview, it stucks for small amout of time.
Try to start loading, which you did, after click and show simple ProgressBar, and when data is loaded, hide progress bar, set info to your fragment and then show fragment. Then you will have all data wich you need in fragment when it is attached and can put it (data) to your adapter.
It have to look good.
Answers 4
If it occurs only for API 19 and lower, it may be a lack of performance from the device.
Maybe the problem do not come from Fragments and Animations, but from another functionality which slow down the UI thread. By functionality, I mean the way your fragments communicate together. Do they share a huge amount of data ? Or heavyweight datas ? If so, you should use Async Tasks or Threads.
Good luck !
0 comments:
Post a Comment