Java Code Examples for com.alibaba.android.arouter.launcher.ARouter#init()

The following examples show how to use com.alibaba.android.arouter.launcher.ARouter#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: TestModuleApplication.java    From JD-Test with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    if(CommonConfig.DEBUG){
        LeakCanary.install(this);
        ARouter.openLog();     // 打印日志
        ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    }

    ARouter.init(this);
    //CrashReport.initCrashReport(getApplicationContext(), "93f0e37549", CommonConfig.DEBUG);
    Fresco.initialize(this);
    GlobalAppComponent.init(this);
}
 
Example 2
Source File: NgaClientApp.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 5 votes vote down vote up
private void initRouter() {
    if (BuildConfig.DEBUG) {   // 这两行必须写在init之前,否则这些配置在init过程中将无效
        ARouter.openLog();     // 打印日志
        ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    }
    ARouter.init(this); // 尽可能早,推荐在Application中初始化
}
 
Example 3
Source File: DemoApplication.java    From AspectJX-Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    LibrarySDK.init();

    ImageLoader.getInstance().init(new ImageLoaderConfiguration.Builder(this).build());

    ARouter.openLog();
    ARouter.openDebug();
    ARouter.init(this);
}
 
Example 4
Source File: L4Application.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (getApplicationContext().getPackageName().equals(processName)) {

        //Log日志
        KLog.init(BuildConfig.DEBUG);

        ARouter.init(this);

    }
}
 
Example 5
Source File: MyApplication.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    String QQ_ID = "1105143764";
    String WX_ID = "wxfc9207d5bd5c0c53";
    String WEIBO_ID = "645439975";

    String WX_SECRET = "99b535f8e17282f247e8eae4ba57df1b";
    String REDIRECT_URL = "http://sns.whalecloud.com/sina2/callback";

    ShareConfig config = ShareConfig.instance()
            .qqId(QQ_ID)
            .wxId(WX_ID)
            .weiboId(WEIBO_ID)
            // 下面两个,如果不需要登录功能,可不填写
            .weiboRedirectUrl(REDIRECT_URL)
            .debug(true)
            .wxSecret(WX_SECRET);

    ShareManager.init(config);

    ARouter.init(this);

    ISNav.getInstance().init(new ImageLoader() {
        @Override
        public void displayImage(Context context, String path, ImageView imageView) {
            Glide.with(context).load(path).into(imageView);
        }
    });
}
 
Example 6
Source File: L4Application.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (getApplicationContext().getPackageName().equals(processName)) {

        //Log日志
        KLog.init(BuildConfig.DEBUG);

        ARouter.init(this);

    }
}
 
Example 7
Source File: MyApplication.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@Override
    @DebugLog
    public void onCreate() {
        super.onCreate();

        Debug.startMethodTracing("sample");

        MultiDex.install(this);
        Stetho.initializeWithDefaults(this);

        if (BuildConfig.DEBUG) {
            ARouter.openLog();
            ARouter.openDebug();
        }

        ARouter.init(this);
        Fresco.initialize(this);
        String dir = MMKV.initialize(this);
        Log.e("application", "onCreate: mmkv.dir==" + dir);
        WebView.setWebContentsDebuggingEnabled(true);


        DoraemonKit.disableUpload();
        DoraemonKit.install(this);
//        DoraemonKit.hide();
        logLifeCycleCallBacks();

        Debug.stopMethodTracing();
    }
 
Example 8
Source File: MyApplication.java    From AndroidModulePattern with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (Utils.isAppDebug()) {
        //开启InstantRun之后,一定要在ARouter.init之前调用openDebug
        ARouter.openDebug();
        ARouter.openLog();
    }
    ARouter.init(this);
    //崩溃日志记录初始化
    ACRA.init(this);
    ACRA.getErrorReporter().removeAllReportSenders();
    ACRA.getErrorReporter().setReportSender(new CrashReportSender());
}
 
Example 9
Source File: MyAppLifecycles.java    From LQRBiliBlili with MIT License 5 votes vote down vote up
private void initARouter(Application application) {
    if (BuildConfig.LOG_DEBUG) {
        ARouter.openDebug();
        ARouter.openLog();
        ARouter.printStackTrace(); // 打印日志的时候打印线程堆栈
    }
    ARouter.init(application);
}
 
