This commit is contained in:
wangcongtao
2020-04-15 20:45:43 +08:00
parent 05a0dbb68b
commit aa78e07ce7
13 changed files with 149 additions and 24 deletions

View File

@@ -1,6 +1,12 @@
package com.mogo.commons;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.elegant.analytics.Analytics;
@@ -57,13 +63,40 @@ public class AbsMogoApplication extends Application {
asyncInit();
}
private void syncInit(){
private void syncInit() {
// 初始化 arouter
if ( DebugConfig.isDebug() ) {
ARouter.openDebug();
ARouter.openLog();
}
ARouter.init( sApp );
TipToast.init( this, new TipToast.ToastViewGenerator() {
@Override
public View make( Context context, String message ) {
if ( TextUtils.isEmpty( message ) ) {
return null;
}
View contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast, null );
TextView txt = contentView.findViewById( R.id.module_commons_toast_msg );
txt.setText( message );
return contentView;
}
@Override
public int gravity() {
return Gravity.TOP | Gravity.CENTER_HORIZONTAL;
}
@Override
public int yOffset() {
return sApp.getResources().getDimensionPixelSize( R.dimen.module_commons_toast_y_offset );
}
@Override
public int xOffset() {
return 0;
}
} );
}
/**
@@ -79,12 +112,11 @@ public class AbsMogoApplication extends Application {
return sc;
}
private void asyncInit(){
ThreadPoolService.execute( ()->{
private void asyncInit() {
ThreadPoolService.execute( () -> {
initNetConfig();
initAccountSdk();
// 初始化toast
TipToast.init( sApp, null );
// 初始化埋点
Analytics.getInstance().start( sApp );
Analytics.getInstance().setAppKey( "6bbe7e0e1ecd8e2f8dc336e1678a2791" );