Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Square mean by 'offscreen fragments being brought back to life' and 'no direct control over animations'?

While discovering Android libraries and frameworks, I came across Square's blog post on Flow and Mortar. The author states that some of the motivations for developing Flow and Mortar was because

... Offscreen fragments mysteriously being brought back to life at odd moments
... No direct control over animation

I am having trouble understanding what the author means. Can anyone elaborate these two pain points the author speaks of?

like image 596
Some Noob Student Avatar asked Aug 20 '14 19:08

Some Noob Student


1 Answers

I recommend you to read Square's new blog post. It clearly describes fragments' problems due to its' complex livecycle, implementation dependent errors, transactions and creation magic. The key idea is that There is no need for new APIs; everything we needed was there from the very beginning: activities, views, and layout inflaters.

Considering your questions:

Offscreen fragments mysteriously being brought back to life at odd moments

Quote from post: If you ever found yourself with a stale unattached fragment recreated on rotation, you know what I'm talking about. ...when restoring the activity instance state, the fragment manager may try to recreate an instance of that fragment class using reflection.

No direct control over animation

About fragment transactions: ...committing a transaction is async and posted at the end of the main thread handler queue. This can leave your app in an unknown state when receiving multiple click events or during configuration changes.

like image 134
Kirill Boyarshinov Avatar answered Nov 11 '22 07:11

Kirill Boyarshinov