|
@@ -23,7 +23,9 @@ import com.cooleshow.base.constanst.UploadConstants;
|
|
|
import com.cooleshow.base.router.RouterPath;
|
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
|
import com.cooleshow.base.utils.JumpUtils;
|
|
|
+import com.cooleshow.base.utils.LOG;
|
|
|
import com.cooleshow.base.utils.ToastUtil;
|
|
|
+import com.cooleshow.base.utils.UiUtils;
|
|
|
import com.cooleshow.base.utils.helper.GlideEngine;
|
|
|
import com.cooleshow.base.utils.helper.QMUIDeviceHelper;
|
|
|
import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
|
|
@@ -67,6 +69,7 @@ public class FeedBackActivity extends BaseMVPActivity<ActivityFeedbackLayoutBind
|
|
|
private FeedBackAddPhotoListAdapter mPhotoListAdapter;
|
|
|
|
|
|
List<String> urlList = new ArrayList<>();
|
|
|
+ private int preUploadSize = 0;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
@@ -94,19 +97,6 @@ public class FeedBackActivity extends BaseMVPActivity<ActivityFeedbackLayoutBind
|
|
|
} else {
|
|
|
presenter.addSuggestion(content, "", currentSelectTypeId, "");
|
|
|
}
|
|
|
-// String mobileNo = viewBinding.etConnect.getText().toString().trim();
|
|
|
-// if (TextUtils.isEmpty(mobileNo)) {
|
|
|
-// mobileNo = UserHelper.getUserPhone();
|
|
|
-//// ToastUtil.getInstance().showShort("请输入您的邮箱或手机号");
|
|
|
-//// return;
|
|
|
-// }
|
|
|
-// boolean mobile = PhoneUtils.isMobile(mobileNo);
|
|
|
-// boolean email = RegexUtils.isEmail(mobileNo);
|
|
|
-// if (mobile || email) {
|
|
|
-// presenter.addSuggestion(content, mobileNo);
|
|
|
-// } else {
|
|
|
-// ToastUtil.getInstance().showShort("请输入正确的邮箱或手机号");
|
|
|
-// }
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -150,10 +140,11 @@ public class FeedBackActivity extends BaseMVPActivity<ActivityFeedbackLayoutBind
|
|
|
|
|
|
private void uploadImg(int enableSelectSize) {
|
|
|
urlList.clear();
|
|
|
+ this.preUploadSize = enableSelectSize;
|
|
|
for (int i = 0; i < mPhotoListAdapter.getData().size(); i++) {
|
|
|
String compressPath = mPhotoListAdapter.getData().get(i).getCompressPath();
|
|
|
if (!TextUtils.isEmpty(compressPath)) {
|
|
|
- upLoadVideo(this, compressPath, enableSelectSize);
|
|
|
+ upLoadVideo(this, compressPath);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -245,14 +236,19 @@ public class FeedBackActivity extends BaseMVPActivity<ActivityFeedbackLayoutBind
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public void upLoadVideo(Activity activity, String filePath, int enableSelectSize) {
|
|
|
- UploadHelper uploadHelper = new UploadHelper(activity, UploadConstants.UPLOAD_TYPE_OTHER);
|
|
|
+ public void upLoadVideo(Activity activity, String filePath) {
|
|
|
+ UploadHelper uploadHelper = new UploadHelper(null, UploadConstants.UPLOAD_TYPE_OTHER);
|
|
|
uploadHelper.uploadFile(new File(filePath));
|
|
|
+ setLoadingCancelable(false);
|
|
|
+ showUploadLoading(0);
|
|
|
uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
|
|
|
@Override
|
|
|
public void onSuccess(String url) {
|
|
|
urlList.add(url);
|
|
|
- if (urlList.size() == enableSelectSize) {
|
|
|
+ LOG.i("upload success:" + urlList.size());
|
|
|
+ if (urlList.size() == preUploadSize) {
|
|
|
+ showUploadLoading(100);
|
|
|
+ hideLoading();
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
for (int i = 0; i < urlList.size(); i++) {
|
|
|
stringBuilder.append(urlList.get(i));
|
|
@@ -266,12 +262,40 @@ public class FeedBackActivity extends BaseMVPActivity<ActivityFeedbackLayoutBind
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void onUploadProgress(double v) {
|
|
|
+ double v1 = countUploadProgress(v);
|
|
|
+ showUploadLoading(v1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void onFailure() {
|
|
|
+ hideLoading();
|
|
|
ToastUtil.getInstance().showShort("上传失败,请重试");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void showUploadLoading(double value) {
|
|
|
+ String s = UiUtils.convertDouble(value);
|
|
|
+ String text = "上传中" + s + "%";
|
|
|
+ showLoading(text);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void hideLoading() {
|
|
|
+ setLoadingCancelable(true);
|
|
|
+ super.hideLoading();
|
|
|
+ }
|
|
|
+
|
|
|
+ private double countUploadProgress(double currentProgress) {
|
|
|
+ int size = urlList.size();
|
|
|
+ double cPercent = currentProgress / 100.0;
|
|
|
+ double singleMaxProgress = 100d / preUploadSize;
|
|
|
+ double result = size * singleMaxProgress + cPercent * singleMaxProgress;
|
|
|
+ LOG.i("result:"+result+"-size:" + size + "-cPercent" + cPercent + "-singleMaxProgress:" + singleMaxProgress);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private String getContent() {
|
|
|
return viewBinding.etContent.getText().toString().trim();
|
|
|
}
|
|
@@ -335,6 +359,7 @@ public class FeedBackActivity extends BaseMVPActivity<ActivityFeedbackLayoutBind
|
|
|
//自定义布局中的控件初始化及事件处理
|
|
|
final TextView tvSubmit = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_finish);
|
|
|
TextView ivCancel = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_cancel);
|
|
|
+ tvSubmit.setTextColor(StyleConfig.getMainColor(FeedBackActivity.this));
|
|
|
tvSubmit.setOnClickListener(v12 -> {
|
|
|
pvOptions.returnData();
|
|
|
pvOptions.dismiss();
|