package com.hh.lib_base;

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

import com.hh.lib_base.log.AppLogUtils;
import com.hh.lib_base.log.CrashLogManager;

/**
 * Description: $
 *
 * @author xwh
 * time 2024/8/19
 **/
public class BaseApplication extends Application {

    private static Context mContext;
    private static Application instance;

    public static Context getContext() {
        return mContext;
    }

    public static Application getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        // 上下文
        mContext = getApplicationContext();
        CrashLogManager crashLog = CrashLogManager.getInstance();
        crashLog.init(getApplicationContext());
        initTimeIntervalMap();
    }

    /**
     *
     * Description:日志文件获取小时区间
     * Time 2024/8/20
     *
    **/
    private void initTimeIntervalMap() {
        for (int i = 0; i < 24; i++) {
            String value;
            int start;
            int end;
            if (i % 2 == 0) {
                //偶数
                start = i;
                end = i + 2;
            } else {
                //奇数
                start = i - 1;
                end = i + 1;
            }
            value = (start > 9 ? start + "" : ("0" + start)) + "_" + (end > 9 ? end + "" : ("0" + end));
            AppLogUtils.intervalMap.put(i, value);
        }
    }
}
