Эх сурвалжийг харах

移动图片工具类之前

FANGLH 8 жил өмнө
parent
commit
a99c724b74

+ 1 - 5
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/ExpenseReimbursementActivity.java

@@ -1213,14 +1213,10 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
         if (setWindow == null) initPopupWindow();
         setWindow.showAtLocation(getWindow().getDecorView().
                 findViewById(android.R.id.content), Gravity.BOTTOM, 0, 0);
-//        if (VERSION_CODES  < 24) // API版本太高不断刷新View亮度,会有黑缝隙bug
-//            DisplayUtil.backgroundAlpha(this, 0.4f);
     }
     private void closePopupWindow() {
         if (setWindow != null)
             setWindow.dismiss();
-//        if (VERSION_CODES  < 24)
-//            DisplayUtil.backgroundAlpha(this, 1f);
 
         btn_save.setVisibility(View.VISIBLE);
     }
@@ -1347,7 +1343,7 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
         if (ListUtils.isEmpty(mAddCost_list)) {
             for (int i = 0; i < default_Cost.length; i++) {
                 AddCostBean m = new AddCostBean();
-                m.setFcs_itemname(default_Cost[0]);
+                m.setFcs_itemname(default_Cost[i]);
                 mAddCost_list.add(m);
             }
         }

+ 0 - 3
app_core/message/src/main/java/com/umano/message/supertoasts/interfacepack/BaseToast.java

@@ -2,7 +2,6 @@ package com.umano.message.supertoasts.interfacepack;
 
 import android.app.Activity;
 import android.content.Context;
