package com.ez.ertc.meeting;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

@SuppressLint("NewApi")
public
/**
 *
 *
 * @author xiezuoyuan
 * @time 2021/5/24 10:43
 */
class EzmLifecycleListener implements Application.ActivityLifecycleCallbacks {
    private int refCount = 0;
    private boolean onBackground = true;

    public boolean isOnBackground() {
        return onBackground;
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {

    }

    @Override
    public void onActivityStarted(Activity activity) {
        refCount++;
        boolean b = refCount <= 0;
        if (onBackground != b){
            onBackground = b;
            ErtcEzmHelper.onBackground(onBackground);
        }
    }

    @Override
    public void onActivityResumed(Activity activity) {

    }

    @Override
    public void onActivityPaused(Activity activity) {

    }

    @Override
    public void onActivityStopped(Activity activity) {
        refCount--;
        boolean b = refCount <= 0;
        if (onBackground != b){
            onBackground = b;
            ErtcEzmHelper.onBackground(onBackground);
        }
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

    }

    @Override
    public void onActivityDestroyed(Activity activity) {

    }
}
