package com.ydl.component.base;


import android.app.Application;
import android.content.Context;
import android.content.Intent;

import com.ydl.devicesidlib.DeviceIDHelper;
import com.ydl.media.audio.PlayService;
import com.ydl.ydlcommon.base.delegate.IAppLifecycles;
import com.ydl.ydlcommon.utils.YdlBuryPointUtil;
import com.yidianling.course.lifeCallback.CoursePlayLifecycle;

import org.jetbrains.annotations.NotNull;

import io.flutter.view.FlutterMain;

/**
 * Created by haorui on 2019-09-02.
 * Des:
 */
public class DemoAppLifecycles implements IAppLifecycles {
    @Override
    public void attachBaseContext(@NotNull Context base) {

    }

    @Override
    public void onCreate(@NotNull Application application) {
        //数据埋点初始化--一定要放在主进程中
        YdlBuryPointUtil.init(application);

        //设备ID初始化
        DeviceIDHelper.getInstance().init(application);

        //Flutter 初始化需要在主线程中执行
        FlutterMain.startInitialization(application);

        Intent intent = new Intent(application, PlayService.class);
        application.startService(intent);

        application.registerActivityLifecycleCallbacks(new CoursePlayLifecycle());
    }

    @Override
    public void onTerminate(@NotNull Application application) {

    }
}
