Fix classloader when restoring bottom nav state

This commit is contained in:
canyie 2022-01-19 20:22:26 +08:00 committed by John Wu
parent abfd3c3e5d
commit 1f5992f2c2

View File

@ -7,10 +7,10 @@ import android.content.Context;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.customview.view.AbsSavedState;
import androidx.interpolator.view.animation.FastOutLinearInInterpolator; import androidx.interpolator.view.animation.FastOutLinearInInterpolator;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
@ -101,12 +101,12 @@ public class ConcealableBottomNavigationView extends BottomNavigationView {
} }
} }
static class SavedState extends View.BaseSavedState { static class SavedState extends AbsSavedState {
public boolean isHidden; public boolean isHidden;
public SavedState(Parcel source) { public SavedState(Parcel source) {
super(source); super(source, ConcealableBottomNavigationView.class.getClassLoader());
isHidden = source.readByte() != 0; isHidden = source.readByte() != 0;
} }
@ -120,7 +120,7 @@ public class ConcealableBottomNavigationView extends BottomNavigationView {
out.writeByte(isHidden ? (byte) 1 : (byte) 0); out.writeByte(isHidden ? (byte) 1 : (byte) 0);
} }
public static final Creator<SavedState> CREATOR = new Creator<SavedState>() { public static final Creator<SavedState> CREATOR = new Creator<>() {
@Override @Override
public SavedState createFromParcel(Parcel source) { public SavedState createFromParcel(Parcel source) {