package ai.pai.client.app;

import android.app.Application;

import com.android.common.utils.LogHelper;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.utils.Log;

import java.io.File;

import ai.pai.client.BuildConfig;
import ai.pai.client.utils.Constants;
import ai.pai.client.utils.PatchManager;
import ai.pai.client.utils.PhotoLoader;
import ai.pai.client.utils.UrlContainer;

/**
 * Created by chengzhenyu on 2015/12/9.
 */
public class PaiAiApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        LogHelper.d("PaiAiApplication","app onCreate 应用启动"+System.currentTimeMillis());
        LogHelper.setLogEnable(BuildConfig.isDevMode);
        Log.LOG=false;
        Config.IsToastTip=false;
//        CrashHandler.getInstance().init(this);
        PlatformConfig.setWeixin("wx4e22a0c8ae6d766d", "636ac848016c593575d11143c55c8333");
        PlatformConfig.setQQZone("1105111674","OFQ2J1RBMJyHPW8G");
        PlatformConfig.setSinaWeibo("2730190333","ff16591583c7bcf4a0d781eae316635a");
        PhotoLoader.getInstance(this);
        checkAppDir();
        new PatchManager().patch(this, UrlContainer.PATCH_CONFIG_URL,Constants.APP_PATCH_DIR+File.separator+"patch-"+BuildConfig.VERSION_NAME+".dex","ai.pai.client.patch.PatchesInfoImpl");
    }

    private void checkAppDir(){
        File appImgDir = new File(Constants.APP_IMAGE_DIR);
        appImgDir.mkdirs();
        File appTmpDir = new File(Constants.APP_TEMP_DIR);
        appTmpDir.mkdirs();
        File appUploadDir = new File(Constants.APP_UPLOAD_DIR);
        appUploadDir.mkdirs();
        File patchDir = new File(Constants.APP_PATCH_DIR);
        patchDir.mkdirs();
    }

}
