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

Class cast exception #303

Closed
uzghun opened this issue May 20, 2016 · 1 comment
Closed

Class cast exception #303

uzghun opened this issue May 20, 2016 · 1 comment

Comments

@uzghun
Copy link

uzghun commented May 20, 2016

Some times app crashes with class cast exception.

java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to pl.droidsonroids.gif.GifViewSavedState

@koral--
Copy link
Owner

koral-- commented May 21, 2016

One of the possible reasons is that you have extended one of the library Views like GifTextView and overrode onSave/onRestoreInstanceState method(s) in a way that saved state received in onRestoreInstanceState is not an instance of GifViewSavedState.
To restore view state correctly pattern with passing superclass state has to be followed, eg. this is how CompoundButton from Android framework implements it. As you can see ClassCastException will also occur in analogous case with CompoundButton.

However I just discovered that some framework classes eg. TextView uses more lenient rules.

I can add similar behavior to library classes, so if you pass something which is not an instance of GifViewSavedState then state restoration will be ignored (except for calling superclass method).

If it is not the case please post more info including complete stacktrace and code snippet how you are using library classes.

koral-- added a commit that referenced this issue May 22, 2016
Allowed saved state which are not instance of GifViewSavedState - #303
@koral-- koral-- closed this as completed May 22, 2016
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

2 participants