|
@@ -1,8 +1,10 @@
|
|
|
package com.fxy.detection;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
+import android.app.AlertDialog;
|
|
|
import android.content.BroadcastReceiver;
|
|
|
import android.content.Context;
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.content.IntentFilter;
|
|
|
import android.os.Bundle;
|
|
@@ -17,6 +19,7 @@ import android.view.inputmethod.EditorInfo;
|
|
|
import android.widget.EditText;
|
|
|
import android.widget.ImageButton;
|
|
|
import android.widget.LinearLayout;
|
|
|
+import android.widget.ProgressBar;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
@@ -31,8 +34,11 @@ import com.fxy.bean.ActionBean;
|
|
|
import com.fxy.bean.ScanBean;
|
|
|
import com.fxy.common.AsyncUpload;
|
|
|
import com.fxy.common.PictureSelectorUpload;
|
|
|
+import com.fxy.common.UploadProgressEvent;
|
|
|
import com.fxy.constant.BaseConfig;
|
|
|
import com.fxy.constant.EventCode;
|
|
|
+import com.fxy.detection.bean.NeedPhotoBean;
|
|
|
+import com.fxy.detection.bean.TakePictureBean;
|
|
|
import com.fxy.net.MyDialogCallback;
|
|
|
import com.fxy.net.Urls;
|
|
|
import com.fxy.view.FloatingImageView;
|
|
@@ -43,6 +49,8 @@ import com.luck.picture.lib.entity.LocalMedia;
|
|
|
import com.lzy.okgo.OkGo;
|
|
|
import com.lzy.okgo.model.Response;
|
|
|
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
+import org.greenrobot.eventbus.ThreadMode;
|
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
@@ -74,7 +82,12 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
@BindView(R.id.et_tracking_number)
|
|
|
EditText etTrackingNumber;
|
|
|
|
|
|
+ @BindView(R.id.et_unit_code)
|
|
|
+ EditText etUnitCode;
|
|
|
|
|
|
+ //拍照区域
|
|
|
+ @BindView(R.id.ll_camera_picture_module)
|
|
|
+ LinearLayout llCameraPictureModule;
|
|
|
|
|
|
|
|
|
@BindView(R.id.ll_label_picture)
|
|
@@ -97,12 +110,30 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
TextView tvAwaitNum;
|
|
|
|
|
|
|
|
|
+ @BindView(R.id.pb_progressbar)
|
|
|
+ ProgressBar pbProgressbar;
|
|
|
+
|
|
|
+ @BindView(R.id.percentage_text_view)
|
|
|
+ TextView tvPercentageTextView;
|
|
|
+
|
|
|
+
|
|
|
+ @BindView(R.id.btn_start_upload)
|
|
|
+ TextView btnStartUpload;
|
|
|
+
|
|
|
+ @BindView(R.id.ll_upload_progressbar)
|
|
|
+ LinearLayout llUploadProgressbar;
|
|
|
+
|
|
|
+
|
|
|
private HashMap<String, Object> postData = new HashMap<>();
|
|
|
|
|
|
+ private HashMap<String,AsyncUpload> mapPictureSelector = new HashMap<>();
|
|
|
+
|
|
|
+ private List<TakePictureBean> takePictureBeanList = new ArrayList<>();
|
|
|
+
|
|
|
|
|
|
- private AsyncUpload labelPictureSelectorUpload;
|
|
|
- private AsyncUpload weighPictureSelectorUpload;
|
|
|
private String currentPictureType= "";
|
|
|
+
|
|
|
+ private boolean currentUploadStatus = false;
|
|
|
//
|
|
|
//扫码扫码动作
|
|
|
private ScanBean scanBean;
|
|
@@ -111,6 +142,8 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
private boolean showWeightImg = false;
|
|
|
|
|
|
private boolean isRequiredShow = false;
|
|
|
+
|
|
|
+ private ArrayList<String> baseImgList = new ArrayList<>();
|
|
|
protected String action;
|
|
|
|
|
|
|
|
@@ -153,14 +186,12 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
// 图片选择结果回调
|
|
|
if (requestCode == PictureConfig.CHOOSE_REQUEST) {
|
|
|
- if (currentPictureType.equals("weight_img")){
|
|
|
- weighPictureSelectorUpload.setNotifyParam(getNotifyParam());
|
|
|
- weighPictureSelectorUpload.getSelectImg(data);
|
|
|
- }else {
|
|
|
- labelPictureSelectorUpload.setNotifyParam(getNotifyParam());
|
|
|
- labelPictureSelectorUpload.getSelectImg(data);
|
|
|
+ if (mapPictureSelector.containsKey(currentPictureType)){
|
|
|
+ mapPictureSelector.get(currentPictureType).setNotifyParam(getNotifyParam());
|
|
|
+ mapPictureSelector.get(currentPictureType).getSelectImg(data);
|
|
|
}
|
|
|
totalAwaitNum();
|
|
|
+ checkSubmit();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -194,10 +225,11 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
iniData();
|
|
|
RecyclerView rvLabelShowImg = (RecyclerView)llLabelPicture.findViewById(R.id.rv_show_img);
|
|
|
RecyclerView rvWeighShowImg = (RecyclerView)llWeighPicture.findViewById(R.id.rv_show_img);
|
|
|
- labelPictureSelectorUpload = setItemPicture("label_img",rvLabelShowImg);
|
|
|
- weighPictureSelectorUpload = setItemPicture("weight_img",rvWeighShowImg);
|
|
|
+ mapPictureSelector.put("label_img",setItemPicture("label_img",rvLabelShowImg,9));
|
|
|
+ mapPictureSelector.put("weight_img",setItemPicture("weight_img",rvWeighShowImg,9));
|
|
|
|
|
|
iniPhoto();
|
|
|
+ totalAwaitNum();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -207,15 +239,15 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
* @param uploadType String
|
|
|
* @param showImg RecyclerView
|
|
|
*/
|
|
|
- private AsyncUpload setItemPicture(String uploadType,RecyclerView showImg){
|
|
|
+ private AsyncUpload setItemPicture(String uploadType,RecyclerView showImg,int num){
|
|
|
|
|
|
String notifyUrl = Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN;
|
|
|
- AsyncUpload pictureUpload = new AsyncUpload(DetectionPutInMainActivity.this,showImg,"detection",uploadType,notifyUrl);
|
|
|
+ AsyncUpload pictureUpload = new AsyncUpload(DetectionPutInMainActivity.this,showImg,"detection",uploadType,notifyUrl,false);
|
|
|
pictureUpload.setUploadType(uploadType);
|
|
|
pictureUpload.setCompress(true,100,100);
|
|
|
pictureUpload.setOnlyCamera(true);
|
|
|
- pictureUpload.setMaxSelectNum(9);
|
|
|
- pictureUpload.asyncUpload();//
|
|
|
+ pictureUpload.setMaxSelectNum(num);
|
|
|
+
|
|
|
//showImg.onTouchEvent()
|
|
|
|
|
|
pictureUpload.setOnChangeListener(new AsyncUpload.UploadChangeListener() {
|
|
@@ -236,6 +268,23 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void setCameraPicture(){
|
|
|
+ llCameraPictureModule.removeAllViews();;
|
|
|
+ for (int i=0;i<takePictureBeanList.size();i++){
|
|
|
+ addPictureSelectorUpload(llCameraPictureModule,takePictureBeanList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void addPictureSelectorUpload(LinearLayout linearLayout, TakePictureBean takePictureBean){
|
|
|
+ View itemPictureSelector = View.inflate(mContext, R.layout.item_picture_selector, null);
|
|
|
+ TextView tvPicturesTitle = itemPictureSelector.findViewById(R.id.tv_pictures_title);
|
|
|
+ tvPicturesTitle.setText(takePictureBean.getField());
|
|
|
+ RecyclerView rvLabelShowImg = (RecyclerView)itemPictureSelector.findViewById(R.id.recyclerview);
|
|
|
+ linearLayout.addView(itemPictureSelector);
|
|
|
+ AsyncUpload tmpPictureSelector = setItemPicture(takePictureBean.getField(),rvLabelShowImg,takePictureBean.getNumber());
|
|
|
+ mapPictureSelector.put(takePictureBean.getField(),tmpPictureSelector);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
|
//XLog.e("event:"+event.getKeyCode());
|
|
@@ -249,11 +298,14 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
public HashMap<String, Object> getNotifyParam(){
|
|
|
postData.put("box_number",etOrderNumber.getText().toString().trim());
|
|
|
postData.put("tracking_number",etTrackingNumber.getText().toString().trim());
|
|
|
- labelPictureSelectorUpload.setNotifyParam(postData);
|
|
|
- weighPictureSelectorUpload.setNotifyParam(postData);
|
|
|
+ postData.put("unit_code",etUnitCode.getText().toString().trim());
|
|
|
+ mapPictureSelector.get(currentPictureType).setNotifyParam(postData);
|
|
|
+ mapPictureSelector.get(currentPictureType).setNotifyParam(postData);
|
|
|
return postData;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//监听按键
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
XLog.e("监听按键:"+keyCode);XLog.e(event);
|
|
@@ -363,6 +415,7 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
List<EditText> list = new ArrayList<>();
|
|
|
list.add(etTrackingNumber);
|
|
|
list.add(etOrderNumber);
|
|
|
+ list.add(etUnitCode);
|
|
|
unifyEdit(list);
|
|
|
llResult.setVisibility(View.GONE);
|
|
|
llWeighPicture.setVisibility(View.GONE);
|
|
@@ -370,17 +423,24 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
|
|
|
|
|
|
private void iniData(){
|
|
|
-
|
|
|
+ baseImgList.add("label_img");
|
|
|
+ baseImgList.add("weight_img");
|
|
|
}
|
|
|
|
|
|
//getAwaitNum
|
|
|
private void totalAwaitNum(){
|
|
|
- int awaitNum = labelPictureSelectorUpload.getAwaitNum();
|
|
|
+ int awaitNum = mapPictureSelector.get("label_img").getAwaitNum();
|
|
|
tvAwaitNum.setText(String.valueOf(awaitNum));
|
|
|
+ if (awaitNum == 0){
|
|
|
+ operateStopUpload();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//统一按钮回调
|
|
|
+ @SuppressLint("NonConstantResourceId")
|
|
|
public void callbackEditor(View v){
|
|
|
+ XLog.e("获取:"+v.getId());
|
|
|
+ XLog.e("id:"+R.id.et_tracking_number);
|
|
|
switch (v.getId()) {
|
|
|
case R.id.et_tracking_number:
|
|
|
getInboundTrack();
|
|
@@ -394,9 +454,28 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
etOrderNumber.requestFocus();
|
|
|
return;
|
|
|
}
|
|
|
+ etUnitCode.requestFocus();
|
|
|
+ etUnitCode.setSelection(etUnitCode.getText().toString().length());
|
|
|
+ break;
|
|
|
+ case R.id.et_unit_code:
|
|
|
+ for (int i=0;i<baseImgList.size();i++){
|
|
|
+ String tmpKey = baseImgList.get(0);
|
|
|
+ if (mapPictureSelector.containsKey(tmpKey) && mapPictureSelector.get(tmpKey).getOssPhotoList().size()==0){
|
|
|
+ mapPictureSelector.get(tmpKey).authCamera();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- labelPictureSelectorUpload.authCamera();
|
|
|
+ for (int i=0;i<takePictureBeanList.size();i++){
|
|
|
+ String tmpKey = takePictureBeanList.get(0).getField();
|
|
|
+ if (mapPictureSelector.containsKey(tmpKey) && mapPictureSelector.get(tmpKey).getOssPhotoList().size()==0){
|
|
|
+ mapPictureSelector.get(tmpKey).authCamera();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pictureInbound();
|
|
|
break;
|
|
|
+
|
|
|
default:
|
|
|
}
|
|
|
|
|
@@ -507,22 +586,31 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
{
|
|
|
((EditText) view).setText(scanResult);
|
|
|
showSuccessToast("扫描成功");
|
|
|
- switch (view.getId()) {
|
|
|
- case R.id.et_tracking_number:
|
|
|
- getInboundTrack();
|
|
|
- break;
|
|
|
- case R.id.et_order_number:
|
|
|
- showSuccessToast("扫描成功");
|
|
|
- break;
|
|
|
- default:
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ callbackEditor(view);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void getInboundTrack(){
|
|
|
+ int awaitNum = mapPictureSelector.get("label_img").getAwaitNum();
|
|
|
+ if (currentUploadStatus && awaitNum>0){
|
|
|
+ new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
|
|
|
+ .setMessage("当前正在上传图片。是否需要停止上传继续操作")
|
|
|
+ .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
+ if (!currentUploadStatus){
|
|
|
+ operateStartUpload();
|
|
|
+ }
|
|
|
+ dialogInterface.dismiss();
|
|
|
+ }
|
|
|
+ }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
|
|
+ }
|
|
|
+ }).show();
|
|
|
+ }
|
|
|
|
|
|
if (etTrackingNumber.getText().toString().isEmpty()){
|
|
|
showErrorToast(etTrackingNumber.getHint().toString());
|
|
@@ -558,18 +646,20 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
String show_weight_img = result.has("show_weight_img") ? result.getString("show_weight_img"):"";
|
|
|
|
|
|
|
|
|
+ if (result.has("need_photo")){
|
|
|
+ takePictureBeanList = JsonUtil.jsonString2Beans(result.getString("need_photo"),TakePictureBean.class);
|
|
|
+ }
|
|
|
|
|
|
showWeightImg = show_weight_img.contains("1");
|
|
|
llWeighPicture.setVisibility(showWeightImg ? View.VISIBLE:View.GONE);
|
|
|
llResult.setVisibility(showText.isEmpty() ? View.GONE:View.VISIBLE);
|
|
|
tvResult.setText(showText);
|
|
|
|
|
|
-
|
|
|
+ setCameraPicture();
|
|
|
|
|
|
if(bean.code == 1){
|
|
|
showSuccessToast(bean.msg,voiceName);
|
|
|
- etOrderNumber.requestFocus();
|
|
|
- etOrderNumber.setSelection(etOrderNumber.getText().toString().length());
|
|
|
+
|
|
|
}else{
|
|
|
showWarningToast(bean.msg,voiceName);
|
|
|
}
|
|
@@ -579,6 +669,29 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ etOrderNumber.requestFocus();
|
|
|
+ etOrderNumber.setSelection(etOrderNumber.getText().toString().length());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkSubmit(){
|
|
|
+ if (mapPictureSelector.get("label_img").getOssPhotoList().size()==0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (showWeightImg && mapPictureSelector.get("weight_img").getOssPhotoList().size()==0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (takePictureBeanList.size()>0){
|
|
|
+ for (int i=0;i<takePictureBeanList.size();i++){
|
|
|
+ if (mapPictureSelector.get(takePictureBeanList.get(i).getField()).getOssPhotoList().size()==0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pictureInbound();
|
|
|
+ initUnitCode();
|
|
|
}
|
|
|
|
|
|
private void pictureInbound(){
|
|
@@ -587,21 +700,43 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+// if (!checkRepeat(Urls.FXY_DETECTION_PUTIN+(postParam.toString()))){
|
|
|
+// Toast.makeText(this, getString(R.string.error_data_processed), Toast.LENGTH_LONG).show();
|
|
|
+// return;
|
|
|
+// }
|
|
|
|
|
|
-
|
|
|
+ OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN).upJson(postParam)
|
|
|
+ .execute(new MyDialogCallback(this, true, false) {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(Response<String> response) {
|
|
|
+ super.onSuccess(response);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
//假成功
|
|
|
- initFinish();
|
|
|
+
|
|
|
showSuccessToast("success");
|
|
|
+ }
|
|
|
|
|
|
-// if (!checkRepeat(Urls.FXY_DETECTION_PUTIN+(postParam.toString()))){
|
|
|
-// Toast.makeText(this, getString(R.string.error_data_processed), Toast.LENGTH_LONG).show();
|
|
|
-// return;
|
|
|
-// }
|
|
|
+ //完成入库
|
|
|
+ private void finishInbound(){
|
|
|
+ isRequiredShow = true;
|
|
|
+ if (etTrackingNumber.getText().toString().isEmpty()){
|
|
|
+ showWarningToast(etTrackingNumber.getHint().toString());
|
|
|
+ return ;
|
|
|
+ }
|
|
|
|
|
|
+ if (etOrderNumber.getText().toString().isEmpty()){
|
|
|
+ showWarningToast(etOrderNumber.getHint().toString());
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ HashMap<String,Object> postData = new HashMap<>();
|
|
|
+ postData.put("box_number",etOrderNumber.getText().toString().trim());
|
|
|
+ postData.put("tracking_number",etTrackingNumber.getText().toString().trim());
|
|
|
|
|
|
+ String body = (new Gson()).toJson(postData);
|
|
|
|
|
|
- OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN).upJson(postParam)
|
|
|
+ OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN).upJson(body)
|
|
|
.execute(new MyDialogCallback(this, true, false) {
|
|
|
@Override
|
|
|
public void onSuccess(Response<String> response) {
|
|
@@ -619,17 +754,43 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ //假成功
|
|
|
+
|
|
|
+ showSuccessToast("success");
|
|
|
+ initFinish();
|
|
|
}
|
|
|
|
|
|
- private void initFinish(){
|
|
|
+ public void initUnitCode(){
|
|
|
isRequiredShow = false;
|
|
|
- labelPictureSelectorUpload.emptyRemake();//清空图片
|
|
|
- weighPictureSelectorUpload.emptyRemake();
|
|
|
- etOrderNumber.setText("");
|
|
|
- etTrackingNumber.setText("");
|
|
|
- etTrackingNumber.requestFocus();
|
|
|
+ for (String key : mapPictureSelector.keySet()) {
|
|
|
+ if (!baseImgList.contains(key)){
|
|
|
+ mapPictureSelector.get(key).emptyRemake();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ etUnitCode.setText("");
|
|
|
+ etUnitCode.requestFocus();
|
|
|
+ llLabelPicture.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initFinish(){
|
|
|
+ initUnitCode();
|
|
|
+ for (int i=0;i<baseImgList.size();i++){
|
|
|
+ if (mapPictureSelector.containsKey(baseImgList.get(i))){
|
|
|
+ mapPictureSelector.get(baseImgList.get(i)).emptyRemake();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
llResult.setVisibility(View.GONE);
|
|
|
llWeighPicture.setVisibility(View.GONE);
|
|
|
+ llLabelPicture.setVisibility(View.VISIBLE);
|
|
|
+
|
|
|
+ takePictureBeanList.clear();
|
|
|
+ setCameraPicture();
|
|
|
+ etTrackingNumber.setText("");
|
|
|
+ etOrderNumber.setText("");
|
|
|
+ etTrackingNumber.requestFocus();
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -648,33 +809,59 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ if (etUnitCode.getText().toString().isEmpty()){
|
|
|
+ showWarningToast(etUnitCode.getHint().toString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
postParam = new JSONObject();
|
|
|
Gson gson = new Gson();
|
|
|
|
|
|
- List<LocalMedia> labelPhotoList = labelPictureSelectorUpload.getSelectList();
|
|
|
-
|
|
|
-
|
|
|
- //检查是否拍照 工单处理时拍照拍照非必传
|
|
|
- if (labelPhotoList.size()==0){
|
|
|
+ List<String> stringList = mapPictureSelector.get("label_img").getOssPhotoList();
|
|
|
+ if (stringList.size()==0){
|
|
|
showWarningToast("面单照片不能为空");
|
|
|
return false;
|
|
|
}
|
|
|
- postParam.put("label_img_tag",labelPictureSelectorUpload.getUniqueTag());
|
|
|
+ postParam.put("label_img_tag",mapPictureSelector.get("label_img").getUniqueTag());
|
|
|
+ postParam.put("label_img",gson.toJson(stringList));
|
|
|
|
|
|
|
|
|
- if (showWeightImg){
|
|
|
- List<LocalMedia> weighPhotoList = weighPictureSelectorUpload.getSelectList();
|
|
|
+ AsyncUpload weightUpload = mapPictureSelector.get("weight_img");
|
|
|
+ if (showWeightImg && weightUpload!=null){
|
|
|
+ List<String> weighPhotoList = weightUpload.getOssPhotoList();
|
|
|
if (weighPhotoList.size()==0){
|
|
|
showWarningToast("内件照片不能为空");
|
|
|
return false;
|
|
|
}
|
|
|
- postParam.put("weight_img_tag",weighPictureSelectorUpload.getUniqueTag());
|
|
|
- }
|
|
|
+ postParam.put("weight_img_tag",weightUpload.getUniqueTag());
|
|
|
+ postParam.put("weight_img",gson.toJson(weighPhotoList));
|
|
|
+ }
|
|
|
+
|
|
|
+ //拍照
|
|
|
+ if (takePictureBeanList.size()>0){
|
|
|
+
|
|
|
+ JSONObject otherObject = new JSONObject();
|
|
|
+ for (int i=0; i < takePictureBeanList.size();i++){
|
|
|
+ String name = takePictureBeanList.get(i).getField();
|
|
|
+ if (!mapPictureSelector.containsKey(name) ){
|
|
|
+ showErrorToast("页面渲染异常,请更新操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> tmpList = mapPictureSelector.get(name).getOssPhotoList();
|
|
|
+ if (tmpList.size() == 0){
|
|
|
+ showWarningToast("请上传".concat(takePictureBeanList.get(i).getTitle()).concat("拍照"));
|
|
|
+ }
|
|
|
+ otherObject.put(name,gson.toJson(tmpList));
|
|
|
+ }
|
|
|
+ postParam.put("other_img",otherObject);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
postParam.put("box_number",etOrderNumber.getText().toString().trim());
|
|
|
postParam.put("tracking_number",etTrackingNumber.getText().toString().trim());
|
|
|
+ postParam.put("unit_code",etUnitCode.getText().toString().trim());
|
|
|
+
|
|
|
|
|
|
} catch (JSONException e) {
|
|
|
showWarningToast("系统异常"+e.getMessage());
|
|
@@ -693,23 +880,101 @@ public class DetectionPutInMainActivity extends BaseActivity implements StoJNI.
|
|
|
}
|
|
|
|
|
|
//sIsGoodinfoMatch,sIsBattery,sIsMagnetic,sIsWood,sIsExtra,sIsOther
|
|
|
- @OnClick({R.id.btn_confirm})
|
|
|
+ @OnClick({R.id.btn_confirm,R.id.btn_start_upload})
|
|
|
public void onViewClicked(View view) {
|
|
|
Bundle bundle = new Bundle();
|
|
|
switch (view.getId()) {
|
|
|
case R.id.btn_confirm:
|
|
|
- pictureInbound();
|
|
|
+ finishInbound();
|
|
|
break;
|
|
|
+ case R.id.btn_start_upload:
|
|
|
+
|
|
|
+ if (currentUploadStatus) {
|
|
|
+ operateStopUpload();
|
|
|
+ } else {
|
|
|
+ operateStartUpload();
|
|
|
+ }
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void operateStopUpload(){
|
|
|
+ if (currentUploadStatus){
|
|
|
+ mapPictureSelector.get("label_img").setStopUpload();
|
|
|
+ currentUploadStatus = false;
|
|
|
+ btnStartUpload.setText("开始上传");
|
|
|
+ llUploadProgressbar.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void operateStartUpload(){
|
|
|
+ if (!currentUploadStatus){
|
|
|
+ mapPictureSelector.get("label_img").setStartUpload();
|
|
|
+ currentUploadStatus = true;
|
|
|
+ btnStartUpload.setText("停止上传");
|
|
|
+ llUploadProgressbar.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void showBack() {
|
|
|
+ super.showBack();
|
|
|
+ tb_iv_left.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+
|
|
|
+ int num = mapPictureSelector.get("label_img").getAwaitNum();
|
|
|
+
|
|
|
+ if (num>0){
|
|
|
+ new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
|
|
|
+ .setMessage("返回会取消上传还有"+num+"条数据未上传,确定要返回吗")
|
|
|
+ .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
+ if (!currentUploadStatus){
|
|
|
+ operateStartUpload();
|
|
|
+ }
|
|
|
+ dialogInterface.dismiss();
|
|
|
+ }
|
|
|
+ }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
+ if (isShowBackDialog) {
|
|
|
+ onBackPressedSupport();
|
|
|
+ } else {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).show();
|
|
|
+
|
|
|
+ }else{
|
|
|
+ if (isShowBackDialog) {
|
|
|
+ onBackPressedSupport();
|
|
|
+ } else {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+ public void onUploadProgress(UploadProgressEvent event) {
|
|
|
+ // 更新进度条或其他 UI 元素
|
|
|
+ int num = event.getProgress();
|
|
|
+ pbProgressbar.setProgress(num);
|
|
|
+ tvPercentageTextView.setText(String.valueOf(num).concat("%"));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
unbinder.unbind();
|
|
|
- labelPictureSelectorUpload.removeHandler();
|
|
|
- weighPictureSelectorUpload.removeHandler();
|
|
|
+
|
|
|
+ for (AsyncUpload asyncUpload : mapPictureSelector.values()) {
|
|
|
+ asyncUpload.removeHandler();
|
|
|
+ }
|
|
|
+
|
|
|
super.onDestroy();
|
|
|
}
|
|
|
@Override
|