public AdsManager(Context context, LifecycleRegistry lifecycleRegistry) { this.context = context; this.lifecycleRegistry = lifecycleRegistry; RxLifecycle.with(lifecycleRegistry) .onResume() .doOnSubscribe(compositeDisposable::add) .subscribe(resume -> this.onResume()); RxLifecycle.with(lifecycleRegistry) .onPause() .doOnSubscribe(compositeDisposable::add) .subscribe(resume -> this.onPause()); RxLifecycle.with(lifecycleRegistry) .onDestroy() .doOnSubscribe(compositeDisposable::add) .subscribe(resume -> this.onDestroy()); }
private LifecycleRegistry init() { LifecycleRegistry registry = new LifecycleRegistry(this); registry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE); registry.handleLifecycleEvent(Lifecycle.Event.ON_START); registry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME); return registry; }
public void bind(LifecycleRegistry lifecycle, V view) { unbind(); this.viewReference = new WeakReference<V>(view); RxLifecycle.with(lifecycle) .onDestroy() .doOnSubscribe(this::call) .subscribe(x -> unbind()); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLifecycleRegistry = new LifecycleRegistry(this); mLifecycleRegistry.markState(Lifecycle.State.CREATED); navigator = NavigatorFactory.getInstance(); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); restoreViewStateFromBundle(savedInstanceState); initialize(); setupUI(savedInstanceState == null); }
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLifecycleRegistry = new LifecycleRegistry(this); mLifecycleRegistry.markState(Lifecycle.State.CREATED); setRetainInstance(true); navigator = NavigatorFactory.getInstance(); if (savedInstanceState != null && savedInstanceState.containsKey(UI_MODEL)) { viewState = savedInstanceState.getParcelable(UI_MODEL); } initialize(); }
@Override public void onCreate() { super.onCreate(); mLifecycle = new LifecycleRegistry(this); mLifecycle.addObserver(new WallpaperAnalytics(this)); mLifecycle.addObserver(new SourceManager(this)); mLifecycle.addObserver(new NotificationUpdater(this)); mLifecycle.addObserver(new WearableController(this)); mLifecycle.addObserver(new WidgetUpdater(this)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { mLifecycle.addObserver(new ArtworkInfoShortcutController(this, this)); } if (UserManagerCompat.isUserUnlocked(this)) { mLifecycle.handleLifecycleEvent(Lifecycle.Event.ON_START); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { mUnlockReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mLifecycle.handleLifecycleEvent(Lifecycle.Event.ON_START); unregisterReceiver(this); mUnlockReceiver = null; } }; IntentFilter filter = new IntentFilter(Intent.ACTION_USER_UNLOCKED); registerReceiver(mUnlockReceiver, filter); } }
public SourceManager(Context context) { mContext = context; mLifecycle = new LifecycleRegistry(this); mLifecycle.addObserver(new NetworkChangeObserver(mContext)); new SubscriberLiveData().observe(this, source -> { if (source != null) { sendSelectedSourceAnalytics(source.componentName); // Ensure the artwork from the newly selected source is downloaded context.startService(TaskQueueService.getDownloadCurrentArtworkIntent(context)); } }); }
@Override public LifecycleRegistry getLifecycle() { return lifecycleRegistry; }
@Override public LifecycleRegistry getLifecycle() { return registry; }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLifecycleRegistry = new LifecycleRegistry(this); mLifecycleRegistry.markState(Lifecycle.State.CREATED); }
TestLifecycleOwner() { this.lifecycle = new LifecycleRegistry(this); }
@Override public LifecycleRegistry getLifecycle() { return mRegistry; }
public RxLifecycle(LifecycleRegistry lifecycleRegistry) { this.observer = new RxLifecycleObserver(subject); this.lifecycleRegistry = lifecycleRegistry; lifecycleRegistry.addObserver(observer); }
public static RxLifecycle with(LifecycleRegistry lifecycleRegistry) { return new RxLifecycle(lifecycleRegistry); }
public LifecycleRegistry getLifecycle() { return this.mRegistry; }
@MainThread @NonNull @Override public LifecycleRegistry getLifecycle() { return lifecycleRegistry; }
private TestLifecycleOwner(@Nullable LifecycleRegistry registry) { this.registry = registry == null ? new LifecycleRegistry(this) : registry; }