Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

@InstanceState on custom view is misleading #1959

Copy link
Copy link
@yolapop

Description

@yolapop
Issue body actions

AndroidAnnotations version: 4.2.0

Android compile SDK version: 25

Hi, i found an odd API here. When I found AA has supported @InstanceState, I was happy that I don't have to write custom parcelable again. But, it doesn't work like what I expected.

As you can see here I'm saving view states (background, checked state) on @InstanceState.

Annotated code:

@InstanceState protected boolean checked = false;
@InstanceState protected String label;
@InstanceState protected boolean selectableMode = false;
@InstanceState protected int normalBackgroundColor, selectedBackgroundColor;

But after onRestoreInstanceState is called, there is no way to set the restored states back to the view.

Generated code:

@Override
public void onRestoreInstanceState(Parcelable state) {
    Bundle bundle_ = ((Bundle) state);
    Parcelable instanceState = bundle_.getParcelable(INSTANCE_STATE_KEY);
    super.onRestoreInstanceState(instanceState);
    checked = bundle_.getBoolean("checked");
    label = bundle_.getString("label");
    selectableMode = bundle_.getBoolean("selectableMode");
    normalBackgroundColor = bundle_.getInt("normalBackgroundColor");
    selectedBackgroundColor = bundle_.getInt("selectedBackgroundColor");
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.