You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
Sometimes we need to do something based on whether the activity/fragment is firstly created or re-created (e.g. configuration changes). Usually I check it in onCreate by examining whether the Bundle is null or not. Since in @AfterViews there is no Bundle argument, I have an idea to support such that goal. The code below is just my idea, maybe you have a better idea (or not to accept the idea).
List and usages of the new annotation(s)
No new annotation, only allowing @AfterViews annotated method to have a boolean argument.
While I see the goal - knowing if an Activity or Fragment is newly created or recreated - as a valid request. I'm not sure if @AfterViews is a good place? but as i don't know a better place i think it is okay.
I think I'd prefer to pass the Bundle too. but we have to ensure to null the reference after all @AfterViews methods have been called. (the sample is missing the change of the boolean)
Today I found it's a great idea too. When using a library which needs to restore instance state by passing it savedInstanceState I think that I need the Bundle like you said, because I restore the library's component's views in @AfterViews void initViews().
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description of the feature
Sometimes we need to do something based on whether the activity/fragment is firstly created or re-created (e.g. configuration changes). Usually I check it in
onCreate
by examining whether theBundle
is null or not. Since in@AfterViews
there is noBundle
argument, I have an idea to support such that goal. The code below is just my idea, maybe you have a better idea (or not to accept the idea).List and usages of the new annotation(s)
No new annotation, only allowing
@AfterViews
annotated method to have aboolean
argument.Examples of the generated code
The text was updated successfully, but these errors were encountered: