Skip to content

Commit

Permalink
Fix of #17 BadParcelableException when running from support library v…
Browse files Browse the repository at this point in the history
…ersion 28.0.0
  • Loading branch information
andremion committed Oct 18, 2018
1 parent 82a2d19 commit 1e9762c
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions counterfab/src/main/java/com/andremion/counterfab/CounterFab.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.andremion.counterfab;

import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
Expand All @@ -27,6 +28,7 @@
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION_CODES;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.IntRange;
Expand Down Expand Up @@ -268,6 +270,19 @@ private SavedState(Parcelable superState) {
*/
private SavedState(Parcel in) {
super(in);
readState(in);
}

/**
* Constructor called from {@link #CREATOR}
*/
@TargetApi(VERSION_CODES.N)
private SavedState(Parcel in, ClassLoader loader) {
super(in, loader);
readState(in);
}

private void readState(Parcel in) {
count = in.readInt();
}

Expand All @@ -284,12 +299,19 @@ public String toString() {
+ " count=" + count + "}";
}

public static final Creator<SavedState> CREATOR
= new Creator<SavedState>() {
public static final Creator<SavedState> CREATOR = new ClassLoaderCreator<SavedState>() {

@Override
public SavedState createFromParcel(Parcel in, ClassLoader loader) {
return new SavedState(in, loader);
}

@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}

@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
Expand Down

0 comments on commit 1e9762c

Please sign in to comment.