Example 10
Source File: BaseCommonApplication.java    From XModulable with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化路由和组件
 *
 * @param isDebug 是否调试模式
 */
protected final void initRouterAndModule(boolean isDebug) {
    if (isDebug) {           // 这两行必须写在init之前,否则这些配置在init过程中将无效
        ARouter.openLog();     // 打印日志
        ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    }
    ARouter.init(this); // 尽可能早,推荐在Application中初始化

    if (isDebug) {
        XModulable.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    }
    XModulable.init(this); // 必须在ARouter初始化后进行,因为组件对象有可能回包含ARouter对应的IOC
}
 
Example 11
Source File: MyApplication.java    From Router 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中初始化
}
 
Example 12
Source File: MyApplication.java    From SimpleProject with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();

	ARouter.openDebug();
	ARouter.openLog();
	ARouter.init(this);
	ImageLoaderManager.getInstance().init(this, new FrescoInstance());
	LogUtil.i("channel=====" + ChannelUtil.getChannel(this));
}
 
Example 13
Source File: MainActivity.java    From SimpleProject with MIT License 5 votes vote down vote up
@Override
protected void initActivity() {
	ARouter.init(getApplication());
	tabLayout.setCurrentItem(1);
	tabLayout.setItemData(textColor, itemText, unselectedIcon, selectedIcon);
	tabLayout.setOnItemStateListener(new TabLayout.OnItemStateListener() {
		@Override
		public void onItemSelected(int position) {

		}

		@Override
		public void onItemUnSelected() {

		}
	});

	// 设置全局的登录逻辑
	LoginAspect.setOnLoginListener(new LoginAspect.OnLoginListener() {
		@Override
		public void onLogin(ProceedingJoinPoint joinPoint) {
			if (BaseApplication.isLogin) {
				try {
					joinPoint.proceed();
				} catch (Throwable throwable) {
					throwable.printStackTrace(System.err);
				}
			} else {
				LogUtil.i("===========跳转登录");
			}
		}
	});
}
 
Example 14
Source File: App.java    From android-open-framework-analysis with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (BuildConfig.DEBUG) {           // 这两行必须写在init之前,否则这些配置在init过程中将无效
        ARouter.openLog();     // 打印日志
        ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    }
    ARouter.init(this); // 尽可能早,推荐在Application中初始化
}
 
Example 15
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 16
Source File: AppContext.java    From star-zone-android with Apache License 2.0 4 votes vote down vote up
public static void initARouter() {
    ARouter.openLog();
    ARouter.openDebug();
    ARouter.printStackTrace();
    ARouter.init(getAppInstance());
}
 
Example 17
Source File: AppLifecyclesImpl.java    From TikTok with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(@NonNull Application application) {
    if (LeakCanary.isInAnalyzerProcess(application)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    //leakCanary内存泄露检查
    ArmsUtils.obtainAppComponentFromContext(application).extras().put(RefWatcher.class.getName(), BuildConfig.USE_CANARY ? LeakCanary.install(application) : RefWatcher.DISABLED);

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

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

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


            webView.loadUrl(s);

        }
    });


}
 
Example 18
Source File: CommonApplicationLike.java    From AcgClub with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
  mAppComponent = DaggerAppComponent
      .builder()
      .appModule(new AppModule(mApplication))////提供application
      .clientModule(new ClientModule())//用于提供okhttp和retrofit的单例
      .imageModule(new ImageModule())//图片加载框架默认使用glide
      .globeConfigModule(getGlobeConfigModule(mApplication, mModules))//全局配置
      .build();
  mAppComponent.inject(this);
  Utils.initAppComponent(mAppComponent);

  //router
  if (BuildConfig.DEBUG) {
    ARouter.openLog();
    ARouter.openDebug();
    ARouter.printStackTrace();
  }
  ARouter.init(mApplication);

  //db init
  Realm.init(mApplication);

  //init utils
  Utils.init(mApplication);

  //log
  LogUtil.init(BuildConfig.DEBUG);

  //loadsir init
  LoadSir.beginBuilder()
      .addCallback(new LoadingCallback())
      .addCallback(new EmptyCallback())
      .addCallback(new EmptyCollectionCallback())
      .addCallback(new PlaceholderCallback())
      .addCallback(new RetryCallback())
      .setDefaultCallback(LoadingCallback.class)
      .commit();

  mApplication.registerActivityLifecycleCallbacks(mActivityLifecycle);

  for (ConfigModule module : mModules) {
    module.registerComponents(mApplication, mAppComponent.repositoryManager());
  }

  for (Lifecycle lifecycle : mLifecycles) {
    lifecycle.onCreate(mApplication);
  }

  //初始化全局dialog
  StyledDialog.init(mApplication);

  //leakCanary内存泄露检查
  //LeakCanary.install(mApplication);

  //rx全局异常处理
  setRxJavaErrorHandler();
}
 
