package com.hh.arome;

import com.alipay.arome.aromecli.AromeInit;
import com.common.lib_base.CommonApplication;
import com.common.lib_base.aop.annotation.Time;
import com.elvishew.xlog.LogLevel;
import com.elvishew.xlog.XLog;
import com.hh.arome.utlis.log.AppLogUtils;
import com.hh.arome.utlis.log.CrashLogManager;

public class MyApplication extends CommonApplication {



    /**
     * 全局上下文
     */
    private static MyApplication mContext;

    public static MyApplication getContext() {
        return mContext;
    }


    @Time
    @Override
    public void onCreate() {
        super.onCreate();

        mContext = this;

        XLog.init(LogLevel.ALL);

        // AMPE
        AromeInit.attachApplicationContext(this);

        // 写入日志相关
        initTimeIntervalMap();
        CrashLogManager crashLog = CrashLogManager.getInstance();
        crashLog.init(getApplicationContext());
    }

    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);
        }
    }



}
