Java Code Examples for com.blankj.utilcode.util.Utils#init()

The following examples show how to use com.blankj.utilcode.util.Utils#init() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Configurator.java    From HHComicViewer with Apache License 2.0 6 votes vote down vote up
public final void configure() {
    //初始化OkHttpClient
    if (HH_CONFIGS.get(ConfigKeys.OKHTTP_CLIENT) == null) {
        //添加interceptor
        for (Interceptor interceptor : INTERCEPTORS) {
            BUILDER.addInterceptor(interceptor);
        }
        HH_CONFIGS.put(ConfigKeys.OKHTTP_CLIENT, BUILDER.build());
    }
    //初始化Utils库
    Utils.init((Application) HHEngine.getApplicationContext());
    //初始化icon库
    initIcons();
    //初始化logger库
    Logger.addLogAdapter(new AndroidLogAdapter());
    HH_CONFIGS.put(ConfigKeys.CONFIG_READY, true);
}
 
Example 2
Source File: App.java    From V2EX with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    app = this;
    mSecretConfig = new SecretImpl();
    mSecretConfig.init(this);

    Config.init(this);
    setTheme(getResources().getIdentifier(Config.getConfig(ConfigRefEnum.CONFIG_THEME),
            "style", getPackageName()));
    Logger.addLogAdapter(new AndroidLogAdapter());
    RetrofitManager.init(this);
    Utils.init(this);

    registerActivityLifecycleCallbacks(this);
    setFontScaleAndUiScale();
}
 
Example 3
Source File: UtilsApp.java    From Android-UtilCode with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    // 内存泄露检查工具
    if (LeakCanary.isInAnalyzerProcess(this)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    LeakCanary.install(this);
    Utils.init(this);
    initLog();
    initCrash();
    initAssets();
}
 
Example 4
Source File: App.java    From EasyPopup with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    // init it in the function of onCreate in ur Application
    Utils.init(this);

}
 
Example 5
Source File: App.java    From AndroidSamples with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    instance = this;
    super.onCreate();
    Utils.init(this);
    initLog();
}
 
Example 6
Source File: MyApplication.java    From XBanner with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    ViewTarget.setTagId(R.id.glide_tag);
    //Fresco初始化
    Fresco.initialize(this);
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .addInterceptor(new LoggerInterceptor("Xbanner"))
            .connectTimeout(10000L, TimeUnit.MILLISECONDS)
            .readTimeout(10000L, TimeUnit.MILLISECONDS)
            .build();
    OkHttpUtils.initClient(okHttpClient);
    Utils.init(this);
}
 
Example 7
Source File: BaseApplication.java    From Android-IM with Apache License 2.0 5 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        baseApplication = this;
        MultiDex.install(this);
        sharedPrefHelper = SharedPrefHelper.getInstance();
        sharedPrefHelper.setRoaming(true);
        //开启极光调试
        JPushInterface.setDebugMode(true);
        mContext = BaseApplication.this;
        //实例化极光推送
        JPushInterface.init(mContext);
        //实例化极光IM,并自动同步聊天记录
        JMessageClient.init(getApplicationContext(), true);
        JMessageClient.setDebugMode(true);
        //初始化极光sms
//        SMSSDK.getInstance().initSdk(mContext);
        //初始化数据库
        setupDatabase();
        //通知管理,通知栏开启,其他关闭
        JMessageClient.setNotificationFlag(FLAG_NOTIFY_SILENCE);
        //初始化utils
        Utils.init(this);
        //推送状态
        initJPush2();
        //初始化统计
        JAnalyticsInterface.init(mContext);
        JAnalyticsInterface.setDebugMode(true);

    }
 
Example 8
Source File: BaseApplication.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 程序启动的时候执行
 */
@Override
public void onCreate() {
    Log.d("Application", "onCreate");
    super.onCreate();
    instance = this;
    Utils.init(this);
    ToastUtils.init(this);
    BaseLifecycleCallback.getInstance().init(this);
    BaseAppHelper.get().init(this);
    initAutoSizeConfig();
    initThreadPool();
    InitializeService.start(this);
}
 
Example 9
Source File: ErrorReportApplication.java    From Meteorite with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    mContext = this;
    mHandler = new Handler();
    //AppStatusTracker.init(this);
    Utils.init(this);
    exceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler(handler);
}
 
Example 10
Source File: App.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    context = getApplicationContext();
    Utils.init(this);
    initOkHttpUtil();
    Realm.init(this);

}
 
