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

Add support for visibility state #104

Open
thekalinga opened this issue Aug 9, 2017 · 3 comments
Open

Add support for visibility state #104

thekalinga opened this issue Aug 9, 2017 · 3 comments

Comments

@thekalinga
Copy link

thekalinga commented Aug 9, 2017

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

class MyActivity {
 @State
 int regularState;

 @VisibilityState
 TextView dynamicVisibilityTv;
 @VisibilityState
 CustomView customView;

 public void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  Icepick.saveInstanceState(this, outState); // this should save `regularState`, `dynamicVisibilityTv$$visibility` & `customView$$visibility`
 }

 public void onRestoreInstanceState(Bundle savedInstanceState) {
  // Always call the superclass so it can restore the view hierarchy
  super.onRestoreInstanceState(savedInstanceState);
  Icepick.restoreInstanceState(this, savedInstanceState); // this should auto restore `regularState`, `dynamicVisibilityTv$$visibility` & `customView$$visibility`
 }

}
@ghost
Copy link

ghost commented Aug 10, 2017

Yes, it would be excellent.

@thekalinga
Copy link
Author

thekalinga commented Aug 16, 2017

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

@thekalinga
Copy link
Author

thekalinga commented Aug 16, 2017

@frankiesardo Any views on this?

FYI: I'm not comfortable clojure, else, I would have submitted a pull request :(

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

No branches or pull requests

1 participant