package com.sjkj.appthreefloor_tsgz.app;

import android.content.Context;

import androidx.annotation.NonNull;

import com.amap.api.maps.MapsInitializer;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
import com.scwang.smartrefresh.layout.api.RefreshFooter;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.sjkj.appthreefloor_tsgz.R;
import com.sjkj.appthreefloor_tsgz.header.MyClassicsHeader;
import com.sjkj.appthreefloor_tsgz.utils.CrashHandler;
import com.sjkj.base_lib.app.BaseApp;
import com.sjkj.base_lib.utils.AppTools;
import com.sjkj.base_lib.utils.Constants;

public class App extends BaseApp {

    static {
        SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
            @NonNull
            @Override
            public RefreshHeader createRefreshHeader(@NonNull Context context, @NonNull RefreshLayout layout) {
                layout.setPrimaryColorsId(R.color.white, R.color.white);//全局设置主题颜色
                return new MyClassicsHeader(context).setAccentColor(0xff666666);
            }
        });
        SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
            @NonNull
            @Override
            public RefreshFooter createRefreshFooter(@NonNull Context context, @NonNull RefreshLayout layout) {
                return new ClassicsFooter(context).setDrawableSize(20);
            }
        });
    }

    @Override
    public void onCreate() {
        super.onCreate();
//        MultiDex.install(this);
        // 本地存储
//        MMKV.initialize(this);
        //极光推送
//        PushUtils.pushInit();
//        PushUtils.getRegistrationId();
//        initHuaWeiMeeting();
        AppTools.initLog();
        CrashHandler.getInstance().init(getApplicationContext());
        AppTools.setCameraType(AppTools.CAMERA_TYPE_DH);
        AppTools.setPackageName(getPackageName());
        MapsInitializer.updatePrivacyAgree(this,true);
        MapsInitializer.updatePrivacyShow(this,true,true);
        AppTools.initDefaultLatLng(Constants.DEFAULT_LOCATION_LAT, Constants.DEFAULT_LOCATION_LNG);
    }

//    /**
//     * 以下为华为会议初始化方法
//     */
//    private void initHuaWeiMeeting() {//"com.sjkj.integratedplatform"  ccsjkj.top
//        OpenSDKConfig sdkConfig = new OpenSDKConfig(this)
//                .setAppId("3f989ae3a9664bbd8e78dde9d29a5a22")    //设置唯一App ID，可填应用英文名，使用App ID登录必须要设置
//                .setServerAddress("meeting.huaweicloud.com"/*DBConfig.Default.getInstance().getServerAddress()*/)   //设置会议服务器地址
//                .setServerPort("443"/*DBConfig.Default.getInstance().getServerAddress()*/);  //设置会议服务器地址
////                .setServerPort(DBConfig.Default.getInstance().getServerPort());  //设置会议服务器端口
//        LogUtils.e("server_address:" + sdkConfig.getServerAddress());
//        LogUtils.e("server_port:" + sdkConfig.getServerPort());
////        HWMSdk.setServerConfig("http://www.ccsjkj.top.com","443");
////        HWMSdk.init(this, sdkConfig);
//
//        //AppKey 376325f07055e83fbda766a800e5aa580aca87e30dcd0f426058e071d00a360c
//
//        //登录接口
////        HWMSdk.getOpenApi(Application).login(LoginParam, HwmCallback<LoginResult>）;
//        //入会接口
////        HWMSdk.getOpenApi(Application).joinConf(JoinConfParam, HwmCancelableCallBack<Void>);
//        //注销接口
////        HWMSdk.getOpenApi(Application).logout(HwmCallback<LoginCompletedResult>);
//    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }
}
