use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class BackstackDelegateTest method onCreateRestoresBackstackKeys.
@Test
public void onCreateRestoresBackstackKeys() {
BackstackDelegate backstackDelegate = new BackstackDelegate(null);
TestKey testKey = new TestKey("hello");
final TestKey restoredKey = new TestKey("world");
ArrayList<Parcelable> restoredKeys = new ArrayList<Parcelable>() {
{
add(restoredKey);
}
};
StateBundle stateBundle = new StateBundle();
stateBundle.putParcelableArrayList(BackstackManager.getHistoryTag(), restoredKeys);
Mockito.when(savedInstanceState.getParcelable(backstackDelegate.getHistoryTag())).thenReturn(stateBundle);
backstackDelegate.onCreate(savedInstanceState, null, HistoryBuilder.single(testKey));
assertThat(backstackDelegate.getBackstack()).isNotNull();
backstackDelegate.setStateChanger(stateChanger);
assertThat(backstackDelegate.getBackstack().getHistory()).containsExactly(restoredKey);
}
use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class BackstackManagerTest method afterClearAndRestorationTheInitialKeysShouldBeRestoredAndNotOverwrittenByRestoredState.
@Test
public void afterClearAndRestorationTheInitialKeysShouldBeRestoredAndNotOverwrittenByRestoredState() {
TestKey initial = new TestKey("initial");
TestKey restored = new TestKey("restored");
ArrayList<Parcelable> history = new ArrayList<>();
history.add(restored);
StateBundle stateBundle = new StateBundle();
stateBundle.putParcelableArrayList(BackstackManager.getHistoryTag(), history);
BackstackManager backstackManager = new BackstackManager();
backstackManager.setup(HistoryBuilder.single(initial));
backstackManager.fromBundle(stateBundle);
backstackManager.setStateChanger(stateChanger);
Backstack backstack = backstackManager.getBackstack();
backstack.goBack();
assertThat(backstack.getHistory()).isEmpty();
backstack.setStateChanger(stateChanger, Backstack.INITIALIZE);
assertThat(backstack.getHistory()).doesNotContain(restored);
assertThat(backstack.getHistory()).containsExactly(initial);
}
use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class ViewPresenter method toBundle.
@NonNull
@Override
public final StateBundle toBundle() {
StateBundle stateBundle = new StateBundle();
onSave(stateBundle);
this.stateBundle = new StateBundle(stateBundle);
return stateBundle;
}
use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class AddOrEditTaskPresenter method toBundle.
public StateBundle toBundle() {
StateBundle bundle = new StateBundle();
bundle.putString("title", title);
bundle.putString("description", description);
return bundle;
}
use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class TasksPresenter method toBundle.
@Override
@NonNull
public StateBundle toBundle() {
StateBundle bundle = new StateBundle();
bundle.putString("FILTERING", filterType.getValue().name());
return bundle;
}
Aggregations