@Test public void onCreateInvalidNonConfigurationThrowsException() { BackstackDelegate backstackDelegate = new BackstackDelegate(); try { backstackDelegate.onCreate(null, new TestKey("crashpls"), History.single(new TestKey("hello"))); Assert.fail(); } catch(IllegalArgumentException e) { } }
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable Object nonConfigurationInstance, @Nonnull List<?> initialKeys) { if(nonConfigurationInstance != null && !(nonConfigurationInstance instanceof NonConfigurationInstance)) { throw new IllegalArgumentException( "The provided non configuration instance must be of type BackstackDelegate.NonConfigurationInstance!"); } NonConfigurationInstance nonConfig = (NonConfigurationInstance) nonConfigurationInstance; if(nonConfig != null) { backstack = nonConfig.getBackstack(); } if(backstack == null) { backstack = new Backstack(); backstack.setKeyFilter(keyFilter); backstack.setKeyParceler(keyParceler); backstack.setStateClearStrategy(stateClearStrategy); if(scopedServices != null) { backstack.setScopedServices(scopedServices); } if(globalServices != null) { backstack.setGlobalServices(globalServices); } if(globalServiceFactory != null) { backstack.setGlobalServices(globalServiceFactory); } backstack.setup(initialKeys); for(Backstack.CompletionListener completionListener : stateChangeCompletionListeners) { backstack.addStateChangeCompletionListener(completionListener); } if(savedInstanceState != null) { backstack.fromBundle(savedInstanceState.<StateBundle>getParcelable(getHistoryTag())); } } backstack.setStateChanger(stateChanger); }
BackstackDelegate { public void onCreate(@Nullable Bundle savedInstanceState, @Nullable Object nonConfigurationInstance, @Nonnull List<?> initialKeys) { if(nonConfigurationInstance != null && !(nonConfigurationInstance instanceof NonConfigurationInstance)) { throw new IllegalArgumentException( "The provided non configuration instance must be of type BackstackDelegate.NonConfigurationInstance!"); } NonConfigurationInstance nonConfig = (NonConfigurationInstance) nonConfigurationInstance; if(nonConfig != null) { backstack = nonConfig.getBackstack(); } if(backstack == null) { backstack = new Backstack(); backstack.setKeyFilter(keyFilter); backstack.setKeyParceler(keyParceler); backstack.setStateClearStrategy(stateClearStrategy); if(scopedServices != null) { backstack.setScopedServices(scopedServices); } if(globalServices != null) { backstack.setGlobalServices(globalServices); } if(globalServiceFactory != null) { backstack.setGlobalServices(globalServiceFactory); } backstack.setup(initialKeys); for(Backstack.CompletionListener completionListener : stateChangeCompletionListeners) { backstack.addStateChangeCompletionListener(completionListener); } if(savedInstanceState != null) { backstack.fromBundle(savedInstanceState.<StateBundle>getParcelable(getHistoryTag())); } } backstack.setStateChanger(stateChanger); } }
BackstackDelegate { public void onCreate(@Nullable Bundle savedInstanceState, @Nullable Object nonConfigurationInstance, @Nonnull List<?> initialKeys) { if(nonConfigurationInstance != null && !(nonConfigurationInstance instanceof NonConfigurationInstance)) { throw new IllegalArgumentException( "The provided non configuration instance must be of type BackstackDelegate.NonConfigurationInstance!"); } NonConfigurationInstance nonConfig = (NonConfigurationInstance) nonConfigurationInstance; if(nonConfig != null) { backstack = nonConfig.getBackstack(); } if(backstack == null) { backstack = new Backstack(); backstack.setKeyFilter(keyFilter); backstack.setKeyParceler(keyParceler); backstack.setStateClearStrategy(stateClearStrategy); if(scopedServices != null) { backstack.setScopedServices(scopedServices); } if(globalServices != null) { backstack.setGlobalServices(globalServices); } if(globalServiceFactory != null) { backstack.setGlobalServices(globalServiceFactory); } backstack.setup(initialKeys); for(Backstack.CompletionListener completionListener : stateChangeCompletionListeners) { backstack.addStateChangeCompletionListener(completionListener); } if(savedInstanceState != null) { backstack.fromBundle(savedInstanceState.<StateBundle>getParcelable(getHistoryTag())); } } backstack.setStateChanger(stateChanger); } BackstackDelegate();  BackstackDelegate(@Nullable StateChanger stateChanger); }
BackstackDelegate { public void onCreate(@Nullable Bundle savedInstanceState, @Nullable Object nonConfigurationInstance, @Nonnull List<?> initialKeys) { if(nonConfigurationInstance != null && !(nonConfigurationInstance instanceof NonConfigurationInstance)) { throw new IllegalArgumentException( "The provided non configuration instance must be of type BackstackDelegate.NonConfigurationInstance!"); } NonConfigurationInstance nonConfig = (NonConfigurationInstance) nonConfigurationInstance; if(nonConfig != null) { backstack = nonConfig.getBackstack(); } if(backstack == null) { backstack = new Backstack(); backstack.setKeyFilter(keyFilter); backstack.setKeyParceler(keyParceler); backstack.setStateClearStrategy(stateClearStrategy); if(scopedServices != null) { backstack.setScopedServices(scopedServices); } if(globalServices != null) { backstack.setGlobalServices(globalServices); } if(globalServiceFactory != null) { backstack.setGlobalServices(globalServiceFactory); } backstack.setup(initialKeys); for(Backstack.CompletionListener completionListener : stateChangeCompletionListeners) { backstack.addStateChangeCompletionListener(completionListener); } if(savedInstanceState != null) { backstack.fromBundle(savedInstanceState.<StateBundle>getParcelable(getHistoryTag())); } } backstack.setStateChanger(stateChanger); } BackstackDelegate();  BackstackDelegate(@Nullable StateChanger stateChanger); void setKeyFilter(@Nonnull KeyFilter keyFilter); void setKeyParceler(@Nonnull KeyParceler keyParceler); void setStateClearStrategy(@Nonnull Backstack.StateClearStrategy stateClearStrategy); void setScopedServices(@Nullable Activity activity, @Nonnull ScopedServices scopedServices); void setGlobalServices(@Nullable Activity activity, @Nonnull GlobalServices globalServices); void setGlobalServices(@Nullable Activity activity, @Nonnull GlobalServices.Factory globalServiceFactory); void addStateChangeCompletionListener(@Nonnull Backstack.CompletionListener stateChangeCompletionListener); @SuppressWarnings("StringEquality") void setPersistenceTag(@Nonnull String persistenceTag); @TargetApi(14) void registerForLifecycleCallbacks(@Nonnull final Activity activity); void onCreate(@Nullable Bundle savedInstanceState, @Nullable Object nonConfigurationInstance, @Nonnull List<?> initialKeys); void setStateChanger(@Nullable StateChanger stateChanger); NonConfigurationInstance onRetainCustomNonConfigurationInstance(); boolean onBackPressed(); void onSaveInstanceState(@Nonnull Bundle outState); void onPostResume(); void onPause(); void onDestroy(); void persistViewToState(@Nullable View view); void restoreViewFromState(@Nonnull View view); @Nonnull SavedState getSavedState(@Nonnull Object key); boolean hasScope(@Nonnull String scopeTag); boolean hasService(@Nonnull ScopeKey scopeKey, @Nonnull String serviceTag); boolean hasService(@Nonnull String scopeTag, @Nonnull String serviceTag); @Nonnull T getService(@Nonnull ScopeKey scopeKey, @Nonnull String serviceTag); @Nonnull T getService(@Nonnull String scopeTag, @Nonnull String serviceTag); boolean canFindService(@Nonnull String serviceTag); @Nonnull T lookupService(@Nonnull String serviceTag); @Nonnull List<String> findScopesForKey(@Nonnull Object key, @Nonnull ScopeLookupMode lookupMode); boolean canFindFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag); boolean canFindFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag, @Nonnull ScopeLookupMode lookupMode); @Nonnull T lookupFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag); @Nonnull T lookupFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag, @Nonnull ScopeLookupMode lookupMode); @Nonnull Backstack getBackstack(); }
BackstackDelegate { public void onCreate(@Nullable Bundle savedInstanceState, @Nullable Object nonConfigurationInstance, @Nonnull List<?> initialKeys) { if(nonConfigurationInstance != null && !(nonConfigurationInstance instanceof NonConfigurationInstance)) { throw new IllegalArgumentException( "The provided non configuration instance must be of type BackstackDelegate.NonConfigurationInstance!"); } NonConfigurationInstance nonConfig = (NonConfigurationInstance) nonConfigurationInstance; if(nonConfig != null) { backstack = nonConfig.getBackstack(); } if(backstack == null) { backstack = new Backstack(); backstack.setKeyFilter(keyFilter); backstack.setKeyParceler(keyParceler); backstack.setStateClearStrategy(stateClearStrategy); if(scopedServices != null) { backstack.setScopedServices(scopedServices); } if(globalServices != null) { backstack.setGlobalServices(globalServices); } if(globalServiceFactory != null) { backstack.setGlobalServices(globalServiceFactory); } backstack.setup(initialKeys); for(Backstack.CompletionListener completionListener : stateChangeCompletionListeners) { backstack.addStateChangeCompletionListener(completionListener); } if(savedInstanceState != null) { backstack.fromBundle(savedInstanceState.<StateBundle>getParcelable(getHistoryTag())); } } backstack.setStateChanger(stateChanger); } BackstackDelegate();  BackstackDelegate(@Nullable StateChanger stateChanger); void setKeyFilter(@Nonnull KeyFilter keyFilter); void setKeyParceler(@Nonnull KeyParceler keyParceler); void setStateClearStrategy(@Nonnull Backstack.StateClearStrategy stateClearStrategy); void setScopedServices(@Nullable Activity activity, @Nonnull ScopedServices scopedServices); void setGlobalServices(@Nullable Activity activity, @Nonnull GlobalServices globalServices); void setGlobalServices(@Nullable Activity activity, @Nonnull GlobalServices.Factory globalServiceFactory); void addStateChangeCompletionListener(@Nonnull Backstack.CompletionListener stateChangeCompletionListener); @SuppressWarnings("StringEquality") void setPersistenceTag(@Nonnull String persistenceTag); @TargetApi(14) void registerForLifecycleCallbacks(@Nonnull final Activity activity); void onCreate(@Nullable Bundle savedInstanceState, @Nullable Object nonConfigurationInstance, @Nonnull List<?> initialKeys); void setStateChanger(@Nullable StateChanger stateChanger); NonConfigurationInstance onRetainCustomNonConfigurationInstance(); boolean onBackPressed(); void onSaveInstanceState(@Nonnull Bundle outState); void onPostResume(); void onPause(); void onDestroy(); void persistViewToState(@Nullable View view); void restoreViewFromState(@Nonnull View view); @Nonnull SavedState getSavedState(@Nonnull Object key); boolean hasScope(@Nonnull String scopeTag); boolean hasService(@Nonnull ScopeKey scopeKey, @Nonnull String serviceTag); boolean hasService(@Nonnull String scopeTag, @Nonnull String serviceTag); @Nonnull T getService(@Nonnull ScopeKey scopeKey, @Nonnull String serviceTag); @Nonnull T getService(@Nonnull String scopeTag, @Nonnull String serviceTag); boolean canFindService(@Nonnull String serviceTag); @Nonnull T lookupService(@Nonnull String serviceTag); @Nonnull List<String> findScopesForKey(@Nonnull Object key, @Nonnull ScopeLookupMode lookupMode); boolean canFindFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag); boolean canFindFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag, @Nonnull ScopeLookupMode lookupMode); @Nonnull T lookupFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag); @Nonnull T lookupFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag, @Nonnull ScopeLookupMode lookupMode); @Nonnull Backstack getBackstack();  }