Search in sources :

Example 1 with DefaultLifecycleObserver

use of androidx.lifecycle.DefaultLifecycleObserver in project Signal-Android by WhisperSystems.

the class TextureViewRenderer method init.

public void init(@NonNull EglBase.Context sharedContext, @Nullable RendererCommon.RendererEvents rendererEvents, @NonNull int[] configAttributes, @NonNull RendererCommon.GlDrawer drawer) {
    ThreadUtils.checkIsOnMainThread();
    this.rendererEvents = rendererEvents;
    this.rotatedFrameWidth = 0;
    this.rotatedFrameHeight = 0;
    this.eglRenderer.init(sharedContext, this, configAttributes, drawer);
    this.lifecycle = ViewUtil.getActivityLifecycle(this);
    if (lifecycle != null) {
        lifecycle.addObserver(new DefaultLifecycleObserver() {

            @Override
            public void onDestroy(@NonNull LifecycleOwner owner) {
                release();
            }
        });
    }
}
Also used : DefaultLifecycleObserver(androidx.lifecycle.DefaultLifecycleObserver) LifecycleOwner(androidx.lifecycle.LifecycleOwner)

Example 2 with DefaultLifecycleObserver

use of androidx.lifecycle.DefaultLifecycleObserver in project Signal-Android by signalapp.

the class TextureViewRenderer method init.

public void init(@NonNull EglBase.Context sharedContext, @Nullable RendererCommon.RendererEvents rendererEvents, @NonNull int[] configAttributes, @NonNull RendererCommon.GlDrawer drawer) {
    ThreadUtils.checkIsOnMainThread();
    this.rendererEvents = rendererEvents;
    this.rotatedFrameWidth = 0;
    this.rotatedFrameHeight = 0;
    this.eglRenderer.init(sharedContext, this, configAttributes, drawer);
    this.lifecycle = ViewUtil.getActivityLifecycle(this);
    if (lifecycle != null) {
        lifecycle.addObserver(new DefaultLifecycleObserver() {

            @Override
            public void onDestroy(@NonNull LifecycleOwner owner) {
                release();
            }
        });
    }
}
Also used : DefaultLifecycleObserver(androidx.lifecycle.DefaultLifecycleObserver) LifecycleOwner(androidx.lifecycle.LifecycleOwner)

Example 3 with DefaultLifecycleObserver

use of androidx.lifecycle.DefaultLifecycleObserver in project Signal-Android by WhisperSystems.

the class AppForegroundObserver method begin.

@MainThread
public void begin() {
    ThreadUtil.assertMainThread();
    ProcessLifecycleOwner.get().getLifecycle().addObserver(new DefaultLifecycleObserver() {

        @Override
        public void onStart(@NonNull LifecycleOwner owner) {
            onForeground();
        }

        @Override
        public void onStop(@NonNull LifecycleOwner owner) {
            onBackground();
        }
    });
}
Also used : DefaultLifecycleObserver(androidx.lifecycle.DefaultLifecycleObserver) LifecycleOwner(androidx.lifecycle.LifecycleOwner) ProcessLifecycleOwner(androidx.lifecycle.ProcessLifecycleOwner) MainThread(androidx.annotation.MainThread)

Example 4 with DefaultLifecycleObserver

use of androidx.lifecycle.DefaultLifecycleObserver in project Signal-Android by signalapp.

the class AppForegroundObserver method begin.

@MainThread
public void begin() {
    ThreadUtil.assertMainThread();
    ProcessLifecycleOwner.get().getLifecycle().addObserver(new DefaultLifecycleObserver() {

        @Override
        public void onStart(@NonNull LifecycleOwner owner) {
            onForeground();
        }

        @Override
        public void onStop(@NonNull LifecycleOwner owner) {
            onBackground();
        }
    });
}
Also used : DefaultLifecycleObserver(androidx.lifecycle.DefaultLifecycleObserver) LifecycleOwner(androidx.lifecycle.LifecycleOwner) ProcessLifecycleOwner(androidx.lifecycle.ProcessLifecycleOwner) MainThread(androidx.annotation.MainThread)

Aggregations

DefaultLifecycleObserver (androidx.lifecycle.DefaultLifecycleObserver)4 LifecycleOwner (androidx.lifecycle.LifecycleOwner)4 MainThread (androidx.annotation.MainThread)2 ProcessLifecycleOwner (androidx.lifecycle.ProcessLifecycleOwner)2