Example 19
Source File: ARouterUtils.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 4 votes vote down vote up
public static Postcard build(String path) {
    ARouter.init(ContextUtils.getApplication());
    return ARouter.getInstance().build(path);
}
 
Example 20
Source File: BCXApplication.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        // 友盟社会化分享初始化
        UMConfigure.init(this, "5d00ea860cafb258a10004d2", "umeng", UMConfigure.DEVICE_TYPE_PHONE, "");
        PlatformConfig.setWeixin("wx9e2b84f3fb522466", "8d769e483ab92fc2562aad91b79f386c");
//        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
        // 初始化sdk
        CocosBcxApiWrapper.getBcxInstance().init(this);
        //是否开启日志打印
        KLog.init(BuildConfig.IS_TEST_ENV);
        //初始化 ARouter
        if (BuildConfig.DEBUG) { //开启InstantRun之后,一定要在ARouter.init之前调用openDebug
            ARouter.openDebug();
            ARouter.openLog();
        }
        ARouter.init(this);
        ModuleLifecycleConfig.getInstance().initModuleAhead(this); //初始化组件(靠前)
        ModuleLifecycleConfig.getInstance().initModuleLow(this);     //初始化组件(靠后)
        NodeConnectUtil.requestNodeListData(this);
        HttpUtils.getCurrencyRate();
        HttpUtils.getCocosPrice();
//
//        //初始化工具类
//        List<String> mListNode = Arrays.asList("ws://192.168.90.46:8149", "ws://192.168.90.46:8149");
//        String faucetUrl = "http://47.93.62.96:4000";
//        String chainId = "dc57c58b0366a06b33615a10fb624c380557f3642278d51910580ade3ab487fe";
//        String coreAsset = "COCOS";
//        boolean isOpenLog = true;
//        CocosBcxApiWrapper.getBcxInstance().init(this);
//        CocosBcxApiWrapper.getBcxInstance().connect(this, chainId, mListNode, faucetUrl, coreAsset, isOpenLog,
//                new IBcxCallBack() {
//                    @Override
//                    public void onReceiveValue(String value) {
//                        Log.i("initBcxSdk", value);
//                        BaseResult resultEntity = GsonSingleInstance.getGsonInstance().fromJson(value, BaseResult.class);
//                        if (resultEntity.isSuccess()) {
//                            NodeInfoModel.DataBean nodeInfoModel = new NodeInfoModel.DataBean();
//                            nodeInfoModel.chainId = "dc57c58b0366a06b33615a10fb624c380557f3642278d51910580ade3ab487fe";
//                            nodeInfoModel.faucetUrl = "http://47.93.62.96:4000";
//                            nodeInfoModel.coreAsset = "COCOS";
//                            nodeInfoModel.ws = "ws://192.168.90.46:8149";
//                            SPUtils.putObject(BCXApplication.this, SPKeyGlobal.NODE_WORK_MODEL_SELECTED, nodeInfoModel);
//                        }
//                    }
//                });

        //配置全局异常崩溃操作
        CaocConfig.Builder.create()
                .backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT)
                .enabled(true) //是否启动全局异常捕获
                .showRestartButton(true) //是否显示重启按钮
                .showErrorDetails(true)
                .trackActivities(true) //是否跟踪Activity
                .restartActivity(WelcomeActivity.class) //重新启动后的activity
                .errorActivity(DefaultErrorActivity.class) //崩溃后的错误activity
                .apply();
    }