This commit is contained in:
wangcongtao
2020-12-08 20:46:39 +08:00
parent c6e06132f8
commit ce28a42ae7
8 changed files with 79 additions and 25 deletions

View File

@@ -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;
}
/**

View File

@@ -371,4 +371,17 @@ public class DebugConfig {
public static void setNeedHideAdasWhenShare( boolean isNeedHideAdas ) {
DebugConfig.isNeedHideAdasWhenShare = isNeedHideAdas;
}
/**
* 是否需要实时上报坐标位置
*/
private static boolean sIsNeedUploadCoordinatesInTime = false;
public static boolean isNeedUploadCoordinatesDurationInTime() {
return sIsNeedUploadCoordinatesInTime;
}
public static void setNeedUploadCoordinatesInTime( boolean sIsNeedUploadCoordinatesInTime ) {
DebugConfig.sIsNeedUploadCoordinatesInTime = sIsNeedUploadCoordinatesInTime;
}
}