From 979d9cff22806f213b420452ab4a68fcbaf021b6 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 31 五月 2021 17:43:49 +0800
Subject: [PATCH] 1. 修复多项可能引起空指针崩溃的bug; 2. 新建子任务时默认执行人员从全体人员改为当前用户; 3. 新建子任务时默认执行时间强制固定为总任务对应的时段内,确保子任务执行时间不会超出总任务范围。
---
app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeDetailActivity.java | 158 +++++++++++++++++++++++++++++-----------------------
1 files changed, 87 insertions(+), 71 deletions(-)
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeDetailActivity.java b/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeDetailActivity.java
index c124ee0..00a12d1 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeDetailActivity.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeDetailActivity.java
@@ -45,7 +45,7 @@
import cn.flightfeather.thirdapp.CommonApplication;
import cn.flightfeather.thirdapp.R;
import cn.flightfeather.thirdapp.activity.PhotoViewerActivity;
-import cn.flightfeather.thirdapp.bean.Mediafile;
+import cn.flightfeather.thirdapp.bean.entity.Mediafile;
import cn.flightfeather.thirdapp.bean.vo.MediafileVo;
import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo;
import cn.flightfeather.thirdapp.httpservice.ProblemListService;
@@ -184,7 +184,12 @@
if (data!=null){
int position = data.getIntExtra("position",-1);
if (position>-1){
+ mediafileDao.deleteByKey(mediafileListChange.get(position).getGuid());
this.mediafileListChange.remove(position);
+ //fixme 2020/11/12 鐢变簬鍒犻櫎鍗曞紶鍥剧墖鏄洿鎺ヨ仈缃戝皢鏈嶅姟鍣ㄦ暟鎹竴骞跺垹闄わ紝鍥犳褰撳浘鐗囧叏閮ㄥ垹闄ゅ悗锛岀珛鍗虫洿鏂伴棶棰樹负鏈暣鏀圭姸鎬�
+ if (mediafileListChange.isEmpty()) {
+ uploadProblem();
+ }
this.isEdited = !mediafileListChange.isEmpty();
initChangingPhoto(this.mediafileListChange, this.imageViewChangeList);
if (this.problemlistVo.getIschanged()) {
@@ -511,31 +516,39 @@
//<editor-fold desc="鐐瑰嚮浜嬩欢">
private void refreshProblemStatus() {
- this.problemlistVo.setIschanged(true);//璁剧疆涓哄凡鏁存敼
- this.problemlistVo.setExtension3(Domain.CHANGE_UNCHECKED);//璁剧疆涓烘暣鏀瑰緟瀹℃牳
- this.problemlistVo.setChangedtime(new Date());//璁剧疆鏁存敼鏃堕棿涓哄綋鍓嶆椂闂�
- this.problemlistVo.getMediafileList().clear();
- this.problemlistVo.getMediafileList().addAll(this.mediafileListProblem);
- this.problemlistVo.getMediafileList().addAll(this.mediafileListChange);//灏嗘柊澧炵殑鍥剧墖娣诲姞杩涘獟浣撴枃浠跺垪琛紝鐢ㄤ簬app鏁版嵁鍒锋柊
+ //鏁存敼鍥剧墖鍏ㄥ垹闄ゅ悗锛岄棶棰橀��鍥炴湭鏁存敼瀹℃牳閫氳繃鐘舵��
+ if (mediafileListChange.isEmpty()) {
+ this.problemlistVo.setIschanged(false);//璁剧疆涓烘湭鏁存敼
+ this.problemlistVo.setExtension3(Domain.PROBLEM_CHECK_PASS);
+ this.problemlistVo.setChangedtime(null);
+ this.problemlistVo.setChangecatalog(null);
+ } else {
+ this.problemlistVo.setIschanged(true);//璁剧疆涓哄凡鏁存敼
+ this.problemlistVo.setExtension3(Domain.CHANGE_UNCHECKED);//璁剧疆涓烘暣鏀瑰緟瀹℃牳
+ this.problemlistVo.setChangedtime(new Date());//璁剧疆鏁存敼鏃堕棿涓哄綋鍓嶆椂闂�
+ this.problemlistVo.getMediafileList().clear();
+ this.problemlistVo.getMediafileList().addAll(this.mediafileListProblem);
+ this.problemlistVo.getMediafileList().addAll(this.mediafileListChange);//灏嗘柊澧炵殑鍥剧墖娣诲姞杩涘獟浣撴枃浠跺垪琛紝鐢ㄤ簬app鏁版嵁鍒锋柊
- Calendar calendar = Calendar.getInstance();
- int today = calendar.get(Calendar.DAY_OF_YEAR);
- calendar.setTime(this.problemlistVo.getTime());
- int problemDay = calendar.get(Calendar.DAY_OF_YEAR);
- //鏈夋壙璇烘暣鏀圭殑鏃ユ湡
- if (this.problemlistVo.getExtension1() != null){
- //鏁存敼鏃堕棿宸茶秴杩囩洃绠″綋澶╃殑24鐐癸紝鍒欒涓烘槸鎵胯鏁存敼
- if (today > problemDay) {
- this.problemlistVo.setChangecatalog(Domain.PROMISE_CHANGE);
+ Calendar calendar = Calendar.getInstance();
+ int today = calendar.get(Calendar.DAY_OF_YEAR);
+ calendar.setTime(this.problemlistVo.getTime());
+ int problemDay = calendar.get(Calendar.DAY_OF_YEAR);
+ //鏈夋壙璇烘暣鏀圭殑鏃ユ湡
+ if (this.problemlistVo.getExtension1() != null) {
+ //鏁存敼鏃堕棿宸茶秴杩囩洃绠″綋澶╃殑24鐐癸紝鍒欒涓烘槸鎵胯鏁存敼
+ if (today > problemDay) {
+ this.problemlistVo.setChangecatalog(Domain.PROMISE_CHANGE);
+ }
+ //鍚﹀垯鏄幇鍦哄綋澶╂暣鏀�
+ else {
+ this.problemlistVo.setChangecatalog(Domain.LOACAL_CHANGE);
+ }
}
- //鍚﹀垯鏄幇鍦哄綋澶╂暣鏀�
+ //娌℃湁鎵胯鏁存敼鐨勬棩鏈熸槸鏈壙璇烘暣鏀�
else {
- this.problemlistVo.setChangecatalog(Domain.LOACAL_CHANGE);
+ this.problemlistVo.setChangecatalog(Domain.UNPROMISE_CHANGE);
}
- }
- //娌℃湁鎵胯鏁存敼鐨勬棩鏈熸槸鏈壙璇烘暣鏀�
- else {
- this.problemlistVo.setChangecatalog(Domain.UNPROMISE_CHANGE);
}
}
@@ -547,29 +560,8 @@
// return;
// }
if (this.isEdited){
- loadingDialog = DialogUtil.createLoadingDialog(this, "");
- refreshProblemStatus();
- Call<ResponseBody> updateProblemList = application.getRetrofit().create(ProblemListService.class).updateProblemList(this.problemlistVo);
- updateProblemList.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body()!=null){
- Toast.makeText(application, R.string.submit_success, Toast.LENGTH_LONG).show();
- //涓婁紶闂鎴愬姛鍚庯紝寮�濮嬩笂浼犲搴旂殑鏁存敼鍥剧墖
- upLoadPic();
-
- }else if (response.errorBody()!=null){
- Toast.makeText(application, R.string.submit_unsuccess, Toast.LENGTH_LONG).show();
- loadingDialog.dismiss();
- }
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- Toast.makeText(application, R.string.network_error, Toast.LENGTH_LONG).show();
- loadingDialog.dismiss();
- }
- });
+ loadingDialog = DialogUtil.createLoadingDialog(this, "");
+ upLoadPic();
}else {
Toast.makeText(application, R.string.take_one_change_photo_at_least, Toast.LENGTH_SHORT).show();
}
@@ -603,6 +595,45 @@
}
}
+ private void uploadProblem() {
+ refreshProblemStatus();
+ Call<ResponseBody> updateProblemList = application.getRetrofit().create(ProblemListService.class).updateProblemList(this.problemlistVo);
+ updateProblemList.enqueue(new Callback<ResponseBody>() {
+ @Override
+ public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
+ if (response.body()!=null){
+ Toast.makeText(application, R.string.submit_success, Toast.LENGTH_LONG).show();
+
+ if (loadingDialog != null && loadingDialog.isShowing()) {
+ loadingDialog.dismiss();
+ }
+ //杩斿洖requestCode
+ Intent intent = new Intent();
+ intent.putExtra(ARG_PROBLEM, problemlistVo);
+ setResult(RESULT_OK, intent);
+
+ //鍙戦�佹暟鎹洿鏂板箍鎾�
+ Intent intent1 = new Intent("cn.flightfeather.thirdapp.broadcasereceiver.MainReceiver");
+ intent1.setAction(Constant.REFRESH_DATA);
+ intent1.putExtra(ARG_PROBLEM, problemlistVo);
+ sendBroadcast(intent1);
+
+ finish();
+
+ }else if (response.errorBody()!=null){
+ Toast.makeText(application, R.string.submit_unsuccess, Toast.LENGTH_LONG).show();
+ loadingDialog.dismiss();
+ }
+ }
+
+ @Override
+ public void onFailure(Call<ResponseBody> call, Throwable t) {
+ Toast.makeText(application, R.string.network_error, Toast.LENGTH_LONG).show();
+ loadingDialog.dismiss();
+ }
+ });
+ }
+
private void upLoadPic() {
@@ -617,37 +648,22 @@
PhotoUtil photoUtil = new PhotoUtil(mediafiles.size(), application, new OnUpLoadListener() {
@Override
public void onSuccess() {
- Toast.makeText(application, "涓婁紶鎴愬姛", Toast.LENGTH_SHORT).show();
- if (loadingDialog != null && loadingDialog.isShowing()) {
- loadingDialog.dismiss();
- }
- //杩斿洖requestCode
- Intent intent = new Intent();
- intent.putExtra(ARG_PROBLEM, problemlistVo);
- setResult(RESULT_OK, intent);
-
- //鍙戦�佹暟鎹洿鏂板箍鎾�
- Intent intent1 = new Intent("cn.flightfeather.thirdapp.broadcasereceiver.MainReceiver");
- intent1.setAction(Constant.REFRESH_DATA);
- intent1.putExtra(ARG_PROBLEM, problemlistVo);
- sendBroadcast(intent1);
-
- finish();
+ uploadProblem();
}
@Override
public void onFail() {
- Toast.makeText(application, "涓婁紶澶辫触", Toast.LENGTH_SHORT).show();
+ Toast.makeText(application, "涓婁紶澶辫触锛岃閲嶈瘯", Toast.LENGTH_SHORT).show();
loadingDialog.dismiss();
- AlertDialog.Builder dialog = new AlertDialog.Builder(application);
- dialog.setMessage("鍥剧墖涓婁紶澶辫触锛岃鎵嬪姩涓婁紶鎴栬仈绯绘垜鍙革紒");
- dialog.setPositiveButton("纭畾", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- finish();
- }
- });
- dialog.show();
+// AlertDialog.Builder dialog = new AlertDialog.Builder(application);
+// dialog.setMessage("鍥剧墖涓婁紶澶辫触锛岃閲嶈瘯");
+// dialog.setPositiveButton("纭畾", new DialogInterface.OnClickListener() {
+// @Override
+// public void onClick(DialogInterface dialogInterface, int i) {
+// finish();
+// }
+// });
+// dialog.show();
}
});
--
Gitblit v1.9.3