Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Allow saving state for multiple views in a single State (for MultiKeys) #230

Merged
merged 2 commits into from
Feb 15, 2017

Conversation

edenman
Copy link
Contributor

@edenman edenman commented Feb 13, 2017

Fixes #229

Copy link
Collaborator

@loganj loganj left a comment

Choose a reason for hiding this comment

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

Couple small notes, LG otherwise.

for (int viewId : viewIds) {
SparseArray<Parcelable> viewState =
savedState.getSparseParcelableArray(VIEW_STATE_PREFIX + viewId);
if (viewState != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be null? If there's an id, seems like there should be a SparseArray for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might not be: the view could have saveEnabled="false" and there's this check in the toBundle method:

      SparseArray<Parcelable> viewState = entry.getValue();
      if (viewState.size() > 0) {
        outState.putSparseParcelableArray(VIEW_STATE_PREFIX + viewId, viewState);
      }

Copy link
Collaborator

Choose a reason for hiding this comment

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

got it, thanks

return state;
}

private final Object key;
@Nullable private Bundle bundle;
@Nullable SparseArray<Parcelable> viewState;
// TODO shouldn't this be private?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, it should. Mind making the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@loganj loganj merged commit ea2308f into square:master Feb 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants