1. 修改TipToast背景为渐变
2. 增加左侧带图片的TipToast
This commit is contained in:
@@ -4,6 +4,8 @@ import android.app.Application;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
@@ -17,6 +19,7 @@ import com.mogo.commons.network.ParamsUtil;
|
||||
import com.mogo.commons.network.X509TrustManagerImpl;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.TipDrawable;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.network.NetConfig;
|
||||
|
||||
@@ -65,13 +68,26 @@ public class AbsMogoApplication extends Application {
|
||||
ARouter.openLog();
|
||||
}
|
||||
ARouter.init( sApp );
|
||||
TipToast.init( this, ( ( context, message ) -> {
|
||||
TipToast.init( this, ( ( context, message, tipDrawable ) -> {
|
||||
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 );
|
||||
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