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
Currently if there are views whose visibility changes at runtime, we have to explicitly add member variables that represent the visibility status for each view.
This is tedious & error prone.
It would be much better if we add a new annotation @VisibilityState that can auto save the visibility status of a view.
The annotation processor can add a new variable (whose name can be derived from the name of the variable, for eg., mycustomViewRef$$visibility) in the bundle during saveInstanceState & auto apply the visibility status on restoreInstanceState
Here is an example
classMyActivity {
@StateintregularState;
@VisibilityStateTextViewdynamicVisibilityTv;
@VisibilityStateCustomViewcustomView;
publicvoidonSaveInstanceState(BundleoutState) {
super.onSaveInstanceState(outState);
Icepick.saveInstanceState(this, outState); // this should save `regularState`, `dynamicVisibilityTv$$visibility` & `customView$$visibility`
}
publicvoidonRestoreInstanceState(BundlesavedInstanceState) {
// Always call the superclass so it can restore the view hierarchysuper.onRestoreInstanceState(savedInstanceState);
Icepick.restoreInstanceState(this, savedInstanceState); // this should auto restore `regularState`, `dynamicVisibilityTv$$visibility` & `customView$$visibility`
}
}
The text was updated successfully, but these errors were encountered:
Along with visibility state, we should identify additional common views/components whose state we would want to be restore out of the box such as LinearLayoutManager, e.t.c.
Why does anyone needs to pollute code with most basic things when its apt can do this much better
Currently if there are views whose visibility changes at runtime, we have to explicitly add member variables that represent the visibility status for each view.
This is tedious & error prone.
It would be much better if we add a new annotation
@VisibilityState
that can auto save the visibility status of a view.The annotation processor can add a new variable (whose name can be derived from the name of the variable, for eg.,
mycustomViewRef$$visibility
) in the bundle duringsaveInstanceState
& auto apply the visibility status onrestoreInstanceState
Here is an example
The text was updated successfully, but these errors were encountered: