FANGLH 8 anni fa
parent
commit
75828bf17f

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

@@ -9,6 +9,9 @@ import android.content.Intent;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
+import android.os.Handler;
+import android.text.Editable;
+import android.text.TextWatcher;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.LayoutInflater;
@@ -36,6 +39,7 @@ import com.xzjmyk.pm.activity.ui.erp.view.NScrollerGridView;
 import com.xzjmyk.pm.activity.ui.tool.MultiImagePreviewActivity;
 import com.xzjmyk.pm.activity.util.CameraUtil;
 import com.xzjmyk.pm.activity.util.DisplayUtil;
+import com.xzjmyk.pm.activity.util.StringUtils;
 import com.xzjmyk.pm.activity.util.ToastUtil;
 import com.xzjmyk.pm.activity.view.MyGridView;
 import com.xzjmyk.pm.activity.view.MyListView;
@@ -237,7 +241,7 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                     detailsData.remove(selected_detailsData.get(i));
                     if (i == (selected_detailsData.size()-1)){
                         dtAdapter.setTable_list_type(table_list_type);
-//                        dtAdapter.setTable_list_money(table_list_money);
+                        dtAdapter.setTable_list_money(table_list_money);
                         dtAdapter.notifyDataSetChanged();
                         detail_table_ll.setVisibility(View.VISIBLE);
                         Log.i("selected_detailsData",selected_detailsData.toString()+"se");
@@ -382,9 +386,9 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                                 @Override
                                 public void onClick(DialogInterface dialog, int which) {
                                    table_list_type.remove(position);
-//                                   if (!ListUtils.isEmpty(table_list_money) && table_list_money.get(position) != null){
-//                                       table_list_money.remove(position);
-//                                   }
+                                   if (!ListUtils.isEmpty(table_list_money) && table_list_money.get(position) != null){
+                                       table_list_money.remove(position);
+                                   }
                                    if (ListUtils.isEmpty(table_list_type)){
                                        detail_table_ll.setVisibility(View.GONE);
                                    }else {
@@ -405,23 +409,35 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                 }
             }*/
 
-//            viewHolder.details_money.addTextChangedListener(new TextWatcher() {
-//                @Override
-//                public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
-//                @Override
-//                public void onTextChanged(CharSequence s, int start, int before, int count) {}
-//                @Override
-//                public void afterTextChanged(Editable s) {
-//                    if (StringUtils.isEmpty(s.toString())) return;
-//                    double numberstrChche =  Double.parseDouble(s.toString());
-//                    if (table_list_money == null){
-//                        table_list_money.add(position, CommonUtil.getTwoPointDouble(numberstrChche));
-//                    }else {
-//                        table_list_money.remove(position);
-//                        table_list_money.add(position,CommonUtil.getTwoPointDouble(numberstrChche));
-//                    }
-//                }
-//            });
+            viewHolder.details_money.addTextChangedListener(new TextWatcher() {
+                @Override
+                public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
+                @Override
+                public void onTextChanged(CharSequence s, int start, int before, int count) {}
+                @Override
+                public void afterTextChanged(Editable s) {
+                    if (StringUtils.isEmpty(s.toString())) return;
+                    double numberstrChche =  Double.parseDouble(s.toString());
+                    money_edit_position = position;
+                    /*if (table_list_money == null ){
+                        table_list_money.add(position, CommonUtil.getTwoPointDouble(numberstrChche));
+                    }else if (table_list_money.get(position) == null){
+                        table_list_money.add(position, CommonUtil.getTwoPointDouble(numberstrChche));
+                    }else {
+                        table_list_money.remove(position);
+                        table_list_money.add(position,CommonUtil.getTwoPointDouble(numberstrChche));
+                    }*/
+
+                    if(delayRun!=null){
+                        //每次editText有变化的时候,则移除上次发出的延迟线程
+                        dthandler.removeCallbacks(delayRun);
+                    }
+                    money_editString = s.toString();
+
+                    //延迟800ms,如果不再输入字符,则执行该线程的run方法
+                    dthandler.postDelayed(delayRun, 1000);
+                }
+            });
             return convertView;
         }
         class ViewHolder{
@@ -430,8 +446,27 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
             ImageView details_delete;
 
         }
-    }
 
+        private Runnable delayRun = new Runnable() {
+
+            @Override
+            public void run() {
+                if (table_list_money == null ) {
+                    table_list_money.add(CommonUtil.getTwoPointDouble(Double.valueOf(money_editString)));
+                }else {
+                    if (money_edit_position < table_list_money.size()){
+                        table_list_money.remove(money_edit_position);
+                        table_list_money.add(money_edit_position,CommonUtil.getTwoPointDouble(Double.valueOf(money_editString)));
+                    }else if (money_edit_position == table_list_money.size()){
+                        table_list_money.add(CommonUtil.getTwoPointDouble(Double.valueOf(money_editString)));
+                    }
+                }
+            }
+        };
+    }
+    private int money_edit_position;
+    private String money_editString = "";
+    private Handler dthandler = new Handler();
     /**
      *新增弹出PopupWindow表格适配器
      */

+ 2 - 1
WeiChat/src/main/res/layout/activity_expense_reimbursement.xml

@@ -49,7 +49,8 @@
                     android:textSize="15sp"
                     whatever:customRegexp="^[A-Za-z\u4e00-\u9fa5]{1,10}+$"
                     whatever:testErrorString="限制十个之内有效中英文字符"
-                    whatever:testType="regexp" />
+                    whatever:testType="regexp"
+                    android:maxLength="10"/>
 
                 <ImageView
                     style="@style/IMTbleLine_ArrowImg"