Example 11
Source File: TestApp.java    From TikTok with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    ARouter.openLog();     // 打印日志
    ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    ARouter.init(this); // 尽可能早,推荐在Application中初始化

    RxToast.init(this)
            .setBackgroundColor("#CC000000")
            .setTextColor("#FFFFFF")
            .setGravity(Gravity.CENTER)
            .setPadding(16, 16, 12, 12)
            .setMaxLines(2)
            .setTextSize(12)
            .setZ(30)
            .setMaxLines(3)
            .apply();

    Utils.init(this);
    DoraemonKit.install(this);
    // H5任意门功能需要,非必须
    DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() {
        @Override
        public void overrideUrlLoading(Context context, String s) {
            // 使用自己的H5容器打开这个链接
            WebView webView = new WebView(context);
            webView.loadUrl(s);
        }
    });

}
 
Example 12
Source File: TestApp.java    From TikTok with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    ARouter.openLog();     // 打印日志
    ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    ARouter.init(this); // 尽可能早,推荐在Application中初始化

    RxToast.init(this)
            .setBackgroundColor("#CC000000")
            .setTextColor("#FFFFFF")
            .setGravity(Gravity.CENTER)
            .setPadding(16, 16, 12, 12)
            .setMaxLines(2)
            .setTextSize(12)
            .setZ(30)
            .setMaxLines(3)
            .apply();

    Utils.init(this);

    DoraemonKit.install(this);
    // H5任意门功能需要,非必须
    DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() {
        @Override
        public void overrideUrlLoading(Context context, String s) {
            // 使用自己的H5容器打开这个链接
        }
    });
}
 
Example 13
Source File: QPMManager.java    From QPM with Apache License 2.0 5 votes vote down vote up
public void init(Application application) {
    Utils.init(application);
    mContext = application.getApplicationContext();

    QPMSortManager.getInstance().init();
    QPMModeManager.getInstance().init();
    QPMSwitchManager.getInstance().init();
    QPMRAnalysisManager.getInstance().start(mContext, Process.myPid(), mContext.getPackageName());
}
 
Example 14
Source File: MyApplication.java    From youqu_master with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    //初始化logger
    LogUtils.logInit(true);
    Utils.init(this);
    initUmeng();
}
 
Example 15
Source File: IApplication.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@Override
public void onCreate() {
    super.onCreate();
    _context = this.getApplicationContext();
    _asset = _context.getAssets();

    //AndroidUtilsCode
    Utils.init(this);

    //skins
    SkinCompatManager.withoutActivity(this)                         // 基础控件换肤初始化
            .addInflater(new SkinMaterialViewInflater())            // material design 控件换肤初始化[可选]
            .addInflater(new SkinConstraintViewInflater())          // ConstraintLayout 控件换肤初始化[可选]
            .addInflater(new SkinCardViewInflater())                // CardView v7 控件换肤初始化[可选]
            .addInflater(new SkinFlycoTabLayoutInflater())
            .setSkinStatusBarColorEnable(true)                      // 关闭状态栏换肤,默认打开[可选]
            .setSkinWindowBackgroundEnable(true)                    // 关闭windowBackground换肤,默认打开[可选]
            .setSkinAllActivityEnable(true)
            .loadSkin();

    //Crash
    CaocConfig.Builder.create()
            .backgroundMode(CaocConfig.BACKGROUND_MODE_SHOW_CUSTOM)
            .enabled(true)
            .trackActivities(true)
            .minTimeBetweenCrashesMs(2000)
            .restartActivity(SplashActivity.class)
            .errorActivity(CrashActivity.class)
            .apply();

    //Bugly
    Bugly.init(getApplicationContext(), SoUtils.getInstance().getBuglyAppId(), false);

    //Sophix
    SophixManager.getInstance().setPatchLoadStatusStub(CommonUtils.getPatchLoadListener());

    //thunder
    XLTaskHelper.init(this);

    //数据库
    DataBaseManager.init(this);

    //播放器配置
    PlayerConfigShare.initPlayerConfigShare(this);

    //检查补丁
    if (AppConfig.getInstance().isAutoQueryPatch()){
        SophixManager.getInstance().queryAndLoadNewPatch();
    }

    startCorrectlyFlag = true;

    //严格模式
    //strictMode();
}
 
Example 16
Source File: MainApplication.java    From SuperNote with GNU General Public License v3.0 4 votes vote down vote up
private void init(){
        Utils.init(getApplicationContext());
        Connector.getDatabase();
}
 
Example 17
Source File: TestUtils.java    From AndroidUtilCode with Apache License 2.0 4 votes vote down vote up
public static void init() {
    Utils.init(RuntimeEnvironment.application);
}
 
Example 18
Source File: BaseTest.java    From AndroidUtilCode with Apache License 2.0 4 votes vote down vote up
public BaseTest() {
    ShadowLog.stream = System.out;
    Utils.init(RuntimeEnvironment.application);
}
 
Example 19
Source File: BaseApp.java    From AndroidSamples with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Utils.init(this);
}