-import android.text.Layout;
 
 /**
  * 统一规范消息组件的调用
@@ -27,7 +26,6 @@ public interface BaseToast {
     void showAtCenter(String text,int messageColor, int background);
     void showAtBottom(String text,int messageColor, int background);
     void showAtNotiftion(Class<? extends Activity> clazz,String title, String text);
-    void CustomLayout(Layout layout);
 
     /**
       * @desc:Activity 生命周期绑定的消息提示
@@ -38,7 +36,6 @@ public interface BaseToast {
     void showAtCenter(Context ct, String text,int messageColor, int background);
     void showAtBottom(Context ct, String text,int messageColor, int background);
     void showAtNotiftion(Context ct,Class<? extends Activity> clazz, String title,String text);
-    void CustomLayout(Context ct,Layout layout);
 
     /**
      * 自定义布局

+ 0 - 10
app_core/message/src/main/java/com/umano/message/supertoasts/utils/ToastImpl.java

@@ -7,7 +7,6 @@ import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
 import android.support.v7.app.NotificationCompat;
-import android.text.Layout;
 import android.view.Gravity;
 import android.view.View;
 import android.widget.TextView;
@@ -60,11 +59,6 @@ public class ToastImpl implements BaseToast {
 
     }
 
-    @Override
-    public void CustomLayout(Layout layout) {
-
-    }
-
 
     @Override
     public void show(Context ct, String text,int messageColor, int background) {
@@ -139,9 +133,5 @@ public class ToastImpl implements BaseToast {
         mNotificationManager.notify(1000, builder.build());
     }
 
-    @Override
-    public void CustomLayout(Context ct, Layout layout) {
-
-    }
 
 }

+ 178 - 17
app_core/message/src/main/java/com/umano/message/supertoasts/utils/ToastUtils.java

@@ -1,33 +1,194 @@
 package com.umano.message.supertoasts.utils;
 
-import com.umano.message.supertoasts.interfacepack.BaseToast;
+import android.content.Context;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
 
 /**
- * 全局消息调用层
- * Created by Arison on 2017/5/27.
+ * Created by FANGlh on 2017/8/10.
+ * function:
  */
 
 public class ToastUtils  {
-    private BaseToast mToast;
-    private static ToastUtils instance;
+    private  Toast toast;
+    private LinearLayout toastView;
 
-    public ToastUtils(BaseToast toast){
-        mToast= toast;
+    /**
+     * 修改原布局的Toast
+     */
+    public ToastUtils() {
+
+    }
+
+    /**
+     * 完全自定义布局Toast
+     * @param context
+     * @param view
+     */
+    public ToastUtils(Context context, View view, int duration){
+        toast=new Toast(context);
+        toast.setView(view);
+        toast.setDuration(duration);
+    }
+
+    /**
+     * 向Toast中添加自定义view
+     * @param view
+     * @param postion
+     * @return
+     */
+    public  ToastUtils addView(View view,int postion) {
+        toastView = (LinearLayout) toast.getView();
+        toastView.addView(view, postion);
+
+        return this;
+    }
+
+    /**
+     * 设置Toast字体及背景颜色
+     * @param messageColor
+     * @param backgroundColor
+     * @return
+     */
+    public ToastUtils setToastColor(int messageColor, int backgroundColor) {
+        View view = toast.getView();
+        if(view!=null){
+            TextView message=((TextView) view.findViewById(android.R.id.message));
+            message.setBackgroundColor(backgroundColor);
+            message.setTextColor(messageColor);
+        }
+        return this;
+    }
+
+    /**
+     * 设置Toast字体及背景图片
+     * @param messageColor
+     * @param background
+     * @return
+     */
+    public ToastUtils setToastBackground(int messageColor, int background) {
+        View view = toast.getView();
+        if(view!=null){
+            TextView message=((TextView) view.findViewById(android.R.id.message));
+            message.setBackgroundResource(background);
+            message.setTextColor(messageColor);
+        }
+        return this;
+    }
+
+    /**
+     * 短时间显示Toast
+     */
+    public  ToastUtils Short(Context context, CharSequence message){
+        if(toast==null||(toastView!=null&&toastView.getChildCount()>1)){
+            toast= Toast.makeText(context, message, Toast.LENGTH_SHORT);
+            toastView=null;
+        }else{
+            toast.setText(message);
+            toast.setDuration(Toast.LENGTH_SHORT);
+        }
+        return this;
     }
 
-    public static ToastUtils create(BaseToast mToast){
-        if (instance==null){
-            synchronized (ToastUtils.class){
-                if (instance==null){
-                    instance=new ToastUtils(mToast);
-                }
-            }
+    /**
+     * 短时间显示Toast
+     */
+    public ToastUtils Short(Context context, int message) {
+        if(toast==null||(toastView!=null&&toastView.getChildCount()>1)){
+            toast= Toast.makeText(context, message, Toast.LENGTH_SHORT);
+            toastView=null;
+        }else{
+            toast.setText(message);
+            toast.setDuration(Toast.LENGTH_SHORT);
         }
-        return  instance;
+        return this;
     }
 
+    /**
+     * 长时间显示Toast
+     */
+    public ToastUtils Long(Context context, CharSequence message){
+        if(toast==null||(toastView!=null&&toastView.getChildCount()>1)){
+            toast= Toast.makeText(context, message, Toast.LENGTH_LONG);
+            toastView=null;
+        }else{
+            toast.setText(message);
+            toast.setDuration(Toast.LENGTH_LONG);
+        }
+        return this;
+    }
+
+    /**
+     * 长时间显示Toast
+     *
+     * @param context
+     * @param message
+     */
+    public ToastUtils Long(Context context, int message) {
+        if(toast==null||(toastView!=null&&toastView.getChildCount()>1)){
+            toast= Toast.makeText(context, message, Toast.LENGTH_LONG);
+            toastView=null;
+        }else{
+            toast.setText(message);
+            toast.setDuration(Toast.LENGTH_LONG);
+        }
+        return this;
+    }
 
-    public  BaseToast Builder(){
-        return  mToast;
+    /**
+     * 自定义显示Toast时间
+     *
+     * @param context
+     * @param message
+     * @param duration
+     */
+    public ToastUtils Indefinite(Context context, CharSequence message, int duration) {
+        if(toast==null||(toastView!=null&&toastView.getChildCount()>1)){
+            toast= Toast.makeText(context, message,duration);
+            toastView=null;
+        }else{
+            toast.setText(message);
+            toast.setDuration(duration);
+        }
+        return this;
     }
+
+    /**
+     * 自定义显示Toast时间
+     *
+     * @param context
+     * @param message
+     * @param duration
+     */
+    public ToastUtils Indefinite(Context context, int message, int duration) {
+        if(toast==null||(toastView!=null&&toastView.getChildCount()>1)){
+            toast= Toast.makeText(context, message,duration);
+            toastView=null;
+        }else{
+            toast.setText(message);
+            toast.setDuration(duration);
+        }
+        return this;
+    }
+
+    /**
+     * 显示Toast
+     * @return
+     */
+    public ToastUtils show (){
+        toast.show();
+
+        return this;
+    }
+
+    /**
+     * 获取Toast
+     * @return
+     */
+    public Toast getToast(){
+        return toast;
+    }
+
 }