From 4f7f99c6ea914bcd38de78bd8371be566026b905 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期三, 26 二月 2025 15:54:14 +0800
Subject: [PATCH] -为按钮和列表项添加波纹效果,以获得更好的视觉反馈 -改进MapFragment中的底部布局动画 -在MapFragment中添加设备状态和RTU地址显示 -更新BaseListResult以支持泛型类型 -为设备数据添加IntakeListResult和IntakeResult -通过数据库支持增强标记位置更新功能 -添加电话拨号意图以分隔标记详细信息 -通过过期检查改进磁贴缓存 -添加问题报告的确认对话框 -更新登录活动以限制用户名长度 -为波纹效果和UI元素添加新颜色 -重构XML布局以使用新的波纹图 -改进MapFragment中的错误处理和用户反馈
---
app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java | 34 +++++++++++++++++++++++-----------
1 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java b/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java
index 7e5671c..e21da6e 100644
--- a/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java
+++ b/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java
@@ -17,6 +17,7 @@
import com.dayu.pipirrapp.bean.net.CodeResult;
import com.dayu.pipirrapp.bean.net.UplodFileState;
import com.dayu.pipirrapp.bean.net.WeatherResponse;
+import com.dayu.pipirrapp.bean.net.UploadFileResult;
import com.dayu.pipirrapp.net.subscribers.BaseProgressSubscriber;
import com.dayu.pipirrapp.net.subscribers.CodeListener;
import com.dayu.pipirrapp.net.subscribers.ProgressSubscriber;
@@ -28,7 +29,6 @@
import com.dayu.pipirrapp.utils.MyJsonParser;
import com.dayu.pipirrapp.utils.MyLog;
import com.dayu.pipirrapp.utils.NetUtils;
-import com.google.gson.internal.LinkedTreeMap;
import java.io.File;
import java.util.HashMap;
@@ -62,6 +62,7 @@
static ApiManager apiManager;
//鏂囦欢涓婁紶澶辫触閲嶅娆℃暟
int uplodFilerepeatSize = 3;
+
ApiService apiService;
// 绠$悊璁㈤槄浜嬩欢
@@ -302,7 +303,7 @@
public void uploadFile(final Context context, final UplodFileState uplodData, final UploadFileListener listener, final AddPictureAdapter adapter) {
if (!TextUtils.isEmpty(uplodData.getFilePath())) {
- MyLog.d("progressRequestBody>>>" + "path:" + uplodData.getFilePath()+">>>uploadType:"+uplodData.getUploadType());
+ MyLog.d("progressRequestBody_uploadFile>>>" + "path:" + uplodData.getFilePath() + ">>>uploadType:" + uplodData.getUploadType());
uplodData.setState(STATE_UPDING);
File file = new File(uplodData.getFilePath());
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
@@ -312,18 +313,26 @@
int progress = (int) (100 * bytesWritten / contentLength);
// 渚嬪锛氭洿鏂� ProgressBar 鎴栨樉绀鸿繘搴�
runOnUiThread(() -> {
- uplodData.setProgress(progress);
+ if (progress <5) {
+ uplodData.setProgress(0);
+ }
// 杩涘害鏉℃洿鏂颁唬鐮�
if (adapter != null && uplodData.getAdapterPosition() != -1) {
- adapter.updateProgress(uplodData);
+ //浼樺寲涓嶉绻佹洿鏂拌繘搴�
+ if (progress - uplodData.getProgress() > 5 || progress == 100) {
+ uplodData.setProgress(progress);
+ adapter.updateProgress(uplodData);
+
+ }
+
}
- MyLog.d("progressRequestBody>>>" + "adapterPosition:" + uplodData.getAdapterPosition() + ">>>涓婁紶杩涘害: " + progress + "%");
+ MyLog.d("progressRequestBodyHolder>>>path" + "adapterPosition:" + uplodData.getAdapterPosition() + ">>>涓婁紶杩涘害: " + progress + "%");
});
});
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), progressRequestBody);
RequestBody description = RequestBody.create(MediaType.parse("text/plain"), "file description");
- Call<BaseResponse> uploadFile = null;
+ Call<BaseResponse<UploadFileResult>> uploadFile = null;
switch (uplodData.getUploadType()) {
case UplodFileState.IMG_TYPE:
uploadFile = apiService.uploadImgFile(body, description);
@@ -337,14 +346,17 @@
}
uplodData.setThisCall(uploadFile);
- uploadFile.enqueue(new Callback<BaseResponse>() {
+ uploadFile.enqueue(new Callback<BaseResponse<UploadFileResult>>() {
@Override
- public void onResponse(Call<BaseResponse> call, Response<BaseResponse> response) {
+ public void onResponse(Call<BaseResponse<UploadFileResult>> call, Response<BaseResponse<UploadFileResult>> response) {
if (response.body() != null) {
if (response.body().isSuccess()) {
+ UploadFileResult uploadFileResult=response.body().getContent();
uplodData.setState(STATE_DONE);
- uplodData.setPostId(((LinkedTreeMap) response.body().getContent()).get("id").toString());
- uplodData.setWebPath(((LinkedTreeMap) response.body().getContent()).get("webPath").toString());
+ uplodData.setPostId(uploadFileResult.getId());
+ uplodData.setUoloadFilePath(uploadFileResult.getFilePath());
+ uplodData.setHash(uploadFileResult.getHash());
+ uplodData.setWebPathZip(uploadFileResult.getWebPathZip());
listener.onBack(uplodData);
} else {
MyLog.d("progressRequestBody>>>" + response.body().getMsg());
@@ -362,7 +374,7 @@
}
@Override
- public void onFailure(Call<BaseResponse> call, Throwable t) {
+ public void onFailure(Call<BaseResponse<UploadFileResult>> call, Throwable t) {
MyLog.d("progressRequestBody>>>" + "onFailure:" + t.getMessage());
if (!t.getMessage().equals("Canceled")) {
uplodData.setState(STATE_ERROR);
--
Gitblit v1.8.0