opt
This commit is contained in:
@@ -21,9 +21,12 @@ import com.mogo.commons.network.Constants;
|
||||
import com.mogo.commons.network.ParamsUtil;
|
||||
import com.mogo.commons.network.X509TrustManagerImpl;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.httpdns.MogoHttpDnsHandler;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.network.NetConfig;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Map;
|
||||
@@ -39,7 +42,7 @@ import okhttp3.Request;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AbsMogoApplication extends Application {
|
||||
public abstract class AbsMogoApplication extends Application {
|
||||
|
||||
private static final String TAG = "AbsMogoApplication";
|
||||
|
||||
@@ -53,12 +56,22 @@ public class AbsMogoApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
sApp = this;
|
||||
initARouter();
|
||||
if ( shouldInit() ) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldInit(){
|
||||
private void initARouter() {
|
||||
ARouter.init( sApp );
|
||||
// 初始化 arouter
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
ARouter.openDebug();
|
||||
ARouter.openLog();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldInit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,34 +81,29 @@ public class AbsMogoApplication extends Application {
|
||||
}
|
||||
|
||||
private void syncInit() {
|
||||
// 初始化 arouter
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
ARouter.openDebug();
|
||||
ARouter.openLog();
|
||||
}
|
||||
ARouter.init( sApp );
|
||||
TipToast.init( this, ( ( context, message, tipDrawable ) -> {
|
||||
if ( TextUtils.isEmpty( message ) ) {
|
||||
return null;
|
||||
}
|
||||
View contentView;
|
||||
if(tipDrawable==null) {
|
||||
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);
|
||||
}else{
|
||||
if ( tipDrawable == null ) {
|
||||
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 );
|
||||
} else {
|
||||
// 有图片,使用带图片的布局,当前只实现了左侧图片
|
||||
contentView = LayoutInflater.from(context).inflate(R.layout.module_commons_layout_toast_with_left_drawable, null);
|
||||
TextView txt = contentView.findViewById(R.id.module_commons_toast_msg);
|
||||
ImageView img = contentView.findViewById(R.id.module_commons_toast_left_drawable);
|
||||
img.setImageDrawable(tipDrawable.getDrawable());
|
||||
contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast_with_left_drawable, null );
|
||||
TextView txt = contentView.findViewById( R.id.module_commons_toast_msg );
|
||||
ImageView img = contentView.findViewById( R.id.module_commons_toast_left_drawable );
|
||||
img.setImageDrawable( tipDrawable.getDrawable() );
|
||||
ViewGroup.LayoutParams params = img.getLayoutParams();
|
||||
params.width = tipDrawable.getWidth();
|
||||
params.height = tipDrawable.getHeight();
|
||||
txt.setText(message);
|
||||
txt.setText( message );
|
||||
}
|
||||
return contentView;
|
||||
} ) );
|
||||
DebugConfig.setUseCustomMap( SharedPrefsMgr.getInstance( this ).getBoolean( "useCustomMap", false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +130,7 @@ public class AbsMogoApplication extends Application {
|
||||
} );
|
||||
}
|
||||
|
||||
protected void asyncInitImpl(){
|
||||
protected void asyncInitImpl() {
|
||||
|
||||
}
|
||||
|
||||
@@ -134,6 +142,8 @@ public class AbsMogoApplication extends Application {
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
|
||||
IMogoHttpDns dns = MogoHttpDnsHandler.getHttpDnsApi();
|
||||
|
||||
NetConfig.instance().setSignaturePrefix( Constants.SIGN_PREFIX )
|
||||
.setPublicParams( ParamsUtil.getStaticParams() )
|
||||
.setHostnameVerifier( new AllAllowedHostnameVerifier() )
|
||||
@@ -145,6 +155,7 @@ public class AbsMogoApplication extends Application {
|
||||
.build();
|
||||
return chain.proceed( request );
|
||||
} )
|
||||
.setHttpDns( dns.dns() )
|
||||
.setLoggable( DebugConfig.isDebug() );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user