|
@@ -2,6 +2,7 @@ package com.fxy.main.fragment;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.annotation.SuppressLint;
|
|
import android.app.AlertDialog;
|
|
import android.app.AlertDialog;
|
|
|
|
+import android.app.ProgressDialog;
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
@@ -19,6 +20,9 @@ import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.elvishew.xlog.XLog;
|
|
import com.elvishew.xlog.XLog;
|
|
|
|
+import com.fxy.baselibrary.bean.BaseEventBusBean;
|
|
|
|
+import com.fxy.common.AsyncPictureUpload;
|
|
|
|
+import com.fxy.constant.EventCode;
|
|
import com.fxy.utils.JobUtils;
|
|
import com.fxy.utils.JobUtils;
|
|
import com.lzy.okgo.OkGo;
|
|
import com.lzy.okgo.OkGo;
|
|
import com.lzy.okgo.model.Response;
|
|
import com.lzy.okgo.model.Response;
|
|
@@ -52,13 +56,18 @@ import com.fxy.net.MyDialogCallback;
|
|
import com.fxy.net.Urls;
|
|
import com.fxy.net.Urls;
|
|
import com.fxy.utils.DeviceIdUtils;
|
|
import com.fxy.utils.DeviceIdUtils;
|
|
|
|
|
|
|
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
|
+import org.greenrobot.eventbus.ThreadMode;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
import butterknife.ButterKnife;
|
|
import butterknife.ButterKnife;
|
|
@@ -86,6 +95,9 @@ public class MineFragment extends BaseFragment {
|
|
@BindView(R.id.tv_name)
|
|
@BindView(R.id.tv_name)
|
|
TextView tvName;
|
|
TextView tvName;
|
|
|
|
|
|
|
|
+ @BindView(R.id.tv_await_num)
|
|
|
|
+ TextView tvAwaitNum;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 系统缓存
|
|
* 系统缓存
|
|
*/
|
|
*/
|
|
@@ -95,7 +107,9 @@ public class MineFragment extends BaseFragment {
|
|
@BindView(R.id.rl_picture_selector)
|
|
@BindView(R.id.rl_picture_selector)
|
|
LinearLayout rlPictureSelector;
|
|
LinearLayout rlPictureSelector;
|
|
|
|
|
|
-
|
|
|
|
|
|
+ private ProgressDialog progressDialog;
|
|
|
|
+ private AsyncPictureUpload asyncPictureUpload ;
|
|
|
|
+ private boolean currentUploadStatus = false;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 系统版本
|
|
* 系统版本
|
|
@@ -115,6 +129,11 @@ public class MineFragment extends BaseFragment {
|
|
@Override
|
|
@Override
|
|
protected void initView(View rootView) {
|
|
protected void initView(View rootView) {
|
|
bind = ButterKnife.bind(this, rootView);
|
|
bind = ButterKnife.bind(this, rootView);
|
|
|
|
+ asyncPictureUpload = new AsyncPictureUpload(Objects.requireNonNull(getActivity()));
|
|
|
|
+ progressDialog = new ProgressDialog(getActivity());
|
|
|
|
+ // 注册当前Fragment作为事件监听器
|
|
|
|
+ EventBus.getDefault().register(this);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -149,6 +168,10 @@ public class MineFragment extends BaseFragment {
|
|
rlPictureSelector.setVisibility(View.GONE);
|
|
rlPictureSelector.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
JobUtils.deviceIdleJob(getContext());
|
|
JobUtils.deviceIdleJob(getContext());
|
|
|
|
+
|
|
|
|
+ tvAwaitNum.setText(String.valueOf(asyncPictureUpload.getAllAwaitNum()));
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
private String getVersionName(Context context) {
|
|
private String getVersionName(Context context) {
|
|
try {
|
|
try {
|
|
@@ -215,7 +238,7 @@ public class MineFragment extends BaseFragment {
|
|
|
|
|
|
@OnClick({R.id.iv_avatar,R.id.rl_account_feedback,R.id.rl_blue_setting,R.id.rl_scan_setting,R.id.rl_account_wipeCache,
|
|
@OnClick({R.id.iv_avatar,R.id.rl_account_feedback,R.id.rl_blue_setting,R.id.rl_scan_setting,R.id.rl_account_wipeCache,
|
|
R.id.rl_account_versionUpdate,R.id.rl_language_change, R.id.tv_exit,R.id.rl_electronic_scale,R.id.rl_upload_files,
|
|
R.id.rl_account_versionUpdate,R.id.rl_language_change, R.id.tv_exit,R.id.rl_electronic_scale,R.id.rl_upload_files,
|
|
- R.id.rl_picture_selector})
|
|
|
|
|
|
+ R.id.rl_picture_selector,R.id.rl_upload_async_files})
|
|
public void onViewClicked(View view) {
|
|
public void onViewClicked(View view) {
|
|
switch (view.getId()) {
|
|
switch (view.getId()) {
|
|
case R.id.iv_avatar:
|
|
case R.id.iv_avatar:
|
|
@@ -293,6 +316,27 @@ public class MineFragment extends BaseFragment {
|
|
break;
|
|
break;
|
|
case R.id.rl_picture_selector:
|
|
case R.id.rl_picture_selector:
|
|
intent2Page(PictureSelectorActivity.class, false);
|
|
intent2Page(PictureSelectorActivity.class, false);
|
|
|
|
+ break;
|
|
|
|
+ case R.id.rl_upload_async_files:
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int total = asyncPictureUpload.getAllAwaitNum();
|
|
|
|
+ if (total>0){
|
|
|
|
+ progressDialog = new ProgressDialog(getActivity());
|
|
|
|
+ progressDialog.setTitle("待上传文件"+total+"个");
|
|
|
|
+ progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
|
|
|
+ progressDialog.setCanceledOnTouchOutside(false);
|
|
|
|
+ progressDialog.show();
|
|
|
|
+ if (!currentUploadStatus){
|
|
|
|
+ asyncPictureUpload.setStartUpload();
|
|
|
|
+ currentUploadStatus = false;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ showToast("已全部上传");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -438,10 +482,46 @@ public class MineFragment extends BaseFragment {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * eventbus在主线程接收方法
|
|
|
|
+ *
|
|
|
|
+ * @param event
|
|
|
|
+ */
|
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
|
+ public void onEvent(BaseEventBusBean event) {
|
|
|
|
+ assert event != null;
|
|
|
|
+ switch (event.getEventCode()){
|
|
|
|
+
|
|
|
|
+ case EventCode.file_upload_lister:
|
|
|
|
+ int total = asyncPictureUpload.getAllAwaitNum();
|
|
|
|
+ tvAwaitNum.setText(String.valueOf(total));
|
|
|
|
+ if (total>0){
|
|
|
|
+ progressDialog.setTitle("待上传文件"+total+"个");
|
|
|
|
+ }else{
|
|
|
|
+ asyncPictureUpload.setStopUpload();
|
|
|
|
+ currentUploadStatus = false;
|
|
|
|
+ progressDialog.dismiss();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case EventCode.file_upload_progress_lister:
|
|
|
|
+ HashMap<String,Object> hashMap = (HashMap) event.getData();
|
|
|
|
+ int process = Integer.parseInt(hashMap.get("process").toString());
|
|
|
|
+ progressDialog.setProgress(process);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onDestroy() {
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
super.onDestroy();
|
|
bind.unbind();
|
|
bind.unbind();
|
|
|
|
+ if (asyncPictureUpload!=null){
|
|
|
|
+ asyncPictureUpload.setStopUpload();
|
|
|
|
+ asyncPictureUpload.removeHandler();
|
|
|
|
+ }
|
|
|
|
+
|
|
OkGo.getInstance().cancelTag(this);
|
|
OkGo.getInstance().cancelTag(this);
|
|
|
|
+ EventBus.getDefault().unregister(this);
|
|
}
|
|
}
|
|
}
|
|
}
|