package com.ycgis.macall.personalcenter.p.app;

import androidx.core.content.ContextCompat;

import com.anhui.police.auth.sdk.AuthConfig;
import com.anhui.police.auth.sdk.AuthSDK;
import com.anhui.police.auth.sdk.AuthType;
import com.anhui.police.market.sdk.MarketConfigure;
import com.rs.macall.androidx.basemodel.base.BaseApplication;
import com.rs.macall.androidx.basemodel.utils.LogUtils;
import com.ruansee.macall.unifyservemodulesdk.USMConfigure;
import com.ycgis.macall.personalcenter.R;
import com.ycgis.macall.personalcenter.util.FileUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * created by:   Macall
 * create time:  2023/10/25 15:00
 * copyright:    @ruansee.com
 * Describe:
 */
public class RuanseeApplication extends BaseApplication {
    public static final boolean isPrintLog = true;
    public static final boolean isHFVersion = false;
    private static AppCache appCache;
    private static UserData userData;
    public static boolean isShowIIIAppTitle = false;

    //    public static final int RefreshMessageTime = 20000;
    public static final int RefreshMessageTime = 2 * 60 * 1000;

    /**
     * 查询消息的时间间隔
     */
    public static final int REFRESH_MESSAGE_TIME = 2*1000*60;

    static {
        CACHE_FILE_NAME = "newPersonalCenterSP";
        isShowWatermark  = true;
    }

    @Override
    protected void init() {
        appCache = AppCache.getAppCacheData();
        userData = UserData.getUserData();

        FileUtils.initFilePath(getApplication());
        new LogUtils.Builder(FileUtils.LOG_DIR)
                .setBorderSwitch(isPrintLog)
                .setLogSwitch(isPrintLog)
                .setLog2FileSwitch(false);
//        DeviceIdentifier.register(this);

        //统一服务组件
        USMConfigure.getDefault().init("11811535", "grzx_test_app");

        List<AuthType> types = new ArrayList<>();
        types.add(appCache.getAuthType());
        AuthConfig config = AuthConfig.builder();
        config.setThemeColor(ContextCompat.getColor(getApplicationContext(), R.color.colorAccent));
        config.setAuthTypes(types);
        AuthSDK.init("55b161aefd464849b48986a1073d5622", this, config);
//        AuthMarkManager.setShowAuthMark(true);
        //应用中心检测更新
        MarketConfigure.init(this, "442eab382e6a49649e3402115bd8837f", MarketConfigure.MarketDeviceType.DEVICE_TYPE_PHONE);
        MarketConfigure.setUseMarketDownloadHelper(true);
        CrashHandler.getInstance().init(getApplication(),FileUtils.LOG_DIR);
    }

    public static AppCache getAppCache() {
        return appCache;
    }

    public static void setAppCache(AppCache appCache) {
        RuanseeApplication.appCache = appCache;
    }

    public static UserData getUserData() {
        return userData;
    }

    public static void setUserData(UserData userData) {
        RuanseeApplication.userData = userData;
    }


}
