diff --git a/.idea/misc.xml b/.idea/misc.xml
index 21e99e2dc0..cd77a1f062 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java
index 360dbb622b..3acc039d7e 100644
--- a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java
@@ -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;
} ) );
}
diff --git a/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml b/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml
index 58389abf7c..b43a13e664 100644
--- a/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml
+++ b/foudations/mogo-commons/src/main/res/drawable/module_commons_toast_bkg.xml
@@ -2,7 +2,7 @@
+ android:angle="180"
+ android:endColor="#FF3F4057"
+ android:startColor="#FF5E6079" />
\ No newline at end of file
diff --git a/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml
index 0b01115f63..636128bfe7 100644
--- a/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml
+++ b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast.xml
@@ -1,27 +1,28 @@
-
+ android:paddingTop="@dimen/module_commons_toast_marginTop"
+ android:paddingBottom="@dimen/module_commons_toast_marginBottom"
+ android:paddingLeft="@dimen/module_commons_toast_marginLeft"
+ android:paddingRight="@dimen/module_commons_toast_marginRight">
-
\ No newline at end of file
+ tools:text="测试测试测试" />
+
+
+
\ No newline at end of file
diff --git a/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast_with_left_drawable.xml b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast_with_left_drawable.xml
new file mode 100644
index 0000000000..8f692353dc
--- /dev/null
+++ b/foudations/mogo-commons/src/main/res/layout/module_commons_layout_toast_with_left_drawable.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml b/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml
index c1558d9ba0..ddb78a45af 100644
--- a/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml
+++ b/foudations/mogo-commons/src/main/res/values-xhdpi/dimens.xml
@@ -1,13 +1,18 @@
- 50px
- 50px
+ 63px
+ 30px
+ 63px
32px
32px
+ 19px
+ 19px
40px
698px
900px
130px
+ 94px
+ 21px
diff --git a/foudations/mogo-commons/src/main/res/values/dimens.xml b/foudations/mogo-commons/src/main/res/values/dimens.xml
index 54534fb37b..4056fd470a 100644
--- a/foudations/mogo-commons/src/main/res/values/dimens.xml
+++ b/foudations/mogo-commons/src/main/res/values/dimens.xml
@@ -1,11 +1,16 @@
- 30px
- 30px
+ 33px
+ 17px
+ 33px
16px
16px
+ 10px
+ 10px
22px
371px
500px
72px
+ 50px
+ 10px
\ No newline at end of file
diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/TipDrawable.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipDrawable.java
new file mode 100644
index 0000000000..9be08550d2
--- /dev/null
+++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipDrawable.java
@@ -0,0 +1,77 @@
+package com.mogo.utils;
+
+import android.graphics.drawable.Drawable;
+
+/**
+ * TipToast弹出框的图片资源封装类
+ * 当前只支持添加一张图片,可添加到文字的 左{@link #TIP_DRAWABLE_GRAVITY_LEFT}, 上{@link #TIP_DRAWABLE_GRAVITY_TOP}, 右{@link #TIP_DRAWABLE_GRAVITY_RIGHT}, 下{@link #TIP_DRAWABLE_GRAVITY_BOTTOM}
+ *
+ * 当前仅支持添加左侧图片,所以{@link #gravity} 这个参数形同虚设
+ *
+ * @author tongchenfei
+ */
+public class TipDrawable {
+ public static final int TIP_DRAWABLE_GRAVITY_LEFT = 1;
+ public static final int TIP_DRAWABLE_GRAVITY_TOP = 2;
+ public static final int TIP_DRAWABLE_GRAVITY_RIGHT = 3;
+ public static final int TIP_DRAWABLE_GRAVITY_BOTTOM = 4;
+ private Drawable drawable;
+ private int gravity;
+ private int width;
+ private int height;
+
+ /**
+ * 默认图片居左,宽高使用{@link Drawable#getIntrinsicWidth()}和{@link Drawable#getIntrinsicHeight()}
+ * @param drawable 要展示的图片
+ */
+ public TipDrawable(Drawable drawable) {
+ this(drawable, TIP_DRAWABLE_GRAVITY_LEFT,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());
+ }
+
+ /**
+ * 默认图片居左
+ * @param drawable 要展示的图片
+ * @param width 要展示的图片宽度
+ * @param height 要展示的图片高度
+ */
+ public TipDrawable(Drawable drawable, int width, int height) {
+ this(drawable, TIP_DRAWABLE_GRAVITY_LEFT,width,height);
+ }
+
+ /**
+ * 默认宽高使用{@link Drawable#getIntrinsicWidth()}和{@link Drawable#getIntrinsicHeight()}
+ * @param drawable 要展示的图片
+ * @param gravity 左{@link #TIP_DRAWABLE_GRAVITY_LEFT}, 上{@link #TIP_DRAWABLE_GRAVITY_TOP}, 右{@link #TIP_DRAWABLE_GRAVITY_RIGHT}, 下{@link #TIP_DRAWABLE_GRAVITY_BOTTOM}
+ */
+ public TipDrawable(Drawable drawable, int gravity) {
+ this(drawable, gravity,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());
+ }
+
+ /**
+ * 可自定义展示位置
+ * @param drawable 要展示的图片
+ * @param gravity 左{@link #TIP_DRAWABLE_GRAVITY_LEFT}, 上{@link #TIP_DRAWABLE_GRAVITY_TOP}, 右{@link #TIP_DRAWABLE_GRAVITY_RIGHT}, 下{@link #TIP_DRAWABLE_GRAVITY_BOTTOM}
+ */
+ public TipDrawable(Drawable drawable, int gravity, int width, int height) {
+ this.drawable = drawable;
+ this.gravity = gravity;
+ this.width = width;
+ this.height = height;
+ }
+
+ public Drawable getDrawable() {
+ return drawable;
+ }
+
+ public int getGravity() {
+ return gravity;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+}
diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java
index ec457c6b04..446762315f 100644
--- a/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java
+++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/TipToast.java
@@ -4,6 +4,10 @@ package com.mogo.utils;
* 2016/1/1 by congtaowang
*
* @Version 1.0
+ *
+ * 增加了图片支持
+ *
+ * @Version 1.1
*/
import android.content.Context;
@@ -45,17 +49,17 @@ public final class TipToast {
sGenerator = null;
}
- private static void tip( final String message, int duration ) {
+ private static void tip( final String message, int duration ,TipDrawable tipDrawable) {
if ( !checkParams() ) {
return;
}
if ( TextUtils.isEmpty( message ) ) {
return;
}
- new ToastThread( new StringToastRunnable( sContext, message, duration ) ).start();
+ new ToastThread(new StringToastRunnable(sContext, message, duration, tipDrawable)).start();
}
- private static void tip( final int msgId, int duration ) {
+ private static void tip( final int msgId, int duration,TipDrawable tipDrawable ) {
if ( !checkParams() ) {
return;
}
@@ -66,7 +70,7 @@ public final class TipToast {
} catch ( Exception e ) {
return;
}
- tip( ResourcesHelper.getString( sContext, msgId ), duration );
+ tip( ResourcesHelper.getString( sContext, msgId ), duration ,tipDrawable);
}
private static boolean checkParams() {
@@ -82,27 +86,53 @@ public final class TipToast {
}
public static void tip( final String message ) {
- tip( message, Toast.LENGTH_SHORT );
+ tip( message, Toast.LENGTH_SHORT,null );
}
public static void tip( final int msgId ) {
- tip( msgId, Toast.LENGTH_SHORT );
+ tip( msgId, Toast.LENGTH_SHORT ,null);
}
public static void longTip( String message ) {
- tip( message, Toast.LENGTH_LONG );
+ tip( message, Toast.LENGTH_LONG ,null);
}
public static void longTip( int msgId ) {
- tip( msgId, Toast.LENGTH_LONG );
+ tip( msgId, Toast.LENGTH_LONG ,null);
}
public static void shortTip( String message ) {
- tip( message, Toast.LENGTH_SHORT );
+ tip( message, Toast.LENGTH_SHORT ,null);
}
public static void shortTip( int msgId ) {
- tip( msgId, Toast.LENGTH_SHORT );
+ tip( msgId, Toast.LENGTH_SHORT ,null);
+ }
+
+ // -===带图片的方法===-
+
+ public static void tip( final String message,TipDrawable tipDrawable ) {
+ tip( message, Toast.LENGTH_SHORT,tipDrawable );
+ }
+
+ public static void tip( final int msgId,TipDrawable tipDrawable ) {
+ tip( msgId, Toast.LENGTH_SHORT ,tipDrawable);
+ }
+
+ public static void longTip( String message,TipDrawable tipDrawable ) {
+ tip( message, Toast.LENGTH_LONG ,tipDrawable);
+ }
+
+ public static void longTip( int msgId ,TipDrawable tipDrawable) {
+ tip( msgId, Toast.LENGTH_LONG ,tipDrawable);
+ }
+
+ public static void shortTip( String message,TipDrawable tipDrawable ) {
+ tip( message, Toast.LENGTH_SHORT ,tipDrawable);
+ }
+
+ public static void shortTip( int msgId,TipDrawable tipDrawable ) {
+ tip( msgId, Toast.LENGTH_SHORT ,tipDrawable);
}
static class ToastThread extends Thread {
@@ -117,11 +147,13 @@ public final class TipToast {
Context context;
String msg;
int duration;
+ TipDrawable tipDrawable;
- public StringToastRunnable( Context context, String msg, int duration ) {
+ public StringToastRunnable( Context context, String msg, int duration,TipDrawable tipDrawable ) {
this.context = context;
this.msg = msg;
this.duration = duration;
+ this.tipDrawable = tipDrawable;
}
@Override
@@ -131,44 +163,40 @@ public final class TipToast {
return;
}
- sHandler.post( new Runnable() {
+ sHandler.post(() -> {
+ synchronized ( sSyncObject ) {
- @Override
- public void run() {
- synchronized ( sSyncObject ) {
+ if ( context == null ) {
+ return;
+ }
- if ( context == null ) {
- return;
- }
+ if ( sToast != null ) {
+ sToast.cancel();
+ }
- if ( sToast != null ) {
- sToast.cancel();
- }
-
- if ( sGenerator == null ) {
- sToast = Toast.makeText( context, msg, duration );
+ if ( sGenerator == null ) {
+ sToast = Toast.makeText( context, msg, duration );
+ } else {
+ sToast = new Toast( context );
+ final View view = sGenerator.make( context, msg, tipDrawable );
+ if ( view != null ) {
+ sToast.setView( view );
+ sToast.setGravity( sGenerator.gravity(), sGenerator.xOffset(), sGenerator.yOffset() );
+ sToast.setDuration( duration );
} else {
- sToast = new Toast( context );
- final View view = sGenerator.make( context, msg );
- if ( view != null ) {
- sToast.setView( view );
- sToast.setGravity( sGenerator.gravity(), sGenerator.xOffset(), sGenerator.yOffset() );
- sToast.setDuration( duration );
- } else {
- sToast = Toast.makeText( context, msg, duration );
- }
- }
- if ( sToast != null ) {
- sToast.show();
+ sToast = Toast.makeText( context, msg, duration );
}
}
+ if ( sToast != null ) {
+ sToast.show();
+ }
}
- } );
+ });
}
}
public interface ToastViewGenerator {
- View make( Context context, String message );
+ View make( Context context, String message,TipDrawable tipDrawable );
default int gravity() {
return Gravity.CENTER;
@@ -182,5 +210,4 @@ public final class TipToast {
return 0;
}
}
-
}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
index 032ba4ee85..11ef74de23 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
@@ -55,6 +55,8 @@ import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.service.windowview.IMogoTopViewStatusListener;
import com.mogo.utils.LaunchUtils;
import com.mogo.utils.ResourcesHelper;
+import com.mogo.utils.TipDrawable;
+import com.mogo.utils.TipToast;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.glide.GlideApp;
import com.mogo.utils.logger.Logger;
@@ -595,6 +597,19 @@ public class EntranceFragment extends MvpFragment TipToast.tip("分享成功"));
+
+ findViewById(R.id.btnShowDrawableTip).setOnClickListener(v->{
+ TipDrawable drawable =
+ new TipDrawable(getResources().getDrawable(R.drawable.model_ext_default_user_head), 150, 150);
+ TipToast.tip("分享成功",drawable);
+ });
+
+ findViewById(R.id.btnShowDrawableTipNoSize).setOnClickListener(v->{
+ TipDrawable drawable =
+ new TipDrawable(getResources().getDrawable(R.drawable.model_ext_default_user_head));
+ TipToast.tip("分享成功",drawable);
+ });
}
@Override
diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
index 495a892b37..655613c89d 100644
--- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
+++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
@@ -174,6 +174,7 @@
android:visibility="gone" />
+
+
+
+
+
+
+ app:constraint_referenced_ids="btnShowDrawableTipNoSize,btnShowDrawableTip,btnShowTextTip,btnDebugCtrlNaviView,btnDebugCtrlSubView,btnDebugCtrlTopView,btnDebugAddBottomLayerView" />
\ No newline at end of file
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluListWindow.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluListWindow.java
index 74044e6225..df4e3cf871 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluListWindow.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluListWindow.java
@@ -94,6 +94,7 @@ import com.mogo.service.module.MogoAction;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.service.windowview.IMogoTopViewStatusListener;
import com.mogo.utils.NetworkUtils;
+import com.mogo.utils.TipDrawable;
import com.mogo.utils.TipToast;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;