Java Code Examples for androidx.lifecycle.Lifecycle#State
The following examples show how to use
androidx.lifecycle.Lifecycle#State .
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: TwoStateOwner.java From FairEmail with GNU General Public License v3.0 | 6 votes |
private void setState(@NonNull Lifecycle.State state) { try { registry.setCurrentState(state); } catch (Throwable ex) { Log.e(ex); /* java.lang.RuntimeException: Failed to call observer method at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(SourceFile:226) at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(SourceFile:194) at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(SourceFile:186) at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(SourceFile:37) at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(SourceFile:361) at androidx.lifecycle.LifecycleRegistry.backwardPass(SourceFile:316) at androidx.lifecycle.LifecycleRegistry.sync(SourceFile:334) at androidx.lifecycle.LifecycleRegistry.moveToState(SourceFile:145) at androidx.lifecycle.LifecycleRegistry.setCurrentState(SourceFile:118) */ } }
Example 2
Source File: TwoStateOwner.java From FairEmail with GNU General Public License v3.0 | 5 votes |
void destroy() { Lifecycle.State state = registry.getCurrentState(); if (!state.equals(Lifecycle.State.CREATED)) setState(Lifecycle.State.CREATED); if (!state.equals(Lifecycle.State.DESTROYED)) setState(Lifecycle.State.DESTROYED); }
Example 3
Source File: FragmentHelper.java From AndroidNavigation with MIT License | 5 votes |
public static void addFragmentToAddedList(@NonNull FragmentManager fragmentManager, int containerId, @NonNull AwesomeFragment fragment, @NonNull Lifecycle.State maxLifecycle, boolean primary) { if (fragmentManager.isDestroyed()) { return; } FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(containerId, fragment, fragment.getSceneId()); if (primary) { transaction.setPrimaryNavigationFragment(fragment); // primary } transaction.setMaxLifecycle(fragment, maxLifecycle); transaction.commit(); executePendingTransactionsSafe(fragmentManager); }
Example 4
Source File: TwoStateOwner.java From FairEmail with GNU General Public License v3.0 | 4 votes |
void start() { Lifecycle.State state = registry.getCurrentState(); if (!state.equals(Lifecycle.State.STARTED) && !state.equals(Lifecycle.State.DESTROYED)) setState(Lifecycle.State.STARTED); }
Example 5
Source File: TwoStateOwner.java From FairEmail with GNU General Public License v3.0 | 4 votes |
void stop() { Lifecycle.State state = registry.getCurrentState(); if (!state.equals(Lifecycle.State.CREATED) && !state.equals(Lifecycle.State.DESTROYED)) setState(Lifecycle.State.CREATED); }
Example 6
Source File: FakeLifecycleOwner.java From mobius with Apache License 2.0 | 4 votes |
public Lifecycle.State getCurrentState() { return lifecycle.getCurrentState(); }
Example 7
Source File: FragmentHelper.java From AndroidNavigation with MIT License | 4 votes |
public static void addFragmentToAddedList(@NonNull FragmentManager fragmentManager, int containerId, @NonNull AwesomeFragment fragment, @NonNull Lifecycle.State maxLifecycle) { addFragmentToAddedList(fragmentManager, containerId, fragment, maxLifecycle, true); }
Example 8
Source File: LiveEventBusCore.java From LiveEventBus with Apache License 2.0 | 4 votes |
@Override protected Lifecycle.State observerActiveLevel() { return lifecycleObserverAlwaysActive ? Lifecycle.State.CREATED : Lifecycle.State.STARTED; }