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

Fix view state persistence #75

Merged
merged 1 commit into from
Apr 13, 2015
Merged

Fix view state persistence #75

merged 1 commit into from
Apr 13, 2015

Conversation

loganj
Copy link
Collaborator

@loganj loganj commented Apr 2, 2015

Thanks to Aleksey Malevaniy for catching these problems and
demonstrating fixes.

This change fixes two problems with view state persistence in
ActivityFlowSupport:

  1. It was just throwing view state away when building the Parcelable to
    save in the Bundle. The fix is to move filtering into Backstack itself,
    so that it can build a Parcelable that includes view state.
  2. It wasn (re)constructing the view hierarchy for the first time in
    onResume(), which is after restoreHierarchyState() is called. View
    state was therefore not getting properly restored. The fix is to rebuild
    the view hierarchy in onCreate(), so that it's there in time for
    restoreHierarchyState().

container = (PathContainerView) findViewById(R.id.container);
containerAsBackTarget = (HandlesBack) container;
flowSupport = ActivityFlowSupport.onCreate(nonConfig, getIntent(), savedInstanceState, parceler,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add javadoc to ActivityFlowSupport#onCreate that this should be called after setContentView.

@rjrjr
Copy link
Collaborator

rjrjr commented Apr 3, 2015

LGTM

Thanks to Aleksey Malevaniy for catching these problems and
demonstrating fixes.

This change fixes two problems with view state persistence in
ActivityFlowSupport:

1. It was just throwing view state away when building the Parcelable to
save in the Bundle. The fix is to move filtering into Backstack itself,
so that it can build a Parcelable that includes view state.

2. It wasn (re)constructing the view hierarchy for the first time in
onResume(), which is after restoreHierarchyState() is called.  View
state was therefore not getting properly restored. The fix is to rebuild
the view hierarchy in onCreate(), so that it's there in time for
restoreHierarchyState().
loganj added a commit that referenced this pull request Apr 13, 2015
@loganj loganj merged commit c9949f1 into master Apr 13, 2015
@loganj loganj deleted the loganj/view_state branch April 13, 2015 16:30
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

Successfully merging this pull request may close these issues.

None yet

2 participants