Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazing. Moar? #1

Open
rjrjr opened this issue Apr 25, 2014 · 5 comments
Open

Amazing. Moar? #1

rjrjr opened this issue Apr 25, 2014 · 5 comments

Comments

@rjrjr
Copy link

rjrjr commented Apr 25, 2014

Have you tried at all to connect the two graphs? The real excitement is when you try to understand how a Fragment's lifecycle interweaves with its Activity's.

@xxv
Copy link
Owner

xxv commented Apr 25, 2014

They actually do interconnect, but clearly in a way that's a bit too subtle for a number of folks (you're not the first to suggest this). They line up temporally in the vertical axis (which is why there are big gaps between some callbacks). Any thoughts on what kind of subtle hint(s) would have helped you better see the relationship between the two?

@madisp
Copy link

madisp commented May 14, 2014

It would be awesome if there would be any indication of atomicity regarding the mainlooper - e.g. show when two callbacks are guaranteed to come from a single message in the mainloop?

@xxv
Copy link
Owner

xxv commented May 14, 2014

@madisp are there any guarantees about that? I don't recall seeing any in the documentation.

While I'd say it may be good to dig through the source and see which ones come from that same message, Android proper doesn't state that there are any guarantees about that, which means you can't rely on it across Android versions. I did try to indicate which of the fragment callbacks were called from the a given callback's super by having them overlap a little vertically, but even that isn't guaranteed.

@madisp
Copy link

madisp commented May 14, 2014

I know there's a guarantee of activity's onDestroy and onCreate callbacks being in a single message if a config change occurred, but I'm not sure if its been documented. See answer in this stackoverflow thread by hackbod:

(And when a config changes, the previous activity's onDestroy() is called and the next one's
onCreate() run without any messages on the main loop processed between them so the
AsyncTask will never see an inconsistent state.)

This is pretty much the only way one can do callbacks from async stuff in Android sanely.

@xxv
Copy link
Owner

xxv commented May 14, 2014

Interesting. Though to be more precise: she doesn't say that they occur in a single message, but rather that there are no messages on the main loop processed between them.

Personally, I prefer to use Loaders or Fragments to manage background threads and retain state across activity configuration changes. They both have slightly more sane retention systems than what you're provided with just straight AsyncTasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants