androidx.lifecycle.LifecycleRegistry Java Examples
The following examples show how to use
androidx.lifecycle.LifecycleRegistry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransactionArchComponentLiveDataTest.java From Gander with Apache License 2.0 | 6 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return dataChangeListener = invocation.getArgument(0); } }).when(transactionDataStore).addDataChangeListener(any(TransactionDataStore.DataChangeListener.class)); httpTransactionWithId1 = getHttpTransactionWithIndex(1); when(transactionDataStore.getTransactionWithId(1)).thenReturn(httpTransactionWithId1); httpTransactionLiveData = new TransactionArchComponentProvider().getLiveData(transactionDataStore, 1); LifecycleOwner lifecycleOwner = mock(LifecycleOwner.class); lifecycleRegistry = new LifecycleRegistry(lifecycleOwner); when(lifecycleOwner.getLifecycle()).thenReturn(lifecycleRegistry); httpTransactionLiveData.observe(lifecycleOwner, testObserver); }
Example #2
Source File: NoPackageTest.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Before public void init() { mLifecycleOwner = mock(LifecycleOwner.class); mLifecycle = mock(Lifecycle.class); when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycle); mRegistry = new LifecycleRegistry(mLifecycleOwner); }
Example #3
Source File: TwoStateOwner.java From FairEmail with GNU General Public License v3.0 | 5 votes |
private void create() { // Initialize registry = new LifecycleRegistry(this); registry.addObserver(new LifecycleObserver() { @OnLifecycleEvent(Lifecycle.Event.ON_ANY) public void onAny() { Log.d("LifeCycle " + name + " state=" + registry.getCurrentState() + " " + registry); } }); setState(Lifecycle.State.CREATED); }
Example #4
Source File: DataRepository.java From FirefoxReality with Mozilla Public License 2.0 | 5 votes |
private DataRepository(final @NonNull AppDatabase database, final @NonNull AppExecutors executors) { mDatabase = database; mExecutors = executors; mLifeCycle = new LifecycleRegistry(this); mLifeCycle.setCurrentState(Lifecycle.State.STARTED); mObservablePopUps = new MediatorLiveData<>(); mObservablePopUps.addSource(mDatabase.sitePermissionDao().loadAll(), sites -> { if (mDatabase.getDatabaseCreated().getValue() != null) { mObservablePopUps.postValue(sites); } }); }
Example #5
Source File: LifecycleViewHolder.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public LifecycleViewHolder(@NonNull View itemView) { super(itemView); lifecycleRegistry = new LifecycleRegistry(this); }
Example #6
Source File: FrameworkLifecycleRegistryActivity.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@NonNull @Override public LifecycleRegistry getLifecycle() { return mLifecycleRegistry; }
Example #7
Source File: KeyboardWidget.java From Android-Keyboard with Apache License 2.0 | 4 votes |
public void onCreate(@Nullable Intent intent) { mLifecycleRegistry = new LifecycleRegistry(this); mLifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE); }
Example #8
Source File: FakeLifecycleOwner.java From mobius with Apache License 2.0 | 4 votes |
FakeLifecycleOwner() { owner = mock(LifecycleOwner.class); lifecycle = new LifecycleRegistry(owner); Mockito.when(owner.getLifecycle()).thenReturn(lifecycle); }
Example #9
Source File: VRBrowserActivity.java From FirefoxReality with Mozilla Public License 2.0 | 4 votes |
public VRBrowserActivity() { mLifeCycle = new LifecycleRegistry(this); mLifeCycle.setCurrentState(Lifecycle.State.INITIALIZED); mViewModelStore = new ViewModelStore(); }
Example #10
Source File: SugarHolder.java From SugarAdapter with Apache License 2.0 | 4 votes |
@NonNull final LifecycleRegistry getLifecycleRegistry() { return mLifecycleRegistry; }
Example #11
Source File: SessionTest.java From firefox-echo-show with Mozilla Public License 2.0 | 3 votes |
private LifecycleOwner mockLifecycleOwner() { final LifecycleOwner lifecycleOwner = mock(LifecycleOwner.class); LifecycleRegistry registry = new LifecycleRegistry(lifecycleOwner); registry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME); doReturn(registry).when(lifecycleOwner).getLifecycle(); return lifecycleOwner; }