use of proton.inject.observer.event.OnCreateEvent in project AndroidTraining by mixi-inc.
the class ProtonService method onCreate.
@Override
public void onCreate() {
Injector injector = Proton.getInjector(this);
mObserverManager = injector.getInstance(ObserverManager.class);
injector.inject(this);
super.onCreate();
mObserverManager.fire(new OnCreateEvent(null));
}
use of proton.inject.observer.event.OnCreateEvent in project AndroidTraining by mixi-inc.
the class ObserverTest method testFire.
public void testFire() {
ObserverManager manager = mInjector.getInstance(ObserverManager.class);
Observer observer = mInjector.getInstance(Observer.class);
OnCreateEvent event = new OnCreateEvent(null);
manager.fire(event);
assertEquals(event, observer.event);
}
use of proton.inject.observer.event.OnCreateEvent in project AndroidTraining by mixi-inc.
the class StateRecoveryTest method testRecovery.
public void testRecovery() {
mObserverManager.fire(new OnCreateEvent(null));
Aaa a1 = mInjector.getInstance(Aaa.class);
a1.intState = 1;
a1.integerState = Integer.valueOf(1);
a1.intArrayState[0] = 1;
ArrayList<Integer> integerList = new ArrayList<Integer>();
integerList.add(1);
a1.integerListState = integerList;
a1.stringState = "a";
a1.stringArrayState = new String[] { "aa" };
ParcelableClass parcelable = new ParcelableClass("a");
a1.parcelableState = parcelable;
ParcelableClass[] parcelableArray = new ParcelableClass[1];
parcelableArray[0] = new ParcelableClass("a");
a1.parcelableArrayState = parcelableArray;
Bundle outState = new Bundle();
mObserverManager.fire(new OnSaveInstanceStateEvent(outState));
mObserverManager.fire(new OnDestroyEvent());
Injector injector = Proton.getInjector(new MockContext(mMockApplication));
injector.getInstance(StateEventObserver.class);
injector.getInstance(ObserverManager.class).fire(new OnCreateEvent(outState));
Aaa a2 = injector.getInstance(Aaa.class);
assertNotSame(a1, a2);
assertEquals(1, a2.intState);
assertEquals(Integer.valueOf(1), a2.integerState);
assertEquals(1, a2.intArrayState[0]);
assertEquals("a", a2.stringState);
assertEquals("aa", a2.stringArrayState[0]);
assertEquals(integerList, a2.integerListState);
assertEquals("a", a2.parcelableState.string);
assertEquals("a", a2.parcelableArrayState[0].string);
injector.getInstance(ObserverManager.class).fire(new OnDestroyEvent());
}
use of proton.inject.observer.event.OnCreateEvent in project AndroidTraining by mixi-inc.
the class ProtonListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Injector injector = Proton.getInjector(this);
mObserverManager = injector.getInstance(ObserverManager.class);
mStateEventObserver = injector.getInstance(StateEventObserver.class);
injector.inject(this);
super.onCreate(savedInstanceState);
mObserverManager.fire(new OnCreateEvent(savedInstanceState));
}
use of proton.inject.observer.event.OnCreateEvent in project AndroidTraining by mixi-inc.
the class ProtonLauncherActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Injector injector = Proton.getInjector(this);
mObserverManager = injector.getInstance(ObserverManager.class);
mStateEventObserver = injector.getInstance(StateEventObserver.class);
injector.inject(this);
super.onCreate(savedInstanceState);
mObserverManager.fire(new OnCreateEvent(savedInstanceState));
}
Aggregations