Replaced `Icepick with Bridge and Android-State`
* IcePick fails on Java 21 (default in Android Studio 2024.2) * Bridge is the most modern alternative that is currently available. It is backed by ``Android-State`` and can be configured with various frameworks * In the long term this should be replaced with something better
This commit is contained in:
parent
2482615460
commit
2e96b65fda
30 changed files with 171 additions and 104 deletions
|
|
@ -0,0 +1,61 @@
|
|||
package org.schabi.newpipe.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.evernote.android.state.StateSaver;
|
||||
import com.livefront.bridge.Bridge;
|
||||
import com.livefront.bridge.SavedStateHandler;
|
||||
import com.livefront.bridge.ViewSavedStateHandler;
|
||||
|
||||
/**
|
||||
* Configures Bridge's state saver.
|
||||
*/
|
||||
public final class BridgeStateSaverInitializer {
|
||||
|
||||
public static void init(final Context context) {
|
||||
Bridge.initialize(
|
||||
context,
|
||||
new SavedStateHandler() {
|
||||
@Override
|
||||
public void saveInstanceState(
|
||||
@NonNull final Object target,
|
||||
@NonNull final Bundle state) {
|
||||
StateSaver.saveInstanceState(target, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreInstanceState(
|
||||
@NonNull final Object target,
|
||||
@Nullable final Bundle state) {
|
||||
StateSaver.restoreInstanceState(target, state);
|
||||
}
|
||||
},
|
||||
new ViewSavedStateHandler() {
|
||||
@NonNull
|
||||
@Override
|
||||
public <T extends View> Parcelable saveInstanceState(
|
||||
@NonNull final T target,
|
||||
@Nullable final Parcelable parentState) {
|
||||
return StateSaver.saveInstanceState(target, parentState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends View> Parcelable restoreInstanceState(
|
||||
@NonNull final T target,
|
||||
@Nullable final Parcelable state) {
|
||||
return StateSaver.restoreInstanceState(target, state);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private BridgeStateSaverInitializer() {
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue