|
@@ -31,7 +31,6 @@ import com.fxy.baselibrary.util.JsonUtil;
|
|
|
import com.fxy.bean.ActionBean;
|
|
|
import com.fxy.bean.ScanBean;
|
|
|
import com.fxy.common.AsyncPictureSelector;
|
|
|
-import com.fxy.common.AsyncPictureUpload;
|
|
|
import com.fxy.constant.BaseConfig;
|
|
|
import com.fxy.constant.EventCode;
|
|
|
import com.fxy.constant.SPCache;
|
|
@@ -39,6 +38,7 @@ import com.fxy.detection.bean.TakePictureBean;
|
|
|
import com.fxy.detection.bean.TrackingBoxBean;
|
|
|
import com.fxy.net.MyDialogCallback;
|
|
|
import com.fxy.net.Urls;
|
|
|
+import com.fxy.utils.UploadUtils;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.zxing.Result;
|
|
|
import com.luck.picture.lib.config.PictureConfig;
|
|
@@ -86,7 +86,6 @@ public class TrayPutInMainActivity extends BaseActivity implements StoJNI.ScanC
|
|
|
|
|
|
private HashMap<String, AsyncPictureSelector> mapPictureSelector = new HashMap<>();
|
|
|
|
|
|
- private AsyncPictureUpload asyncPictureUpload = new AsyncPictureUpload(this);
|
|
|
|
|
|
private TrackingBoxBean trackingBoxBean;
|
|
|
|
|
@@ -114,9 +113,6 @@ public class TrayPutInMainActivity extends BaseActivity implements StoJNI.ScanC
|
|
|
private int leisure = 10;
|
|
|
|
|
|
|
|
|
- private Handler workHandler;
|
|
|
- private Runnable idleRunnable;
|
|
|
-
|
|
|
@Override
|
|
|
public int getContentViewResId() {
|
|
|
return R.layout.activity_fxy_detection_tray_putin;
|
|
@@ -156,9 +152,6 @@ public class TrayPutInMainActivity extends BaseActivity implements StoJNI.ScanC
|
|
|
mapPictureSelector.get(currentPictureType).getSelectImg(data);
|
|
|
}
|
|
|
totalAwaitNum();
|
|
|
- setNewTiming();
|
|
|
-
|
|
|
-
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -217,36 +210,10 @@ public class TrayPutInMainActivity extends BaseActivity implements StoJNI.ScanC
|
|
|
|
|
|
totalAwaitNum();
|
|
|
|
|
|
- workHandler = new Handler(Looper.getMainLooper());
|
|
|
- // 定义空闲任务
|
|
|
- idleRunnable = new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // 执行空闲后的操作
|
|
|
- operateStartUpload();
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- SPCache spCache = SPCache.getInstance(this);
|
|
|
- leisure = spCache.getLeisure();
|
|
|
|
|
|
- // 初始化时设置计时器
|
|
|
- workHandler.postDelayed(idleRunnable, leisure * 60 * 1000);
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void setNewTiming(){
|
|
|
- try {
|
|
|
- // 取消之前的计时器
|
|
|
- workHandler.removeCallbacks(idleRunnable);
|
|
|
- // 重新计时
|
|
|
- workHandler.postDelayed(idleRunnable, leisure * 60 * 1000); // 2 分钟
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
@@ -404,17 +371,14 @@ public class TrayPutInMainActivity extends BaseActivity implements StoJNI.ScanC
|
|
|
|
|
|
//getAwaitNum
|
|
|
private void totalAwaitNum(){
|
|
|
- int awaitNum = asyncPictureUpload.getAwaitNum();
|
|
|
+ int awaitNum = UploadUtils.getAwaitNum(mRealm,getClass().getSimpleName());
|
|
|
tvAwaitNum.setText(String.valueOf(awaitNum));
|
|
|
- if (awaitNum == 0){
|
|
|
- operateStopUpload();
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//统一按钮回调
|
|
|
@SuppressLint("NonConstantResourceId")
|
|
|
public void callbackEditor(View v){
|
|
|
- setNewTiming();
|
|
|
switch (v.getId()) {
|
|
|
case R.id.et_tracking_number:
|
|
|
getTrackingNumber();
|
|
@@ -692,69 +656,12 @@ public class TrayPutInMainActivity extends BaseActivity implements StoJNI.ScanC
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void operateStopUpload(){
|
|
|
- if (currentUploadStatus){
|
|
|
- asyncPictureUpload.setStopUpload();
|
|
|
- }
|
|
|
- }
|
|
|
- private void operateStartUpload(){
|
|
|
- if (!currentUploadStatus){
|
|
|
- asyncPictureUpload.setStartUpload();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- protected void showBack() {
|
|
|
- super.showBack();
|
|
|
- tb_iv_left.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
-
|
|
|
- int num = asyncPictureUpload.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();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
unbinder.unbind();
|
|
|
|
|
|
- asyncPictureUpload.removeHandler();
|
|
|
- // 确保清除所有的回调以防止内存泄漏
|
|
|
- workHandler.removeCallbacks(idleRunnable);
|
|
|
super.onDestroy();
|
|
|
}
|
|
|
@Override
|