package xn.hxp.base;

import android.app.Application;

import com.blankj.utilcode.util.Utils;
import com.hjq.http.EasyConfig;
import com.hjq.toast.Toaster;
import com.kongzue.dialogx.DialogX;
import com.kongzue.dialogx.util.TextInfo;

import okhttp3.OkHttpClient;
import xn.hxp.R;
import xn.hxp.http.RequestHandler;
import xn.hxp.http.RequestServer;
import xn.hxp.room.tool.UserInfoTool;

public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        DialogX.init(this);
        DialogX.globalTheme = DialogX.THEME.DARK;
        DialogX.implIMPLMode = DialogX.IMPL_MODE.WINDOW;
        DialogX.cancelable = false;
        DialogX.cancelableTipDialog = false;
        DialogX.tipProgressColor = getColor(R.color.appColor);
        DialogX.enterAnimDuration = 0;
        DialogX.exitAnimDuration = 0;

        TextInfo textInfo = new TextInfo();
        textInfo.setFontColor(getColor(R.color.appColor));
        textInfo.setFontSizeUnit(TextInfo.FONT_SIZE_UNIT.SP);
        textInfo.setFontSize(20);
        DialogX.tipTextInfo = textInfo;
        DialogX.globalHoverWindow = true;

        OkHttpClient okHttpClient = new OkHttpClient.Builder().build();
        RequestServer requestServer = new RequestServer();
        EasyConfig.with(okHttpClient).setLogEnabled(true).setServer(requestServer).setHandler(new RequestHandler(Utils.getApp())).into();

        // 吐司框架
        Toaster.init(this);

        // 初始化登录状态
        UserInfoTool.INSTANCE.deleteAll();
    }
}
