Browse Source

的改为上传 图片 形式【taskID=8975】

guilin 2 years ago
parent
commit
ae1a118735

+ 94 - 16
app/src/main/java/com/fxy/putIn/TallyMainActivity.java

@@ -35,6 +35,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
 import com.chad.library.adapter.base.BaseViewHolder;
 import com.elvishew.xlog.XLog;
 import com.fxy.R;
+import com.fxy.base.fragment.ShowImgFragment;
 import com.fxy.baselibrary.base.BaseActivity;
 import com.fxy.baselibrary.bean.BaseEventBusBean;
 import com.fxy.baselibrary.interfaces.OnRxScanerListener;
@@ -45,6 +46,7 @@ import com.fxy.baselibrary.views.MarqueeTextView;
 import com.fxy.bean.ActionBean;
 import com.fxy.bean.ScanBean;
 import com.fxy.common.CommonDialog;
+import com.fxy.common.PictureSelectorUpload;
 import com.fxy.constant.BaseConfig;
 import com.fxy.constant.EventCode;
 import com.fxy.constant.SPCache;
@@ -56,6 +58,7 @@ import com.fxy.net.Urls;
 import com.fxy.view.FloatingImageView;
 import com.fxy.view.PopupWindowManager;
 import com.google.zxing.Result;
+import com.luck.picture.lib.config.PictureConfig;
 import com.lzy.okgo.OkGo;
 import com.lzy.okgo.model.Response;
 
@@ -139,6 +142,16 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
     @BindView(R.id.iv_drag)
     FloatingImageView iv_drag;
 
+
+
+    @BindView(R.id.rv_show_img)
+    RecyclerView rvShowImg;
+
+
+    @BindView(R.id.ll_pictures_box)
+    LinearLayout llPicturesBox;
+
+
     private View notDataView;   //没有数据显示页
     private View errorView;     //错误显示页
     private View emptyView;     //空显示页
@@ -158,6 +171,13 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
 
     private  CommonDialog commonDialog;
 
+    //图片列表
+    private ArrayList photoList =new ArrayList<>();
+
+    private PictureSelectorUpload pictureSelectorUpload;
+
+    private ShowImgFragment showImgFragment;
+
     //是否需要显示客户
     private boolean needCustomer;
     private boolean needCtn;
@@ -209,6 +229,12 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
         {
         }else if (resultCode==0){
         }
+
+        if (resultCode == RESULT_OK) {
+            if (requestCode == PictureConfig.CHOOSE_REQUEST) {// 图片选择结果回调
+                pictureSelectorUpload.getSelectImg(data);
+            }
+        }
     }
 
 
@@ -250,6 +276,26 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
                 }
             }
         });
+
+        initUpload();
+
+
+    }
+
+
+    private void initUpload(){
+        pictureSelectorUpload = new PictureSelectorUpload(TallyMainActivity.this,rvShowImg,"tally",1);
+        pictureSelectorUpload.setOnChangeListener(new PictureSelectorUpload.UploadChangeListener() {
+            @Override
+            public void uploadResult(boolean State) {
+                if (State) {
+                    System.out.println("文件上传回调成功");
+                    doPutIn();
+                } else {
+                    System.out.println("文件上传失败");
+                }
+            }
+        });
     }
 
 
@@ -607,7 +653,7 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
         }
     }
 
