|
@@ -32,11 +32,13 @@ import com.fxy.baselibrary.util.JsonUtil;
|
|
|
import com.fxy.baselibrary.util.StringUtils;
|
|
|
import com.fxy.bean.ActionBean;
|
|
|
import com.fxy.bean.ScanBean;
|
|
|
+import com.fxy.common.AsyncPictureSelector;
|
|
|
import com.fxy.common.PictureSelectorUpload;
|
|
|
import com.fxy.constant.BaseConfig;
|
|
|
import com.fxy.constant.EventCode;
|
|
|
import com.fxy.net.MyDialogCallback;
|
|
|
import com.fxy.net.Urls;
|
|
|
+import com.fxy.utils.UploadUtils;
|
|
|
import com.fxy.view.FloatingImageView;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.zxing.Result;
|
|
@@ -48,6 +50,7 @@ import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
@@ -68,10 +71,17 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
@BindView(R.id.ll_take_picture)
|
|
|
LinearLayout llTakePicture;
|
|
|
|
|
|
+ @BindView(R.id.ll_scan_confirm)
|
|
|
+ LinearLayout llScanConfirm;
|
|
|
+ @BindView(R.id.ll_confirm)
|
|
|
+ LinearLayout llConfirm;
|
|
|
|
|
|
- private ArrayList photoList =new ArrayList<>();
|
|
|
+ @BindView(R.id.tv_await_num)
|
|
|
+ TextView tvAwaitNum;
|
|
|
|
|
|
- private PictureSelectorUpload pictureSelectorUpload;
|
|
|
+ private List<String> photoList =new ArrayList<>();
|
|
|
+
|
|
|
+ private AsyncPictureSelector pictureSelectorUpload;
|
|
|
//
|
|
|
//扫码扫码动作
|
|
|
private ScanBean scanBean;
|
|
@@ -128,9 +138,19 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
if (requestCode == PictureConfig.CHOOSE_REQUEST) {// 图片选择结果回调
|
|
|
pictureSelectorUpload.getSelectImg(data);
|
|
|
}
|
|
|
+
|
|
|
+ totalAwaitNum();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ //getAwaitNum
|
|
|
+ private void totalAwaitNum(){
|
|
|
+ int awaitNum = UploadUtils.getAwaitNum(mRealm,getClass().getSimpleName());
|
|
|
+ tvAwaitNum.setText(String.valueOf(awaitNum));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* EventBus接收信息的方法,开启后才会调用(非粘性事件)
|
|
|
*
|
|
@@ -138,10 +158,9 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
*/
|
|
|
@Override
|
|
|
protected void EventBean(BaseEventBusBean event) {
|
|
|
-// XLog.e("----------接收返回--------------");
|
|
|
-// XLog.e("接收返回:"+event.getEventCode());
|
|
|
- if (event != null && event.getEventCode() == EventCode.displacement_refresh){
|
|
|
-
|
|
|
+ assert event != null;
|
|
|
+ if (event != null && event.getEventCode() == EventCode.file_upload_lister) {
|
|
|
+ totalAwaitNum();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -160,7 +179,7 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
iniData();
|
|
|
|
|
|
RecyclerView rvShowImg = (RecyclerView)llTakePicture.findViewById(R.id.rv_show_img);
|
|
|
- pictureSelectorUpload = setItemPicture("detection",rvShowImg,9,PictureConfig.TYPE_IMAGE);
|
|
|
+ pictureSelectorUpload = setItemPicture("detection",rvShowImg,99);
|
|
|
|
|
|
|
|
|
//监听浮动按钮
|
|
@@ -177,37 +196,24 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 设置多个上传文件
|
|
|
- * @param actionType String
|
|
|
+ * @param uploadType String
|
|
|
* @param showImg RecyclerView
|
|
|
*/
|
|
|
- private PictureSelectorUpload setItemPicture(String actionType,RecyclerView showImg,int maxNum,int pictureType){
|
|
|
- PictureSelectorUpload pictureUpload = new PictureSelectorUpload(ScanPhotosMainActivity.this,showImg,"work",maxNum,pictureType);
|
|
|
- pictureUpload.setActionType(actionType);
|
|
|
- pictureUpload.setCompress(true,100,500);
|
|
|
- pictureUpload.setOnlyCamera(true);
|
|
|
- //showImg.onTouchEvent()
|
|
|
-
|
|
|
- pictureUpload.setOnChangeListener(new PictureSelectorUpload.UploadChangeListener() {
|
|
|
- @Override
|
|
|
- public void uploadResult(boolean State,String actionType) {
|
|
|
- if (State) {
|
|
|
- pictureInbound();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void uploadActionType(String actionType) {
|
|
|
+ private AsyncPictureSelector setItemPicture(String uploadType,RecyclerView showImg,int num){
|
|
|
|
|
|
- System.out.println("actionType:"+actionType);
|
|
|
+ String notifyUrl = Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN;
|
|
|
+ AsyncPictureSelector pictureUpload = new AsyncPictureSelector(ScanPhotosMainActivity.this,showImg,"detection",uploadType,notifyUrl,false);
|
|
|
+ pictureUpload.setUploadType(uploadType);
|
|
|
+ pictureUpload.setCompress(true,100,100);
|
|
|
+ pictureUpload.setOnlyCamera(true);
|
|
|
+ pictureUpload.setMaxSelectNum(num);
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
return pictureUpload;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
|
//XLog.e("event:"+event.getKeyCode());
|
|
@@ -356,22 +362,31 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
showSuccessToast("扫描成功");
|
|
|
urlCode = scanResult;
|
|
|
pictureSelectorUpload.authCamera();
|
|
|
+ setActionTake();
|
|
|
}
|
|
|
|
|
|
+ private void setActionScan(){
|
|
|
+ llTakePicture.setVisibility(View.GONE);
|
|
|
+ llConfirm.setVisibility(View.GONE);
|
|
|
+ llScanConfirm.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setActionTake (){
|
|
|
+ llTakePicture.setVisibility(View.VISIBLE);
|
|
|
+ llConfirm.setVisibility(View.VISIBLE);
|
|
|
+ llScanConfirm.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
|
|
|
private void pictureInbound(){
|
|
|
if (!validate()){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (!checkRepeat(Urls.FXY_DETECTION_CODE_PHOTO+(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_CODE_PHOTO).upJson(postParam)
|
|
|
.execute(new MyDialogCallback(this, true, true) {
|
|
|
@Override
|
|
@@ -384,7 +399,7 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
pictureSelectorUpload.emptyRemake();//清空图片
|
|
|
photoList.clear();
|
|
|
urlCode = "";
|
|
|
-
|
|
|
+ setActionScan();
|
|
|
}else{
|
|
|
showWarningToast(bean.msg);
|
|
|
}
|
|
@@ -401,7 +416,7 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
* 校验必录
|
|
|
*/
|
|
|
private boolean validate(){
|
|
|
- photoList = pictureSelectorUpload.getPhotoList();
|
|
|
+ photoList = pictureSelectorUpload.getOssPhotoList();
|
|
|
|
|
|
if (urlCode.isEmpty()){
|
|
|
showWarningToast("请选扫码");
|
|
@@ -428,13 +443,13 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
}
|
|
|
|
|
|
//sIsGoodinfoMatch,sIsBattery,sIsMagnetic,sIsWood,sIsExtra,sIsOther
|
|
|
- @OnClick({R.id.btn_confirm})
|
|
|
+ @OnClick({R.id.btn_scan_confirm,R.id.btn_confirm})
|
|
|
public void onViewClicked(View view) {
|
|
|
Bundle bundle = new Bundle();
|
|
|
switch (view.getId()) {
|
|
|
|
|
|
- case R.id.btn_confirm:
|
|
|
- if (urlCode.isEmpty() || (pictureSelectorUpload!=null && pictureSelectorUpload.getPhotoList().size()==0) ){
|
|
|
+ case R.id.btn_scan_confirm:
|
|
|
+ if (urlCode.isEmpty() || (pictureSelectorUpload!=null && pictureSelectorUpload.getOssPhotoList().size()==0) ){
|
|
|
ActivityScanerCode.setScanerListener(mScanerListener);
|
|
|
ActivityScanerCode.intent2Activity(mContext, BaseConfig.COMMON_SCANNER_ONLY);
|
|
|
}else{
|
|
@@ -452,22 +467,25 @@ public class ScanPhotosMainActivity extends BaseActivity implements StoJNI.Scan
|
|
|
@Override
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
//取消上传任务
|
|
|
- pictureInbound();
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}).show();
|
|
|
}
|
|
|
|
|
|
+ break;
|
|
|
+ case R.id.btn_confirm:
|
|
|
+ pictureInbound();
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
unbinder.unbind();
|
|
|
- pictureSelectorUpload.removeHandler();
|
|
|
super.onDestroy();
|
|
|
}
|
|
|
@Override
|