opt
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.commons;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -24,6 +25,7 @@ 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.TipDrawable;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.network.NetConfig;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
@@ -85,25 +87,33 @@ public abstract class AbsMogoApplication extends Application {
|
||||
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 {
|
||||
// 有图片,使用带图片的布局,当前只实现了左侧图片
|
||||
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 );
|
||||
try {
|
||||
View contentView = generateToastView( context, message, tipDrawable );
|
||||
return contentView;
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
return contentView;
|
||||
return null;
|
||||
} ) );
|
||||
DebugConfig.setUseCustomMap( SharedPrefsMgr.getInstance( this ).getBoolean( "useCustomMap", false ) );
|
||||
}
|
||||
|
||||
private View generateToastView( Context context, String message, TipDrawable tipDrawable){
|
||||
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{
|
||||
// 有图片,使用带图片的布局,当前只实现了左侧图片
|
||||
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);
|
||||
}
|
||||
return contentView;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user