-    private void doPutIn() {
+    public void doPutIn() {
         //校验数据
         if (!validate()){
             return;
@@ -621,7 +667,8 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
             param.put("tracking_number",tracking_number);
 
             if (needCustomer){
-                param.put("customer_code",customerCode);
+                //param.put("customer_code",customerCode);
+                param.put("label_img",photoList.get(0));
             }
             if (isChange>0){
                 param.put("is_change",isChange);
@@ -654,18 +701,36 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
                                 setPageViewData(result);
                                 if(bean.code == 1){
                                     showSuccessToast(bean.msg);
+                                    llPicturesBox.setVisibility(View.GONE);
                                     clearData(false);
                                 }else{
 
                                     if (result.has("tag") && result.getString("tag").equals("need_customer")){
 
-                                        commonDialog.setTitle("客户编号","请输入客户编号")
-                                                .setTypeCode("need_customer")
-                                                .setContent("")
-                                                .show();
-                                        llCustomerCode.setVisibility(View.VISIBLE);
-                                        needCustomer = true;
+//                                        commonDialog.setTitle("客户编号","请输入客户编号")
+//                                                .setTypeCode("need_customer")
+//                                                .setContent("")
+//                                                .show();
+//                                        llCustomerCode.setVisibility(View.VISIBLE);
+                                        new AlertDialog.Builder(mContext)
+                                                .setTitle(R.string.dl_hint)
+                                                .setMessage(bean.msg)
+                                                .setNegativeButton(R.string.str_submit, new DialogInterface.OnClickListener() {
+                                                    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
+                                                    @Override
+                                                    public void onClick(DialogInterface dialogInterface, int i) {
+                                                        needCustomer = true;
+                                                        llPicturesBox.setVisibility(View.VISIBLE);
+                                                        pictureSelectorUpload.authCamera();
 
+                                                    }
+                                                }).setPositiveButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
+                                            @Override
+                                            public void onClick(DialogInterface dialogInterface, int i) {
+                                                //取消不做操作
+
+                                            }
+                                        }).show();
 
 
                                     }else if (result.has("is_change") && result.getInt("is_change")==1){
@@ -728,12 +793,18 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
             return false;
         }
         if (needCustomer){
-            if (customerCode.isEmpty()){
-                commonDialog.setTitle("客户编号","请输入客户编号")
-                        .setTypeCode("need_customer")
-                        .setContent("")
-                        .show();
-                showWarningToast("请输入客户编号");
+//            if (customerCode.isEmpty()){
+//                commonDialog.setTitle("客户编号","请输入客户编号")
+//                        .setTypeCode("need_customer")
+//                        .setContent("")
+//                        .show();
+//                showWarningToast("请输入客户编号");
+//                return false;
+//            }
+
+            photoList = pictureSelectorUpload.getPhotoList();
+            if (photoList.size()==0){
+                showWarningToast("请拍照");
                 return false;
             }
         }
@@ -856,9 +927,10 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
         }
         setEditTextNormal(etContainerCode,true);
         setEditTextNormal(etOrderNo,true);
+        pictureSelectorUpload.emptyRemake();//清空图片
     }
 
-    @OnClick({R.id.btn_confirm,R.id.btn_change_confirm,R.id.tv_edit_customer,R.id.tv_edit_cnt})
+    @OnClick({R.id.btn_confirm,R.id.btn_change_confirm,R.id.tv_edit_customer,R.id.tv_edit_cnt,R.id.add_tally})
     public void onViewClicked(View view) {
         Bundle bundle = new Bundle();
         switch (view.getId()) {
@@ -902,6 +974,12 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
                         .setContent(mtCnt.getText().toString())
                         .show();
                 break;
+            case R.id.add_tally:
+                doPutIn();
+                break;
+//            case R.id.tv_clear_pictures:
+//                pictureSelectorUpload.emptyRemake();
+//                break;
             default:
                 break;
         }
@@ -1006,7 +1084,7 @@ public class TallyMainActivity extends  BaseActivity implements StoJNI.ScanCallB
     @Override
     protected void onDestroy() {
         unbinder.unbind();
-
+        pictureSelectorUpload.removeHandler();
 
         super.onDestroy();
     }

+ 44 - 0
app/src/main/res/layout/activity_fxy_tally.xml

@@ -64,6 +64,50 @@
             </LinearLayout>
 
 
+<!--            -->
+
+            <LinearLayout
+                android:id="@+id/ll_pictures_box"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:visibility="gone"
+                android:orientation="vertical">
+                <include layout="@layout/fragment_show_img"/>
+                <View
+                    android:layout_width="match_parent"
+                    android:layout_height="1dp"
+                    android:background="@color/md_grey_100" />
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    android:layout_marginTop="@dimen/dp_10"
+                    android:layout_marginRight="@dimen/dp_10"
+                    android:layout_marginBottom="@dimen/dp_4"
+                    android:background="@drawable/bg_white_et"
+                    android:gravity="center_vertical"
+                    android:orientation="horizontal"
+                    android:padding="10dp">
+                    <TextView
+                        style="@style/fontSize"
+                        android:id="@+id/add_tally"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:layout_marginLeft="@dimen/dp_10"
+                        android:layout_marginRight="@dimen/dp_10"
+                        android:background="@drawable/bg_orange_item"
+                        android:gravity="center"
+                        android:text="确定提交"
+                        android:padding="10dp"
+                        android:textColor="@color/white"
+                        android:visibility="visible" />
+                </LinearLayout>
+
+            </LinearLayout>
+
+
+
+
             <View
                 android:layout_width="match_parent"
                 android:layout_height="1dp"

+ 42 - 0
app/src/main/res/layout/activity_fxy_tray.xml

@@ -64,6 +64,48 @@
                 android:background="@color/md_grey_100" />
 
 
+            <include layout="@layout/fragment_show_img"/>
+
+            <LinearLayout
+                android:id="@+id/ll_volume_content"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical"
+                >
+            </LinearLayout>
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="1dp"
+                android:background="@color/md_grey_100" />
+            <LinearLayout
+                android:id="@+id/ll_add_volume"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+                android:background="@drawable/bg_white_et"
+                android:gravity="center_vertical"
+                android:orientation="vertical"
+                android:paddingTop="5dp"
+                android:paddingBottom="5dp">
+                <TextView
+                    style="@style/fontSize"
+                    android:id="@+id/tv_clear_pictures"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    android:background="@drawable/bg_blue_item"
+                    android:gravity="center"
+                    android:layout_weight="1"
+                    android:text="清空重拍"
+                    android:padding="10dp"
+                    android:textColor="@color/white"
+                    android:visibility="visible"
+                    android:layout_height="wrap_content">
+                </TextView>
+
+            </LinearLayout>
+
+
             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"

+ 2 - 2
config.gradle

@@ -8,8 +8,8 @@ ext {
             minSdkVersion    : 17,
             targetSdkVersion : 23,
             versionCode      : 1,
-            versionName      : "1.1.0",
-            versionApi       : "1.1",
+            versionName      : "2.0.0",
+            versionApi       : "2.0",
     ]
 
     dependencies = [