From 0e870a0d919a28a45084a7df5f662afbfd7e086d Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 15 十二月 2020 14:44:28 +0800
Subject: [PATCH] DownloadAndSetImageTask和SetImageTask两个类由于在子线程执行,会经常出现activity关闭后继续执行导致报错崩溃问题,修复此bug
---
app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraActivity.kt | 3
app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseTakePicActivity.kt | 7
app/src/main/java/cn/flightfeather/thirdapp/activity/ProblemDetailActivity.java | 8
app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt | 7
app/src/main/java/cn/flightfeather/thirdapp/util/photo/PhotoUtil.java | 11
app/src/main/res/layout/activity_upload_media_files.xml | 4
app/src/main/java/cn/flightfeather/thirdapp/activity/GitDetailActivity.java | 4
app/src/main/java/cn/flightfeather/thirdapp/task/DownloadAndSetImageTask.java | 12
app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java | 31 +-
app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseActivity.kt | 3
app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceActivity.kt | 12
app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/InspectionInfoFragment.java | 4
app/src/main/java/cn/flightfeather/thirdapp/repository/dao/SceneDao.kt | 4
app/src/main/java/cn/flightfeather/thirdapp/repository/SceneRepository.kt | 5
app/build.gradle | 4
app/src/main/java/cn/flightfeather/thirdapp/task/SetImageTask.java | 85 +-------
app/src/main/java/cn/flightfeather/thirdapp/adapter/PhotoListAdapter.java | 16
app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuChangeActivity.kt | 1
/dev/null | 97 ----------
app/src/main/java/cn/flightfeather/thirdapp/activity/UploadMediaFilesActivity.java | 9
app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeActivity.java | 8
app/src/main/java/cn/flightfeather/thirdapp/fragment/HomeFragment.java | 1
app/src/main/java/cn/flightfeather/thirdapp/activity/PhotoViewerActivity.java | 2
app/src/main/java/cn/flightfeather/thirdapp/adapter/ProblemPromiseListAdapter.java | 14
app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeDetailActivity.java | 156 +++++++++-------
app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuRecheckActivity.kt | 1
26 files changed, 195 insertions(+), 314 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index ec3eab6..60497a4 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -13,8 +13,8 @@
applicationId "cn.flightfeather.thirdapp"
minSdkVersion 19
targetSdkVersion 28
- versionCode 21
- versionName "1.1.14.04"
+ versionCode 23
+ versionName "1.1.14.06"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 25
renderscriptSupportModeEnabled true
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/activity/GitDetailActivity.java b/app/src/main/java/cn/flightfeather/thirdapp/activity/GitDetailActivity.java
index 89c6d9f..0685248 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/activity/GitDetailActivity.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/activity/GitDetailActivity.java
@@ -117,7 +117,7 @@
Mediafile mediaFile = mediafileList.get(i);
File file =getFileFromMediaFile(mediaFile);
if (file.exists()){
- SetImageTask task1 = new SetImageTask(file, ivPhotoList.get(i));
+ SetImageTask task1 = new SetImageTask(file, ivPhotoList.get(i), this);
task1.execute();
}else {
DownloadAndSetImageTask task = new DownloadAndSetImageTask(mediaFile,ivPhotoList.get(i),this);
@@ -150,7 +150,7 @@
}
for (int i = 0;i<mediaFileList.size();i++){
if (resetImage){
- SetImageTask task1 = new SetImageTask(getFileFromMediaFile(mediaFileList.get(i)), ivPhotoList.get(i));
+ SetImageTask task1 = new SetImageTask(getFileFromMediaFile(mediaFileList.get(i)), ivPhotoList.get(i), this);
task1.execute();
}
ivPhotoList.get(i).setOnClickListener(showPhotoClicker(getFilesFromMediaFile(mediaFileList),i,mediaFileList));
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/activity/PhotoViewerActivity.java b/app/src/main/java/cn/flightfeather/thirdapp/activity/PhotoViewerActivity.java
index 200380d..27eb849 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/activity/PhotoViewerActivity.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/activity/PhotoViewerActivity.java
@@ -131,7 +131,7 @@
type = intent.getIntExtra("type",0);
deletable = intent.getBooleanExtra("deletable",false);
mediafiles = (List<Mediafile>) intent.getSerializableExtra(PARA_MEDIAS);
- position = intent.getIntExtra("position",-1);
+ position = intent.getIntExtra("position",0);
iv_share.setOnClickListener(this);
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/activity/ProblemDetailActivity.java b/app/src/main/java/cn/flightfeather/thirdapp/activity/ProblemDetailActivity.java
index c6bb099..c521146 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/activity/ProblemDetailActivity.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/activity/ProblemDetailActivity.java
@@ -598,7 +598,7 @@
//宸叉暣鏀圭殑鍥剧墖
File file = getFileFromMediaFile(mediaFile);
if (file.exists()){
- SetImageTask task1 = new SetImageTask(file, imageViewChangeList.get(changeMediaFileList.size()));
+ SetImageTask task1 = new SetImageTask(file, imageViewChangeList.get(changeMediaFileList.size()), this);
task1.execute();
}else {
DownloadAndSetImageTask task = new DownloadAndSetImageTask(mediaFile,imageViewChangeList.get(changeMediaFileList.size()),this);
@@ -610,7 +610,7 @@
File file = getFileFromMediaFile(mediaFile);
if (file.exists()){
//鏂囦欢鏈湴瀛樺湪鐩存帴璇诲彇鏄剧ず
- SetImageTask task1 = new SetImageTask(file, imageViewProblemList.get(problemMediaFileList.size()));
+ SetImageTask task1 = new SetImageTask(file, imageViewProblemList.get(problemMediaFileList.size()), this);
task1.execute();
}else {
DownloadAndSetImageTask task = new DownloadAndSetImageTask(mediaFile, imageViewProblemList.get(problemMediaFileList.size()),this);
@@ -655,14 +655,14 @@
private void refreshPhotoAndClicker(boolean resetImage) {
for (int i = 0; i < problemMediaFileList.size(); i++) {
if (resetImage){
- SetImageTask task1 = new SetImageTask(getFileFromMediaFile(problemMediaFileList.get(i)), imageViewProblemList.get(i));
+ SetImageTask task1 = new SetImageTask(getFileFromMediaFile(problemMediaFileList.get(i)), imageViewProblemList.get(i), this);
task1.execute();
}
imageViewProblemList.get(i).setOnClickListener(showPhotoClicker(getFilesFromMediaFiles(problemMediaFileList),i,problemMediaFileList,VIEW_PROBLEM_PHOTO));
}
for (int i = 0; i < changeMediaFileList.size(); i++) {
if (resetImage){
- SetImageTask task1 = new SetImageTask(getFileFromMediaFile(changeMediaFileList.get(i)), imageViewChangeList.get(i));
+ SetImageTask task1 = new SetImageTask(getFileFromMediaFile(changeMediaFileList.get(i)), imageViewChangeList.get(i), this);
task1.execute();
}
imageViewChangeList.get(i).setOnClickListener(showPhotoClicker(getFilesFromMediaFiles(changeMediaFileList),i,changeMediaFileList,VIEW_CHANGE_PHOTO));
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/activity/UploadMediaFilesActivity.java b/app/src/main/java/cn/flightfeather/thirdapp/activity/UploadMediaFilesActivity.java
index 05e108a..557bb66 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/activity/UploadMediaFilesActivity.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/activity/UploadMediaFilesActivity.java
@@ -122,10 +122,11 @@
pb_uploading.setMax(photoTotal);
pb_uploading.setProgress(photoUploaded);
tv_status.setText("鍘嬬缉涓�...");
- uploadingDialog2 = uploadingDialog.show();
-
-
-
+ if (uploadingDialog2 != null && !uploadingDialog2.isShowing()) {
+ uploadingDialog2.show();
+ } else {
+ uploadingDialog2 = uploadingDialog.show();
+ }
}
//寮�濮嬩笂浼�
public void startUplaod(List<File> outputFileList){
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java b/app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java
index a7be5aa..15cfe38 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java
@@ -1,20 +1,16 @@
package cn.flightfeather.thirdapp.adapter;
import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import com.bm.library.PhotoView;
+import com.bumptech.glide.Glide;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-
-import cn.flightfeather.thirdapp.util.ScreenUtils;
-import cn.flightfeather.thirdapp.util.photo.PhotoUtil;
/**
* Created by hyhb01 on 2018/3/26.
@@ -57,9 +53,12 @@
@Override
public Object instantiateItem(ViewGroup container, int position) {
- Bitmap bm = PhotoUtil.decodeSampledBitmapFromResource(fileList.get(position).getAbsolutePath(), ScreenUtils.getScreenWidth(context), ScreenUtils.getScreenHeight(context));
- viewList.get(position).setImageBitmap(bm);
+// Bitmap bm = PhotoUtil.decodeSampledBitmapFromResource(fileList.get(position).getAbsolutePath(), ScreenUtils.getScreenWidth(context), ScreenUtils.getScreenHeight(context));
+// viewList.get(position).setImageBitmap(bm);
+ Glide.with(container)
+ .load(fileList.get(position))
+ .into(viewList.get(position));
container.addView(viewList.get(position));
return viewList.get(position);
@@ -67,15 +66,15 @@
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
- BitmapDrawable bitmapDrawable = (BitmapDrawable) viewList.get(position).getDrawable();
- viewList.get(position).setImageDrawable(null);
- if (bitmapDrawable != null) {
- Bitmap bitmap = bitmapDrawable.getBitmap();
- if (bitmap != null) {
- bitmap.recycle();
- System.gc();
- }
- }
+// BitmapDrawable bitmapDrawable = (BitmapDrawable) viewList.get(position).getDrawable();
+// viewList.get(position).setImageDrawable(null);
+// if (bitmapDrawable != null) {
+// Bitmap bitmap = bitmapDrawable.getBitmap();
+// if (bitmap != null) {
+// bitmap.recycle();
+// System.gc();
+// }
+// }
container.removeView(viewList.get(position));
}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/adapter/PhotoListAdapter.java b/app/src/main/java/cn/flightfeather/thirdapp/adapter/PhotoListAdapter.java
index a4d5a50..33b1f8f 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/adapter/PhotoListAdapter.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/adapter/PhotoListAdapter.java
@@ -1,6 +1,6 @@
package cn.flightfeather.thirdapp.adapter;
-import android.content.Context;
+import android.app.Activity;
import android.os.Environment;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
@@ -24,13 +24,13 @@
public class PhotoListAdapter extends RecyclerView.Adapter<PhotoListAdapter.PhotoListHolder> {
private List<Mediafile> mediafileList;
- private Context context;
+ private Activity activity;
private LayoutInflater layoutInflater;
- public PhotoListAdapter(List<Mediafile> mediafileList, Context context) {
+ public PhotoListAdapter(List<Mediafile> mediafileList, Activity activity) {
this.mediafileList = mediafileList;
- this.context = context;
- layoutInflater = LayoutInflater.from(context);
+ this.activity = activity;
+ layoutInflater = LayoutInflater.from(activity);
}
@Override
@@ -44,7 +44,7 @@
Mediafile mediafile = mediafileList.get(position);
if (mediafile.getGuid() == null) {
- Glide.with(context)
+ Glide.with(activity)
.load(R.drawable.icon_add_photo)
.into(holder.iv_photo);
} else {
@@ -56,13 +56,13 @@
// SetImageTask task = new SetImageTask(file,holder.iv_photo);
// task.execute();
// String url = CommonApplication.getInstance().ROOT_URL_RELEASE_IMAGE + mediafile.getExtension1() + mediafile.getGuid() + ".jpg";
- Glide.with(context)
+ Glide.with(activity)
.load(file)
.placeholder(R.drawable.icon_add_photo_waite)
.override(100, 100)
.into(holder.iv_photo);
} else {
- DownloadAndSetImageTask task = new DownloadAndSetImageTask(mediafile, holder.iv_photo, context);
+ DownloadAndSetImageTask task = new DownloadAndSetImageTask(mediafile, holder.iv_photo, activity);
task.execute();
Log.e("photolist", position + " no image found");
}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/adapter/ProblemPromiseListAdapter.java b/app/src/main/java/cn/flightfeather/thirdapp/adapter/ProblemPromiseListAdapter.java
index 22ffe0e..b56583b 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/adapter/ProblemPromiseListAdapter.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/adapter/ProblemPromiseListAdapter.java
@@ -1,7 +1,7 @@
package cn.flightfeather.thirdapp.adapter;
+import android.app.Activity;
import android.app.DatePickerDialog;
-import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import android.support.v7.widget.RecyclerView;
@@ -46,7 +46,7 @@
public class ProblemPromiseListAdapter extends RecyclerView.Adapter<ProblemPromiseListAdapter.ProblemPromiseListHolder>{
private List<ProblemlistVo> problemlistVoList;
- private Context context;
+ private Activity activity;
private LayoutInflater layoutInflater;
private ProblemlistVo problemlistVoCurrent;
private MediafileDao mediafileDao;
@@ -61,10 +61,10 @@
private AllBoolean allBoolean;
- public ProblemPromiseListAdapter(List<ProblemlistVo> problemlistVoList, Context context, CommonApplication application,PromiseActivity promiseActivity,List<Mediafile> signMediaFileList, AllBoolean allBoolean) {
+ public ProblemPromiseListAdapter(List<ProblemlistVo> problemlistVoList, Activity activity, CommonApplication application, PromiseActivity promiseActivity, List<Mediafile> signMediaFileList, AllBoolean allBoolean) {
this.problemlistVoList = problemlistVoList;
- this.context = context;
- layoutInflater = LayoutInflater.from(context);
+ this.activity = activity;
+ layoutInflater = LayoutInflater.from(activity);
mediafileDao = application.getDaoSession().getMediafileDao();
this.application =application;
this.promiseActivity = promiseActivity;
@@ -175,10 +175,10 @@
private void setImage(Mediafile mediafile,ImageView imageView){
File file = new File(Environment.getExternalStorageDirectory(), (mediafile.getPath() + mediafile.getDescription()));
if (file.exists()){
- SetImageTask task1 = new SetImageTask(file,imageView);
+ SetImageTask task1 = new SetImageTask(file, imageView, activity);
task1.execute();
}else {
- DownloadAndSetImageTask task2 = new DownloadAndSetImageTask(mediafile,imageView,context);
+ DownloadAndSetImageTask task2 = new DownloadAndSetImageTask(mediafile,imageView, activity);
task2.execute();
}
}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/fragment/HomeFragment.java b/app/src/main/java/cn/flightfeather/thirdapp/fragment/HomeFragment.java
index d45d1a2..993e48c 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/fragment/HomeFragment.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/fragment/HomeFragment.java
@@ -671,6 +671,7 @@
}
void initView() {
+ if (subtask == null) return;
tv_info.setText(subtask.getName());
tv_address.setText(subtask.getScenseaddress());
try {
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/fragment/InspectionFragment.java b/app/src/main/java/cn/flightfeather/thirdapp/fragment/InspectionFragment.java
deleted file mode 100644
index a7fe0c3..0000000
--- a/app/src/main/java/cn/flightfeather/thirdapp/fragment/InspectionFragment.java
+++ /dev/null
@@ -1,3266 +0,0 @@
-package cn.flightfeather.thirdapp.fragment;
-
-
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.location.Location;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.Handler;
-import android.provider.MediaStore;
-import android.support.annotation.Nullable;
-import android.support.design.widget.FloatingActionButton;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.FileProvider;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.animation.AnimationUtils;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.CheckedTextView;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.Spinner;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.amap.api.maps.AMap;
-import com.amap.api.maps.CameraUpdateFactory;
-import com.amap.api.maps.MapView;
-import com.amap.api.maps.TextureMapView;
-import com.amap.api.maps.model.BitmapDescriptorFactory;
-import com.amap.api.maps.model.LatLng;
-import com.amap.api.maps.model.Marker;
-import com.amap.api.maps.model.MarkerOptions;
-import com.amap.api.maps.model.MyLocationStyle;
-import com.haibin.calendarview.Calendar;
-import com.haibin.calendarview.CalendarView;
-import com.ping.greendao.gen.DaoSession;
-import com.ping.greendao.gen.DomaincatalogDao;
-import com.ping.greendao.gen.DomainitemDao;
-import com.ping.greendao.gen.EvaluationruleDao;
-import com.ping.greendao.gen.EvaluationsubruleDao;
-import com.ping.greendao.gen.GittypeDao;
-import com.ping.greendao.gen.MediafileDao;
-import com.ping.greendao.gen.ProblemtypeDao;
-import com.ping.greendao.gen.ScenseDao;
-import com.ping.greendao.gen.SiteDao;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import cn.flightfeather.thirdapp.CommonApplication;
-import cn.flightfeather.thirdapp.R;
-import cn.flightfeather.thirdapp.activity.GitDetailActivity;
-import cn.flightfeather.thirdapp.activity.GradeActivity;
-import cn.flightfeather.thirdapp.activity.MapActivity;
-import cn.flightfeather.thirdapp.activity.PhotoViewerActivity;
-import cn.flightfeather.thirdapp.activity.ProblemDetailActivity;
-import cn.flightfeather.thirdapp.activity.PromiseActivity;
-import cn.flightfeather.thirdapp.activity.SignActivity;
-import cn.flightfeather.thirdapp.activity.SubTaskMapActivity;
-import cn.flightfeather.thirdapp.activity.UploadMediaFilesActivity;
-import cn.flightfeather.thirdapp.adapter.DomainItemListAdapter;
-import cn.flightfeather.thirdapp.adapter.GitListAdapter;
-import cn.flightfeather.thirdapp.adapter.GitTypeListAdapter;
-import cn.flightfeather.thirdapp.adapter.IconsPageAdapter;
-import cn.flightfeather.thirdapp.adapter.PhotoListAdapter;
-import cn.flightfeather.thirdapp.adapter.ProblemListAdapter;
-import cn.flightfeather.thirdapp.adapter.ProblemTypeListAdapter;
-import cn.flightfeather.thirdapp.adapter.RecyclerItemClickListener;
-import cn.flightfeather.thirdapp.adapter.TaskListAdapter;
-import cn.flightfeather.thirdapp.bean.ChangeAdvice;
-import cn.flightfeather.thirdapp.bean.Domainitem;
-import cn.flightfeather.thirdapp.bean.Gitlist;
-import cn.flightfeather.thirdapp.bean.Gittype;
-import cn.flightfeather.thirdapp.bean.Inspection;
-import cn.flightfeather.thirdapp.bean.LastSubtaskPack;
-import cn.flightfeather.thirdapp.bean.Mediafile;
-import cn.flightfeather.thirdapp.bean.Problemlist;
-import cn.flightfeather.thirdapp.bean.Problemtype;
-import cn.flightfeather.thirdapp.bean.Scense;
-import cn.flightfeather.thirdapp.bean.Site;
-import cn.flightfeather.thirdapp.bean.Subtask;
-import cn.flightfeather.thirdapp.bean.TaskPack;
-import cn.flightfeather.thirdapp.bean.vo.GitlistVo;
-import cn.flightfeather.thirdapp.bean.vo.InspectionVo;
-import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo;
-import cn.flightfeather.thirdapp.bean.vo.TaskVo;
-import cn.flightfeather.thirdapp.common.database.DbLink;
-import cn.flightfeather.thirdapp.common.database.DbSource;
-import cn.flightfeather.thirdapp.httpservice.InspectionImageService;
-import cn.flightfeather.thirdapp.httpservice.InspectionService;
-import cn.flightfeather.thirdapp.httpservice.SubTaskService;
-import cn.flightfeather.thirdapp.module.base.BaseTakePicActivity;
-import cn.flightfeather.thirdapp.module.task.SceneDetailActivity;
-import cn.flightfeather.thirdapp.task.SetImageTask;
-import cn.flightfeather.thirdapp.util.AmapNavi;
-import cn.flightfeather.thirdapp.util.Constant;
-import cn.flightfeather.thirdapp.util.DateFormatter;
-import cn.flightfeather.thirdapp.util.DialogUtil;
-import cn.flightfeather.thirdapp.util.ScreenUtils;
-import cn.flightfeather.thirdapp.util.UUIDGenerator;
-import cn.flightfeather.thirdapp.util.photo.PhotoUtil;
-import cn.flightfeather.thirdapp.util.slideswaphelper.OnDeleteListener;
-import cn.flightfeather.thirdapp.util.slideswaphelper.OnSwipeItemClickListener;
-import cn.flightfeather.thirdapp.util.slideswaphelper.PlusItemSlideCallback;
-import cn.flightfeather.thirdapp.util.slideswaphelper.WItemTouchHelperPlus;
-import io.reactivex.Observer;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.disposables.Disposable;
-import okhttp3.ResponseBody;
-import retrofit2.Call;
-import retrofit2.Callback;
-import retrofit2.Response;
-
-import static android.app.Activity.RESULT_OK;
-
-/**
- * A simple {@link Fragment} subclass.
- */
-public class InspectionFragment extends Fragment implements CalendarView.OnCalendarSelectListener, View.OnClickListener, AMap.OnMyLocationChangeListener {
-
- private static final String TAG = "InspectionFragment";
- private CommonApplication application;
- //鏁版嵁搴撶浉鍏�
- private SiteDao siteDao;
- private ScenseDao scenseDao;
- private DomaincatalogDao domaincatalogDao;
- private DomainitemDao domainitemDao;
- private EvaluationruleDao evaluationruleDao;
- private EvaluationsubruleDao evaluationsubruleDao;
- private GittypeDao gittypeDao;
- private ProblemtypeDao problemtypeDao;
- private MediafileDao mediafileDao;
- private DbSource dbSource;
- private List<Disposable> disposables = new ArrayList<>();
- //缃戠粶鐩稿叧
- InspectionService inspectionService;
- InspectionImageService inspectionImageService;
- SubTaskService subTaskService;
-
-
- //浠诲姟閫夋嫨閮ㄥ垎
- private RelativeLayout rl_selectTask;
- private CalendarView mCalendarView;
- private TextView tv_title;
- private Map<String, Calendar> schemes;
- private Spinner sp_selectMonthTask;
- private ArrayAdapter selectMonthTaskAdapter;
- private RecyclerView rv_subTaskList;
-
- //string:鏃ユ湡锛歽yyy-mm,
- private Map<String, List<TaskVo>> taskAllMapList;
- private java.util.Calendar lastMonthCalender;
- private java.util.Calendar calendarCurrent;
- private List<Integer> dayTaskTimeList;
- private Map<Integer, List<Subtask>> subTaskMapCurrent;
- private List<TaskVo> monthTaskListCurrent;
- private List<String> monthTaskStringListCurrent;
- private List<Subtask> subTaskListCurrent;
- private TaskListAdapter subTaskListAdapter;
- private boolean firstLoad = true;
- private boolean requestAgain = false;
- private TaskVo monthTaskSelected = null;
- private Subtask subTaskSelected = null;
-
-
- //鐜板満宸℃煡閮ㄥ垎
- private RelativeLayout rl_content;
- private TextureMapView tmv_main;
- private ViewPager vp_icons;
- private LinearLayout ll_show;
- private LinearLayout ll_hide;
- private LinearLayout ll_icons;
- private ImageView iv_pointer;
- private LinearLayout ll_showHideDetail;
- private ImageView iv_showHideDetail;
- private LinearLayout ll_taskDetail;
- private ImageView iv_back;
- private ImageView iv_startEndTask;
- private AMap aMap;
- private MapView mv_main;
- private boolean hidden = false;
- private TextView tv_subTaskNameBar;
- private TextView tv_subTaskStatusBar;
- private String subTaskStatusCurrent = "";
- private final String subTaskNotStart = "鏈墽琛�";
- private final String subTaskRunning = "姝e湪鎵ц";
- private final String subTaskEnd = "宸茬粨鏉�";
- private final float banAlpha = 0.2f;
- private Scense scenseCurrent;
- private Site siteCurrent;
- private Inspection inspectionCurrent;
- private String scenseType = "";
- private final String site = "宸ュ湴";
- private InspectionVo inspectionVoCurrent;
- private double latitudeCurrent = -1;
- private double longitudeCurrent = -1;
- private List<Integer> problemNowMarkerList;
- private List<ProblemlistVo> problemListVoListCurrent = new ArrayList<>();
-
- private LinearLayout ll_problemRecheck;
- private LinearLayout ll_takeEvidence;
- private LinearLayout ll_problemList;
- private LinearLayout ll_problemChange;
- private LinearLayout ll_camera;
- private LinearLayout ll_newGit;
- private LinearLayout ll_promise;
- private LinearLayout ll_evaluation;
- private LinearLayout ll_navi;
- private LinearLayout ll_choseLatlng;
- private LinearLayout ll_editeScence;
- //浠诲姟鍜屽伐鍦拌鎯�
- private TextView tv_detailTaskName;
- private TextView tv_detailTaskType;
- private TextView tv_detailPlanTime;
- private TextView tv_detailExecuteTime;
- private TextView tv_detailExecutors;
- private TextView tv_detailScenseName;
- private TextView tv_detailScenseType;
- private TextView tv_detailScenseAddress;
- private TextView tv_detailContact1;
- private TextView tv_detailContact2;
- private TextView tv_callContact1;
- private TextView tv_callContact2;
-
- //闂鍙栬瘉鐩稿叧
- private ImageView miv_add_photo1;
- private ImageView miv_add_photo2;
- private ImageView miv_add_photo3;
- private List<File> pathTempList;
-
- private final int PHOTO1 = 0;
- private final int PHOTO2 = 1;
- private final int PHOTO3 = 2;
-
- private final int TAKE_PHOTO1 = 0;
- private final int TAKE_PHOTO2 = 1;
- private final int TAKE_PHOTO3 = 2;
-
- private final int PICK_PHOTO1 = 10;
- private final int PICK_PHOTO2 = 11;
- private final int PICK_PHOTO3 = 12;
-
- private File tempFileCurrent;
-
- private final int SHOW_PHOTO = 87;
- private final int DELETE_SUCCESS = 88;
-
- public static final int PROBLEM_LIST = 100;
- public static final int PROBLEM_CHANGE = 101;
- public static final int PROBLEM_RECHECK = 102;
- private int OPEN_TYPE = PROBLEM_LIST;
-
- private final int PROBLEM_DETAIL = 105;
-
- private boolean problemEditable = false;
- private final int SIGN = 9;
-
- private final int BUSSINESS_TYPE_SIGN = 6;
- private final int BUSSINESS_TYPE_CAMERA = 5;
-
- private final int SUBTASK_MAP = 200;
- private final int CHOSE_LATLNG = 201;
- private final int PROMISE = 202;
- private ImageView iv_upload;
- private ProblemListAdapter problemListAdapter = null;
-
- //浠绘剰鎷嶇収
- private ImageView iv_cameraPhoto1;
- private ImageView iv_cameraPhoto2;
- private ImageView iv_cameraPhoto3;
- private List<ImageView> ivCameraList;
- private final int CAMERA_PHOTO = 110;
- private final int TAKE_CAMERA_PHOTO = 111;
- private final int PICK_CAMERA_PHTOO = 112;
- //鏂板鎶�闃叉帾鏂�
- private ImageView iv_gitPhoto1;
- private ImageView iv_gitPhoto2;
- private ImageView iv_gitPhoto3;
- private List<ImageView> ivGitList;
- private final int GIT_PHOTO = 113;
- private final int TAKE_GIT_PHOTO = 114;
- private final int PICK_GIT_PHOTO = 115;
- //鍥剧墖娴忚鐩稿叧
- private final int VIEW_CAMERA_PHOTO = 116;
- private final int VIEW_SIGN_PHOTO = 117;
- private final int VIEW_EVIDENCE_TEMP_PHOTO = 118;
- private final int VIEW_CAMERA_TEMP_PHOTO = 226;
- private final int VIEW_GIT_TEMP_PHOTO = 227;
-
- private Dialog cameraDialog;
- private FloatingActionButton fab_map;
- private int currentPage;
- private final int TASK_PAGE = 230;
- private final int INSPECTION_PAGE = 231;
-
- private final int EDITE_SCENSE = 232;
-
- //鍔犺浇寮瑰嚭妗�
- private Dialog dialog;
-
- //婊戝姩鍒犻櫎
- private WItemTouchHelperPlus extension;
-
-
- public InspectionFragment() {
- // Required empty public constructor
- }
-
- public void loadInspection(Subtask task) {
- subTaskSelected = task;
- if (rl_content != null && !rl_content.isShown()) {
- rl_content.setVisibility(View.VISIBLE);
- }
- if (rl_selectTask != null && rl_selectTask.isShown()) {
- rl_selectTask.setVisibility(View.INVISIBLE);
- }
- loadInspectionData(subTaskSelected.getStguid());
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- Log.e(TAG, "onCreateView()");
- View view = inflater.inflate(R.layout.fragment_inspection, container, false);
- return view;
- }
-
- @Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- Log.e(TAG, "onViewCreated()");
- application = (CommonApplication) getActivity().getApplication();
- currentPage = TASK_PAGE;
- initUI(view);
- initMarkPhotoList();
- initDataBase();
- initDate();
- initData();
- initRecyclerView();
- initSpinnerData();
- refreshUploadIconStatus();
-
- initIconViewPager();
- initMap(savedInstanceState);
- initLocation();
- rl_selectTask.setVisibility(View.VISIBLE);
- rl_content.setVisibility(View.INVISIBLE);
-
- }
-
- /**
- * Called when the fragment is no longer attached to its activity. This
- * is called after {@link #onDestroy()}.
- */
- @Override
- public void onDetach() {
- super.onDetach();
- }
-
-
- //鍒濆鍖栧甫鏁板瓧marker鐨勫垪琛�
- private void initMarkPhotoList() {
- problemNowMarkerList = new ArrayList<>();
- problemNowMarkerList.add(R.drawable.icon_mark1_red);
- problemNowMarkerList.add(R.drawable.icon_mark2_red);
- problemNowMarkerList.add(R.drawable.icon_mark3_red);
- problemNowMarkerList.add(R.drawable.icon_mark4_red);
- problemNowMarkerList.add(R.drawable.icon_mark5_red);
- problemNowMarkerList.add(R.drawable.icon_mark6_red);
- problemNowMarkerList.add(R.drawable.icon_mark7_red);
- problemNowMarkerList.add(R.drawable.icon_mark8_red);
- problemNowMarkerList.add(R.drawable.icon_mark9_red);
- problemNowMarkerList.add(R.drawable.icon_mark10_red);
- problemNowMarkerList.add(R.drawable.icon_mark11_red);
- problemNowMarkerList.add(R.drawable.icon_mark12_red);
- problemNowMarkerList.add(R.drawable.icon_mark13_red);
- problemNowMarkerList.add(R.drawable.icon_mark14_red);
- problemNowMarkerList.add(R.drawable.icon_mark15_red);
- problemNowMarkerList.add(R.drawable.icon_mark16_red);
- problemNowMarkerList.add(R.drawable.icon_mark17_red);
- problemNowMarkerList.add(R.drawable.icon_mark18_red);
- problemNowMarkerList.add(R.drawable.icon_mark19_red);
- problemNowMarkerList.add(R.drawable.icon_mark20_red);
- problemNowMarkerList.add(R.drawable.icon_mark21_red);
- problemNowMarkerList.add(R.drawable.icon_mark22_red);
- problemNowMarkerList.add(R.drawable.icon_mark23_red);
- problemNowMarkerList.add(R.drawable.icon_mark24_red);
- problemNowMarkerList.add(R.drawable.icon_mark25_red);
- problemNowMarkerList.add(R.drawable.icon_mark26_red);
- problemNowMarkerList.add(R.drawable.icon_mark27_red);
- problemNowMarkerList.add(R.drawable.icon_mark28_red);
- problemNowMarkerList.add(R.drawable.icon_mark29_red);
- problemNowMarkerList.add(R.drawable.icon_mark30_red);
- }
-
- private void initUI(View view) {
- //浠诲姟閫夋嫨閮ㄥ垎
- rl_selectTask = (RelativeLayout) view.findViewById(R.id.rl_select_Task);
- mCalendarView = (CalendarView) view.findViewById(R.id.calendarView);
- mCalendarView.setOnCalendarSelectListener(this);
- fab_map = (FloatingActionButton) view.findViewById(R.id.fab_map);
- fab_map.setOnClickListener(this);
-
- tv_title = (TextView) view.findViewById(R.id.tv_title);
- sp_selectMonthTask = (Spinner) view.findViewById(R.id.sp_select_month_task);
- rv_subTaskList = (RecyclerView) view.findViewById(R.id.recyclerView);
-
- //鐜板満宸℃煡閮ㄥ垎
- rl_content = (RelativeLayout) view.findViewById(R.id.rl_content);
- vp_icons = (ViewPager) view.findViewById(R.id.vp_patrol_icons);
- ll_icons = (LinearLayout) view.findViewById(R.id.ll_patrol_icons);
- ll_show = (LinearLayout) view.findViewById(R.id.ll_patrol_show);
- ll_hide = (LinearLayout) view.findViewById(R.id.ll_patrol_hide);
- iv_pointer = (ImageView) view.findViewById(R.id.iv_patrol_pointer);
- ll_showHideDetail = (LinearLayout) view.findViewById(R.id.ll_show_hide_detail);
- iv_showHideDetail = (ImageView) view.findViewById(R.id.iv_patrol_show_site_detail);
- ll_taskDetail = (LinearLayout) view.findViewById(R.id.ll_patrol_task_detail);
- iv_back = (ImageView) view.findViewById(R.id.iv_patrol_back);
- iv_startEndTask = (ImageView) view.findViewById(R.id.iv_start_end_task);
- mv_main = (MapView) view.findViewById(R.id.mv_main);
- tv_subTaskNameBar = (TextView) view.findViewById(R.id.tv_subtask_name_bar);
- tv_subTaskStatusBar = (TextView) view.findViewById(R.id.tv_subtask_status_bar);
- tv_detailTaskName = (TextView) view.findViewById(R.id.tv_subtask_name);
- tv_detailTaskType = (TextView) view.findViewById(R.id.tv_subtask_type);
- tv_detailPlanTime = (TextView) view.findViewById(R.id.tv_subtask_plan_time);
- tv_detailExecuteTime = (TextView) view.findViewById(R.id.tv_subtask_execute_time);
- tv_detailExecutors = (TextView) view.findViewById(R.id.tv_subtask_executors);
- tv_detailScenseName = (TextView) view.findViewById(R.id.tv_scense_name);
- tv_detailScenseType = (TextView) view.findViewById(R.id.tv_scense_type);
- tv_detailScenseAddress = (TextView) view.findViewById(R.id.tv_scense_address);
- tv_detailContact1 = (TextView) view.findViewById(R.id.tv_scense_contact1);
- tv_detailContact2 = (TextView) view.findViewById(R.id.tv_scense_contact2);
- iv_upload = (ImageView) view.findViewById(R.id.iv_upload);
- tv_callContact1 = (TextView) view.findViewById(R.id.tv_call_contact1);
- tv_callContact2 = (TextView) view.findViewById(R.id.tv_call_contact2);
-
- ll_show.setOnClickListener(this);
- ll_hide.setOnClickListener(this);
- ll_showHideDetail.setOnClickListener(this);
- iv_back.setOnClickListener(this);
- iv_upload.setOnClickListener(this);
-
- ll_taskDetail.setVisibility(View.GONE);
-
-
- }
-
- //鍒濆鍖栨暟鎹簱
- private void initDataBase() {
- DaoSession daoSession = application.getDaoSession();
- scenseDao = daoSession.getScenseDao();
- siteDao = daoSession.getSiteDao();
- domaincatalogDao = daoSession.getDomaincatalogDao();
- domainitemDao = daoSession.getDomainitemDao();
- evaluationruleDao = daoSession.getEvaluationruleDao();
- evaluationsubruleDao = daoSession.getEvaluationsubruleDao();
- gittypeDao = daoSession.getGittypeDao();
- problemtypeDao = daoSession.getProblemtypeDao();
- mediafileDao = daoSession.getMediafileDao();
-
- dbSource = DbLink.getDbSource(application);
- }
-
- //鍒濆鍖栨椂闂村拰鏃ュ巻
- private void initDate() {
- tv_title.setText(mCalendarView.getCurYear() + "骞�" + mCalendarView.getCurMonth() + "鏈�");
- lastMonthCalender = java.util.Calendar.getInstance();
- calendarCurrent = java.util.Calendar.getInstance();
-
- }
-
- //鍒濆鍖栨暟鎹�
- private void initData() {
- taskAllMapList = new HashMap<>();
- subTaskListCurrent = new ArrayList<>();
-
- inspectionService = application.getRetrofit().create(InspectionService.class);
- inspectionImageService = application.getRetrofitImage().create(InspectionImageService.class);
- subTaskService = application.getRetrofit().create(SubTaskService.class);
- String yearMonth = DateFormatter.YearMonthFormat.format(new Date());
- getThreeMonthTask(yearMonth, "Middle", false);
- }
-
- //鎵撶數璇�
- private View.OnClickListener callClikeListner(final String tele) {
- View.OnClickListener onClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + tele));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- }
- };
- return onClickListener;
- }
-
- private void refreshUploadIconStatus() {
- List<Mediafile> mediafileList = mediafileDao.queryBuilder().where(MediafileDao.Properties.Remark.eq("鏈笂浼�")).list();
- if (mediafileList != null && mediafileList.size() > 0) {
- iv_upload.setSelected(true);
- } else {
- iv_upload.setSelected(false);
- }
- }
-
- //鑱旂綉鑾峰緱涓変釜鏈堢殑浠诲姟淇℃伅
- private void getThreeMonthTask(final String yearMonth, final String type, final boolean clearMap) {
- showLoadingDialog();
- Call<List<TaskPack>> loadThreeMonthTasks = inspectionService.loadThreeMonthTasks(yearMonth, application.getCurrentUser().getGuid(), type, String.valueOf(application.getCurrentUser().getUsertypeid()));
- loadThreeMonthTasks.enqueue(new Callback<List<TaskPack>>() {
- @Override
- public void onResponse(Call<List<TaskPack>> call, Response<List<TaskPack>> response) {
-
- if (response.body() != null) {
- requestAgain = false;
- List<TaskPack> taskPackList = response.body();
- if (clearMap) {
- taskAllMapList.clear();
- }
- if (taskPackList != null && taskPackList.size() > 0) {
- for (TaskPack taskPack : taskPackList) {
- taskAllMapList.put(taskPack.getDate(), taskPack.getUpperTaskList());
- }
- if (type.equals("Middle")) {
- showMonthAllTask(calendarCurrent);
- }
-
-
- }
- loadingOver(true);
- } else if (response.errorBody() != null) {
- if (!requestAgain) {
- requestAgain = true;
- getThreeMonthTask(yearMonth, type, clearMap);
- } else {
- loadingOver(false);
- Toast.makeText(application, "鑾峰彇浠诲姟淇℃伅鍑洪敊", Toast.LENGTH_SHORT).show();
- showMonthAllTask(calendarCurrent);
- }
- System.out.println("ThreeMonthTask:" + response.errorBody());
- }
-
- }
-
- @Override
- public void onFailure(Call<List<TaskPack>> call, Throwable t) {
- if (!requestAgain) {
- requestAgain = true;
- getThreeMonthTask(yearMonth, type, clearMap);
- } else {
- loadingOver(false);
- Toast.makeText(application, "缃戠粶閾炬帴澶辫触", Toast.LENGTH_SHORT).show();
- showMonthAllTask(calendarCurrent);
- }
- System.out.println("ThreeMonthTask:" + t.toString());
- }
- });
- }
-
- //鏄剧ず褰撳墠鏈堢殑鏈堜换鍔″垪琛�(鏃ュ巻涓婄殑鏍囨敞浜ょ粰spinner鎿嶄綔)
- private void showMonthAllTask(java.util.Calendar calendarCurrent) {
- monthTaskListCurrent = new ArrayList<>();
- monthTaskStringListCurrent = new ArrayList<>();
- dayTaskTimeList = new ArrayList<>();
- subTaskMapCurrent = new HashMap<>();
- String currentMonth = DateFormatter.YearMonthFormat.format(calendarCurrent.getTime());
- List<TaskVo> taskVoList = taskAllMapList.get(currentMonth);
-
- if (taskVoList != null && taskVoList.size() > 0) {
- monthTaskStringListCurrent.add("鍏ㄩ儴浠诲姟");
- monthTaskListCurrent.addAll(taskVoList);
- for (TaskVo monthTask : taskVoList) {
-// monthTaskListCurrent.add(monthTask);
- monthTaskStringListCurrent.add(monthTask.getName());
- }
- } else {
- monthTaskStringListCurrent.add("鏃犱换鍔�");
- }
- selectMonthTaskAdapter = new ArrayAdapter(getContext(), R.layout.item_spinner_drop_down, monthTaskStringListCurrent);
- sp_selectMonthTask.setAdapter(selectMonthTaskAdapter);
-
- }
-
- //鏄剧ず褰撴湀鏃ユ暟鎹拰鍘嗘爣娉�
- private void showOneMonthAllTask2(java.util.Calendar calendarCurrent) {
- String currentMonth = DateFormatter.YearMonthFormat.format(calendarCurrent.getTime());
- if (subTaskMapCurrent != null) {
- List<TaskVo> taskVoList = taskAllMapList.get(currentMonth);
-
- if (taskVoList != null && taskVoList.size() > 0) {
- for (TaskVo monthTask : taskVoList) {
- getOneMonthTaskAllData(monthTask);
- }
- }
- addScheme(dayTaskTimeList);
- }
- }
-
- //鏄剧ず涓�涓湀浠诲姟鐨勬暟鎹拰鏃ュ巻鏍囨敞锛圫pinner閫夋嫨涓�涓湀浠诲姟鍚庣殑鎿嶄綔锛�
- private void showOneMonthTask(TaskVo monthTask) {
- getOneMonthTaskAllData(monthTask);
- addScheme(dayTaskTimeList);
- }
-
- //鑾峰彇涓�涓湀浠诲姟鐨勫叏閮ㄦ暟鎹�
- private void getOneMonthTaskAllData(TaskVo monthTask) {
- List<TaskVo> dayTaskList = monthTask.getDaytaskList();
- if (dayTaskList != null && dayTaskList.size() > 0) {
- for (TaskVo dayTask : dayTaskList) {
- java.util.Calendar calendar = java.util.Calendar.getInstance();
- calendar.setTime(dayTask.getStarttime());
- int day = calendar.get(java.util.Calendar.DAY_OF_MONTH);
- dayTaskTimeList.add(day);
-
- List<Subtask> subTaskList = dayTask.getSubtaskList();
- if (subTaskList != null && subTaskList.size() > 0) {
- if (subTaskMapCurrent.containsKey(day)) {
- subTaskMapCurrent.get(day).addAll(subTaskList);
- } else {
- List<Subtask> subtasks = new ArrayList<>();
- subtasks.addAll(subTaskList);
- subTaskMapCurrent.put(day, subtasks);
- }
- }
- }
- } else {
-
- }
- }
-
- //璺熸嵁鏃ユ湡鏄剧ず閭eぉ鐨勫瓙浠诲姟
- private void showSubTaskByDay(int day) {
- if (application.isDebugMode()) {
- subTaskListCurrent.removeAll(subTaskListCurrent);
- Subtask subtask = new Subtask();
- subtask.setStguid(UUIDGenerator.generate16ShortUUID());
- subtask.setName("宸℃煡闀块鐢熸�佸晢鍔″尯10鍙峰寳鍦板潡浜屾湡锛堝寳鍖猴級鏂板缓宸ョ▼");
- int typeno = 1;
- subtask.setTypeno((byte) typeno);
- subtask.setType("宸℃煡");
- subtask.setScenseid("Y0TdY7cjFHcVJCIf");
- subtask.setScensename("闀块鐢熸�佸晢鍔″尯10鍙峰寳鍦板潡浜屾湡锛堝寳鍖猴級鏂板缓宸ョ▼");
- subtask.setScenseaddress("鍚屾櫘璺� 娉稿畾璺�");
- subtask.setProvincename("涓婃捣甯�");
- subtask.setCityname("涓婃捣甯�");
- subtask.setDistrictname("鏅檧鍖�");
- java.util.Calendar startTime = java.util.Calendar.getInstance();
- startTime.set(2018, 1, 18);
- java.util.Calendar endTime = java.util.Calendar.getInstance();
- endTime.set(2018, 1, 18);
- subtask.setPlanstarttime(startTime.getTime());
- subtask.setPlanendtime(endTime.getTime());
- subtask.setExecutorguids("Kmi6GJoee93KzWfm");
- subtask.setExecutorusernames("chenchong");
- subtask.setExecutorrealtimes("闄堝啿");
- subtask.setStatus("鏈墽琛�");
- subTaskListCurrent.add(subtask);
-
- subtask = new Subtask();
- subtask.setStguid(UUIDGenerator.generate16ShortUUID());
- subtask.setName("宸℃煡閲戝北浜灄澶у瀷灞呬綇鍖哄競鏀块亾璺」鐩灄鍚夎矾锛堣溅浜叕璺�-绾㈡璺級");
- typeno = 1;
- subtask.setTypeno((byte) typeno);
- subtask.setType("宸℃煡");
- subtask.setScenseid("XvQio9lWSMFguTob");
- subtask.setScensename("閲戝北浜灄澶у瀷灞呬綇鍖哄競鏀块亾璺」鐩灄鍚夎矾锛堣溅浜叕璺�-绾㈡璺級");
- subtask.setScenseaddress("浜灄闀囨灄鍚夎矾");
- subtask.setProvincename("涓婃捣甯�");
- subtask.setCityname("涓婃捣甯�");
- subtask.setDistrictname("閲戝北鍖�");
- startTime = java.util.Calendar.getInstance();
- startTime.set(2018, 1, 20, 10, 20);
- endTime = java.util.Calendar.getInstance();
- endTime.set(2018, 1, 20, 11, 30);
- subtask.setPlanstarttime(startTime.getTime());
- subtask.setPlanendtime(endTime.getTime());
- subtask.setExecutorguids("Kmi6GJoee93KzWfm");
- subtask.setExecutorusernames("chenchong");
- subtask.setExecutorrealtimes("闄堝啿");
- subtask.setStatus("姝e湪鎵ц");
- subTaskListCurrent.add(subtask);
-
- subtask = new Subtask();
- subtask.setStguid(UUIDGenerator.generate16ShortUUID());
- subtask.setName("宸℃煡闈欏畨鍖哄ぇ瀹佽矾琛楅亾325琛楀潑鍦板潡浣忓畢椤圭洰");
- typeno = 1;
- subtask.setTypeno((byte) typeno);
- subtask.setType("宸℃煡");
- subtask.setScenseid("ZjTy9pdMPUmAgltG");
- subtask.setScensename("闈欏畨鍖哄ぇ瀹佽矾琛楅亾325琛楀潑鍦板潡浣忓畢椤圭洰");
- subtask.setScenseaddress("褰睙璺紝骞冲瀷鍏宠矾浜ゅ弶鍙�");
- subtask.setProvincename("涓婃捣甯�");
- subtask.setCityname("涓婃捣甯�");
- subtask.setDistrictname("闈欏畨鍖�");
- startTime = java.util.Calendar.getInstance();
- startTime.set(2018, 1, 23, 15, 10);
- endTime = java.util.Calendar.getInstance();
- endTime.set(2018, 1, 23, 16, 30);
- subtask.setPlanstarttime(startTime.getTime());
- subtask.setPlanendtime(endTime.getTime());
- subtask.setExecutorguids("Kmi6GJoee93KzWfm");
- subtask.setExecutorusernames("chenchong");
- subtask.setExecutorrealtimes("闄堝啿");
- subtask.setStatus("宸茬粨鏉�");
- subTaskListCurrent.add(subtask);
- } else {
- if (subTaskMapCurrent != null) {
- List<Subtask> subTaskList = subTaskMapCurrent.get(day);
- subTaskListCurrent.clear();
- if (subTaskList != null && subTaskList.size() > 0) {
- for (Subtask subtask : subTaskList) {
- if (!subTaskListCurrent.contains(subtask)) {
- subTaskListCurrent.add(subtask);
- }
- }
-
- }
- if (subTaskListCurrent.size() > 0) {
- if (rl_content.getVisibility() != View.VISIBLE) {
- fab_map.show();
- }
- } else {
- fab_map.hide();
- }
- }
-
- }
-
- subTaskListAdapter.notifyDataSetChanged();
- }
-
- //璁剧疆spinner鐨勭偣鍑讳簨浠�
- private void initSpinnerData() {
- sp_selectMonthTask.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- //灏嗛�変腑鐨勬枃瀛楀彉涓虹櫧鑹�
- CheckedTextView tv = (CheckedTextView) view.findViewById(view.getId());
- tv.setTextColor(getContext().getResources().getColor(R.color.white));
- //閫夋嫨鍚庢竻绌烘暟鎹噸鏂拌鍙�
- dayTaskTimeList = new ArrayList<Integer>();
- subTaskMapCurrent = new HashMap<Integer, List<Subtask>>();
- if (position == 0) {
- showOneMonthAllTask2(calendarCurrent);
- showSubTaskByDay(calendarCurrent.get(java.util.Calendar.DAY_OF_MONTH));
- } else {
- monthTaskSelected = monthTaskListCurrent.get(position - 1);
- showOneMonthTask(monthTaskSelected);
- showSubTaskByDay(calendarCurrent.get(java.util.Calendar.DAY_OF_MONTH));
- }
-
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
-
- }
- });
-
- }
-
- //鍒濆鍖栧瓙浠诲姟鍒楄〃
- private void initRecyclerView() {
- LinearLayoutManager manager = new LinearLayoutManager(getContext());
- rv_subTaskList.setLayoutManager(manager);
-
- subTaskListAdapter = new TaskListAdapter(getContext(), subTaskListCurrent);
- subTaskListAdapter.setOnDeleteListener(new OnDeleteListener() {
- @Override
- public void delete(final int position) {
- Call<ResponseBody> deleteSubTask = subTaskService.deleteSubTask(subTaskListCurrent.get(position).getStguid());
- deleteSubTask.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body() != null) {
- subTaskListAdapter.notifyItemRemoved(position);
- subTaskListAdapter.notifyItemRangeChanged(position, subTaskListCurrent.size() - position);
- subTaskListCurrent.remove(position);
- showToast("鍒犻櫎鎴愬姛");
- String yearMonth = DateFormatter.YearMonthFormat.format(new Date());
- getThreeMonthTask(yearMonth, "Middle", false);
- } else {
- showToast("鍒犻櫎澶辫触");
- }
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
-
- }
- });
- }
- });
-
- subTaskListAdapter.setOnItemClickListener(new OnSwipeItemClickListener() {
-
- @Override
- public void click(int position) {
- subTaskSelected = subTaskListCurrent.get(position);
- loadInspectionData(subTaskSelected.getStguid());
- }
- });
- rv_subTaskList.setAdapter(subTaskListAdapter);
- //2019.1.23 by riku 娣诲姞婊戝姩鍒犻櫎鍔熻兘
- if (application.getCurrentUser().getUsertypeid() == 0) {
- PlusItemSlideCallback callback = new PlusItemSlideCallback(WItemTouchHelperPlus.SLIDE_ITEM_TYPE_ITEMVIEW);
- extension = new WItemTouchHelperPlus(callback);
- extension.attachToRecyclerView(rv_subTaskList);
- }
- }
-
- //鍒濆鍖栧姛鑳介潰鐗坴iewpager
- private void initIconViewPager() {
- ll_show.setVisibility(View.INVISIBLE);
- View iconPage1 = View.inflate(getContext(), R.layout.page_patrol_icons_first, null);
- View iconPage2 = View.inflate(getContext(), R.layout.page_patrol_icons_second, null);
- ll_problemRecheck = (LinearLayout) iconPage1.findViewById(R.id.ln_patrol_problem_recheck);
- ll_takeEvidence = (LinearLayout) iconPage1.findViewById(R.id.ln_patrol_take_evidence);
- ll_problemList = (LinearLayout) iconPage1.findViewById(R.id.ln_patrol_problem_list);
- ll_problemChange = (LinearLayout) iconPage1.findViewById(R.id.ln_patrol_change);
- ll_camera = (LinearLayout) iconPage1.findViewById(R.id.ln_patrol_camera);
- ll_newGit = (LinearLayout) iconPage1.findViewById(R.id.ln_patrol_newgit);
- ll_promise = (LinearLayout) iconPage1.findViewById(R.id.ln_patrol_promiss);
- ll_evaluation = (LinearLayout) iconPage1.findViewById(R.id.ln_patrol_rate);
- ll_navi = (LinearLayout) iconPage2.findViewById(R.id.ln_patrol_navi);
- ll_choseLatlng = (LinearLayout) iconPage2.findViewById(R.id.ln_patrol_chose_latlng);
- ll_editeScence = (LinearLayout) iconPage2.findViewById(R.id.ln_patrol_edit);
- List<View> viewList = new ArrayList<>();
- viewList.add(iconPage1);
- viewList.add(iconPage2);
-
- IconsPageAdapter adapter = new IconsPageAdapter(viewList);
- vp_icons.setAdapter(adapter);
- vp_icons.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
- @Override
- public void onPageSelected(int position) {
- //褰撻〉闈㈡敼鍙樻椂锛屽垏鎹㈠埌瀵瑰簲鐨勫皬鍦嗙偣
- if (position == 0) {
- iv_pointer.setImageResource(R.drawable.select_first_point);
- } else if (position == 1) {
- iv_pointer.setImageResource(R.drawable.select_second_point);
- }
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
- });
-
- }
-
- //鏍规嵁鏃ユ湡鍒楄〃娣诲姞鍏ㄩ儴鏍囪鐐�
- private void addScheme(List<Integer> dayTaskTimeList) {
- schemes = new HashMap<>();
- if (dayTaskTimeList != null && dayTaskTimeList.size() > 0) {
- for (Integer day : dayTaskTimeList) {
- Calendar c = getSchemeCalendar(calendarCurrent.get(java.util.Calendar.YEAR), (calendarCurrent.get(java.util.Calendar.MONTH) + 1), day, 0xFFdf1356, false);
- schemes.put(c.toString(), c);
- }
- }
- mCalendarView.setSchemeDate(schemes);
- }
-
-
- //娣诲姞鏍囪鐐�
- private Calendar getSchemeCalendar(int year, int month, int day, int color, boolean schemeCompleted) {
- Calendar calendar = new Calendar();
- calendar.setYear(year);
- calendar.setMonth(month);
- calendar.setDay(day);
- calendar.setSchemeColor(color);//濡傛灉鍗曠嫭鏍囪棰滆壊銆佸垯浼氫娇鐢ㄨ繖涓鑹�
- calendar.setScheme("璁�");
- return calendar;
- }
-
- //鍒濆鍖栧湴鍥�
- private void initMap(Bundle savedInstanceState) {
- mv_main.onCreate(savedInstanceState);
- aMap = mv_main.getMap();
- aMap.setRenderFps(60);
- aMap.getUiSettings().setZoomControlsEnabled(false);
- aMap.getUiSettings().setScaleControlsEnabled(true);
- //鐐瑰嚮marker璺宠浆鍒伴棶棰樿鎯�
- aMap.setOnMarkerClickListener(new AMap.OnMarkerClickListener() {
- @Override
- public boolean onMarkerClick(Marker marker) {
- String guid = marker.getSnippet();
- if (guid != null && guid.length() > 0) {
- Intent intent = new Intent(getActivity(), ProblemDetailActivity.class);
- ProblemlistVo problemlistVo = null;
- for (int i = 0; i < problemListVoListCurrent.size(); i++) {
- if (problemListVoListCurrent.get(i).getGuid().equals(guid)) {
- problemlistVo = problemListVoListCurrent.get(i);
- }
- }
- intent.putExtra("problemlistVo", problemlistVo);
- intent.putExtra("subTaskSelected", subTaskSelected);
- intent.putExtra("scenseLat", scenseCurrent.getLatitude());
- intent.putExtra("scenseLng", scenseCurrent.getLongitude());
- intent.putExtra("editable", problemEditable);
- intent.putExtra("type", PROBLEM_LIST);
- startActivity(intent);
- }
- return false;
- }
- });
-
- }
-
- //鑱旂綉鍔犺浇宸℃煡淇℃伅
- private void loadInspectionData(final String subTaskId) {
- showLoadingDialog();
- if (inspectionService == null)
- inspectionService = application.getRetrofit().create(InspectionService.class);
- Call<InspectionVo> loadallInspectionData = inspectionService.loadInspectionData(subTaskId);
- loadallInspectionData.enqueue(new Callback<InspectionVo>() {
- @Override
- public void onResponse(Call<InspectionVo> call, Response<InspectionVo> response) {
- if (response.body() != null) {
- inspectionVoCurrent = response.body();
- inspectionCurrent = transInspectionVo(inspectionVoCurrent);
- initInspectionData();
-
- fab_map.hide();
- showIcons();
- rl_content.setVisibility(View.VISIBLE);
- rl_selectTask.setVisibility(View.INVISIBLE);
- loadingOver(true);
- } else if (response.errorBody() != null) {
- if (!requestAgain) {
- requestAgain = true;
- loadInspectionData(subTaskId);
- } else {
- loadingOver(false);
- Toast.makeText(application, "鑾峰彇宸℃煡淇℃伅澶辫触", Toast.LENGTH_SHORT).show();
- System.out.println("loadInspectionData:" + response.errorBody().toString());
- }
- }
- }
-
- @Override
- public void onFailure(Call<InspectionVo> call, Throwable t) {
- if (!requestAgain) {
- requestAgain = true;
- loadInspectionData(subTaskId);
- } else {
- loadingOver(false);
- Toast.makeText(application, "鑱旂綉澶辫触", Toast.LENGTH_SHORT).show();
- System.out.println("loadInspectionData:" + t.toString());
- }
- }
- });
- }
-
- private Inspection transInspectionVo(InspectionVo inspectionVo) {
- Inspection inspection = new Inspection();
- inspection.setGuid(inspectionVo.getGuid());
- inspection.setStguid(inspectionVo.getStguid());
- inspection.setSguid(inspectionVo.getSguid());
- inspection.setScensename(inspectionVo.getScensename());
- inspection.setScenseaddress(inspectionVo.getScenseaddress());
- inspection.setIstogether(inspectionVo.getIstogether());
- inspection.setEntouraget(inspectionVo.getEntouraget());
- inspection.setEntouragewx(inspectionVo.getEntouragewx());
- inspection.setEntourage(inspectionVo.getEntourage());
- inspection.setExecutionstarttime(inspectionVo.getExecutionstarttime());
- inspection.setExecutionendtime(inspectionVo.getExecutionendtime());
- inspection.setProblemcount(inspectionVo.getProblemcount());
- inspection.setIsrechecked(inspectionVo.getIsrechecked());
- inspection.setRecheckcount(inspectionVo.getRecheckcount());
- inspection.setPromissednum(inspectionVo.getPromissednum());
- inspection.setChangednum(inspectionVo.getChangednum());
- inspection.setChangednum(inspectionVo.getChangednum());
- inspection.setIschanged(inspectionVo.getIschanged());
- inspection.setIsrvaluated(inspectionVo.getIsrvaluated());
- inspection.setIspromissed(inspectionVo.getIspromissed());
- inspection.setPromissedtime(inspectionVo.getPromissedtime());
- inspection.setPromisseduserguid(inspectionVo.getPromisseduserguid());
- inspection.setPromissedusername(inspectionVo.getPromissedusername());
- inspection.setPromisseduserrealname(inspectionVo.getPromisseduserrealname());
- inspection.setPromissedway(inspectionVo.getPromissedway());
- inspection.setPromisseddeadline(inspectionVo.getPromisseddeadline());
- inspection.setPromissbookpath(inspectionVo.getPromissbookpath());
- inspection.setSignpath(inspectionVo.getSignpath());
- inspection.setExtension1(inspectionVo.getExtension1());
- inspection.setExtension2(inspectionVo.getExtension2());
- inspection.setExtension3(inspectionVo.getExtension3());
- inspection.setRemark(inspectionVo.getRemark());
- return inspection;
- }
-
- //鍒濆鍖栧贰鏌ョ殑鍩烘湰淇℃伅
- private void initInspectionData() {
- if (application.isDebugMode()) {
- inspectionCurrent = new Inspection();
- inspectionCurrent.setGuid(UUIDGenerator.generate16ShortUUID());
- inspectionCurrent.setStguid(subTaskSelected.getStguid());
- inspectionCurrent.setSguid(subTaskSelected.getScenseid());
- inspectionCurrent.setScensename(subTaskSelected.getScensename());
- inspectionCurrent.setScenseaddress(subTaskSelected.getScenseaddress());
- inspectionCurrent.setProblemcount(0);
- inspectionCurrent.setChangednum(0);
- }
- tv_subTaskNameBar.setText(subTaskSelected.getName());
- currentPage = INSPECTION_PAGE;
- aMap.clear();
- subTaskStatusCurrent = subTaskSelected.getStatus();
- switch (subTaskStatusCurrent) {
- case subTaskNotStart:
- iv_startEndTask.setSelected(false);
- break;
- case subTaskRunning:
- iv_startEndTask.setSelected(true);
- break;
- case subTaskEnd:
- iv_startEndTask.setSelected(true);
- }
- updateStatus();
- //2019.1.4 by riku: 娣诲姞 鐢ㄦ埛绫诲瀷涓衡�滀富绠¢儴闂ㄢ�濇垨鈥滅鐞嗗憳鈥濓紝缂栧彿涓�2鎴�0鏃讹紝鎸夐挳iv_startEndTask娌℃湁鐐瑰嚮浜嬩欢
- if (application.getCurrentUser().getUsertypeid() != 2 || application.getCurrentUser().getUsertypeid() != 0) {
- iv_startEndTask.setOnClickListener(this);
- } else {
- iv_startEndTask.setAlpha(0.5f);
- }
- scenseCurrent = scenseDao.queryBuilder().where(ScenseDao.Properties.Guid.eq(subTaskSelected.getScenseid())).unique();
- scenseType = scenseCurrent.getType();
- switch (scenseType) {
- case site:
- siteCurrent = siteDao.queryBuilder().where(SiteDao.Properties.Sguid.eq(subTaskSelected.getScenseid())).unique();
- break;
- }
- tv_detailTaskName.setText(subTaskSelected.getName());
- tv_detailTaskType.setText(subTaskSelected.getType());
- java.util.Calendar planStartTime = java.util.Calendar.getInstance();
- planStartTime.setTime(subTaskSelected.getPlanstarttime());
- java.util.Calendar planEndTime = java.util.Calendar.getInstance();
- planEndTime.setTime(subTaskSelected.getPlanendtime());
- if (planStartTime.get(java.util.Calendar.YEAR) == planEndTime.get(java.util.Calendar.YEAR) &&
- planStartTime.get(java.util.Calendar.MONTH) == planEndTime.get(java.util.Calendar.MONTH) &&
- planStartTime.get(java.util.Calendar.DAY_OF_MONTH) == planEndTime.get(java.util.Calendar.DAY_OF_MONTH)) {
- String text = DateFormatter.dateFormat.format(planStartTime.getTime());
- String startTime = DateFormatter.timeFormat.format(planStartTime.getTime());
- if (startTime.equals("00:00")) {
- tv_detailPlanTime.setText(text);
- } else {
- String endTime = DateFormatter.timeFormat.format(planEndTime.getTime());
- tv_detailPlanTime.setText(text + " " + startTime + " - " + endTime);
- }
- } else {
- String startTime = DateFormatter.dateTimeFormat.format(planStartTime.getTime());
- String endTime = DateFormatter.dateTimeFormat.format(planEndTime.getTime());
- tv_detailPlanTime.setText(startTime + " - " + endTime);
- }
- refreshExecutionTime();
- tv_detailExecutors.setText(subTaskSelected.getExecutorrealtimes().replaceAll(Constant.CONNECTOR, Constant.CONNECTOR_FOR_VIEW));
- tv_detailScenseName.setText(scenseCurrent.getName());
- tv_detailScenseType.setText(scenseCurrent.getType());
- tv_detailScenseAddress.setText(scenseCurrent.getCityname() + scenseCurrent.getDistrictname() + " " + scenseCurrent.getLocation());
- tv_detailContact1.setText(scenseCurrent.getContacts() + " " + scenseCurrent.getContactst());
- tv_detailContact2.setText("");
- tv_callContact1.setOnClickListener(callClikeListner(scenseCurrent.getContactst()));
- refreshProblemMarker();
- //灏嗗満鏅綅缃坊鍔犲埌鍦板浘涓�
- LatLng sourceLatLng = new LatLng(scenseCurrent.getLatitude(), scenseCurrent.getLongitude());
- MarkerOptions options = new MarkerOptions().position(sourceLatLng);
- aMap.addMarker(options);
- aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sourceLatLng, 15f));
-
- }
-
- private void refreshExecutionTime() {
- String executeTime = "";
- if (subTaskSelected.getExecutionstarttime() != null) {
- executeTime = DateFormatter.dateTimeFormat.format(subTaskSelected.getExecutionstarttime());
- } else {
- executeTime = "鏈墽琛�";
- }
- if (subTaskSelected.getExecutionendtime() != null) {
- executeTime = executeTime + " - " + DateFormatter.timeFormat.format(subTaskSelected.getExecutionendtime());
- }
- tv_detailExecuteTime.setText(executeTime);
- }
-
- //鏇存柊鐘舵�佷俊鎭�
- private void updateStatus() {
- tv_subTaskStatusBar.setText(subTaskStatusCurrent);
- setIconsStatus(subTaskStatusCurrent);
- }
-
- //鍒濆鍖栦綅缃�
- public void initLocation() {
- MyLocationStyle myLocationStyle;
- myLocationStyle = new MyLocationStyle();//鍒濆鍖栧畾浣嶈摑鐐规牱寮忕被myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//杩炵画瀹氫綅銆佷笖灏嗚瑙掔Щ鍔ㄥ埌鍦板浘涓績鐐癸紝瀹氫綅鐐逛緷鐓ц澶囨柟鍚戞棆杞紝骞朵笖浼氳窡闅忚澶囩Щ鍔ㄣ�傦紙1绉�1娆″畾浣嶏級濡傛灉涓嶈缃甿yLocationType锛岄粯璁や篃浼氭墽琛屾绉嶆ā寮忋��
- // myLocationStyle.interval(2000); //璁剧疆杩炵画瀹氫綅妯″紡涓嬬殑瀹氫綅闂撮殧锛屽彧鍦ㄨ繛缁畾浣嶆ā寮忎笅鐢熸晥锛屽崟娆″畾浣嶆ā寮忎笅涓嶄細鐢熸晥銆傚崟浣嶄负姣銆�
- myLocationStyle.showMyLocation(true);
- myLocationStyle.radiusFillColor(getResources().getColor(R.color.transparent));
- myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);//杩炵画瀹氫綅銆佽摑鐐逛笉浼氱Щ鍔ㄥ埌鍦板浘涓績鐐癸紝瀹氫綅鐐逛緷鐓ц澶囨柟鍚戞棆杞紝骞朵笖钃濈偣浼氳窡闅忚澶囩Щ鍔�
- aMap.setMyLocationStyle(myLocationStyle);//璁剧疆瀹氫綅钃濈偣鐨凷tyle
- aMap.getUiSettings().setMyLocationButtonEnabled(false);//璁剧疆榛樿瀹氫綅鎸夐挳鏄惁鏄剧ず锛岄潪蹇呴渶璁剧疆銆�
- aMap.setMyLocationEnabled(true);// 璁剧疆涓簍rue琛ㄧず鍚姩鏄剧ず瀹氫綅钃濈偣锛宖alse琛ㄧず闅愯棌瀹氫綅钃濈偣骞朵笉杩涜瀹氫綅锛岄粯璁ゆ槸false銆�
- aMap.setOnMyLocationChangeListener(this);
- }
-
- //鏍规嵁浠诲姟鐘舵�侊紝璁剧疆鍥炬爣闈㈡澘鍔熻兘寮�鍏�
- public void setIconsStatus(String subTaskStatus) {
- switch (subTaskStatus) {
- case subTaskNotStart:
- ll_problemRecheck.setAlpha(banAlpha);
- ll_problemRecheck.setOnClickListener(showNeedStartTaskListener());
- ll_takeEvidence.setAlpha(banAlpha);
- ll_takeEvidence.setOnClickListener(showNeedStartTaskListener());
- ll_problemList.setAlpha(banAlpha);
- ll_problemList.setOnClickListener(showNeedStartTaskListener());
- ll_problemChange.setAlpha(banAlpha);
- ll_problemChange.setOnClickListener(showNeedStartTaskListener());
- ll_camera.setAlpha(banAlpha);
- ll_camera.setOnClickListener(showNeedStartTaskListener());
- ll_newGit.setAlpha(banAlpha);
- ll_newGit.setOnClickListener(showNeedStartTaskListener());
- ll_promise.setAlpha(banAlpha);
- ll_promise.setOnClickListener(showNeedStartTaskListener());
- ll_evaluation.setAlpha(banAlpha);
- ll_evaluation.setOnClickListener(showNeedStartTaskListener());
- ll_navi.setOnClickListener(this);
- ll_choseLatlng.setOnClickListener(this);
- ll_editeScence.setOnClickListener(this);
- break;
- case subTaskRunning:
- ll_problemRecheck.setAlpha(1);
- ll_problemRecheck.setOnClickListener(this);
- ll_takeEvidence.setAlpha(1);
- ll_takeEvidence.setOnClickListener(this);
- ll_problemList.setAlpha(1);
- ll_problemList.setOnClickListener(this);
- ll_problemChange.setAlpha(1);
- ll_problemChange.setOnClickListener(this);
- ll_camera.setAlpha(1);
- ll_camera.setOnClickListener(this);
- ll_newGit.setAlpha(1);
- ll_newGit.setOnClickListener(this);
- ll_promise.setAlpha(1);
- ll_promise.setOnClickListener(this);
- ll_evaluation.setAlpha(1);
- ll_evaluation.setOnClickListener(this);
- ll_navi.setOnClickListener(this);
- ll_choseLatlng.setOnClickListener(this);
- ll_editeScence.setOnClickListener(this);
- break;
- case subTaskEnd:
- ll_problemRecheck.setAlpha(1);
- ll_problemRecheck.setOnClickListener(this);
- ll_takeEvidence.setAlpha(banAlpha);
- ll_takeEvidence.setOnClickListener(null);
- ll_problemList.setAlpha(1);
- ll_problemList.setOnClickListener(this);
- ll_problemChange.setAlpha(1);
- ll_problemChange.setOnClickListener(this);
- ll_camera.setAlpha(1);
- ll_camera.setOnClickListener(this);
- ll_newGit.setAlpha(1);
- ll_newGit.setOnClickListener(this);
- ll_promise.setAlpha(1);
- ll_promise.setOnClickListener(this);
- ll_evaluation.setAlpha(1);
- ll_evaluation.setOnClickListener(this);
- ll_navi.setOnClickListener(this);
- ll_choseLatlng.setOnClickListener(this);
- ll_editeScence.setOnClickListener(this);
- break;
- }
- if (application.getCurrentUser().getUsertypeid() == 2) {
- ll_takeEvidence.setAlpha(banAlpha);
- ll_takeEvidence.setOnClickListener(null);
- ll_problemChange.setAlpha(banAlpha);
- ll_problemChange.setOnClickListener(null);
- ll_camera.setAlpha(banAlpha);
- ll_camera.setOnClickListener(null);
- ll_evaluation.setAlpha(banAlpha);
- ll_evaluation.setOnClickListener(null);
- ll_navi.setAlpha(banAlpha);
- ll_navi.setOnClickListener(null);
- ll_choseLatlng.setAlpha(banAlpha);
- ll_choseLatlng.setOnClickListener(null);
- ll_editeScence.setAlpha(banAlpha);
- ll_editeScence.setOnClickListener(null);
- }
- }
-
- //鏄剧ず璇峰紑濮嬩换鍔$殑OnClickListener
- public View.OnClickListener showNeedStartTaskListener() {
- View.OnClickListener listener = new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
- if (application.getCurrentUser().getUsertypeid() == 2) {
- dialog.setTitle("浠诲姟杩樻湭寮�濮�");
- dialog.setMessage("鏃犲彲鏌ョ湅鐨勮缁嗕俊鎭�");
- } else {
- dialog.setTitle("璇峰厛寮�濮嬩换鍔�");
- dialog.setMessage("鐐瑰嚮鐣岄潰鍙充笂瑙掔殑'寮�濮�'鎸夐挳锛屾潵寮�濮嬩换鍔�");
- }
- dialog.setPositiveButton("纭畾", null);
- dialog.show();
- }
- };
-
- return listener;
- }
-
- //鍚戜笅鏀剁缉鍥炬爣闈㈡澘
- public void hideIcons() {
- ll_icons.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.bottom_menu_exit));
- ll_icons.setVisibility(View.GONE);
- ll_show.setVisibility(View.VISIBLE);
- }
-
- //鍚戜笂鏄剧ず鍥炬爣闈㈡澘
- public void showIcons() {
- ll_icons.setVisibility(View.VISIBLE);
- ll_icons.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.bottom_menu_enter));
- ll_show.setVisibility(View.GONE);
- }
-
- //鍚戜笂鏀剁缉浠诲姟璇︽儏
- private void hideTaskDetail() {
- ll_taskDetail.setVisibility(View.VISIBLE);
- ll_taskDetail.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.top_menu_exit));
- ll_taskDetail.setVisibility(View.GONE);
-
- }
-
- //鍚戜笅鏄剧ず浠诲姟璇︽儏
- private void showTaskDetail() {
- refreshExecutionTime();
- ll_taskDetail.setVisibility(View.VISIBLE);
- ll_taskDetail.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.top_menu_enter));
- }
-
- //鏄剧ず寮�濮嬩换鍔″璇濇
- private void showStartTaskDialog() {
- AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
- dialog.setTitle("瑕佸紑濮嬩换鍔″悧?");
- dialog.setPositiveButton("纭畾", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- subTaskStatusCurrent = subTaskRunning;
- updateStatus();
- subTaskSelected.setStatus(subTaskRunning);
- subTaskSelected.setExecutionstarttime(new Date());
- inspectionCurrent.setExecutionstarttime(new Date());
- updateSubtask(subTaskSelected);
- updateInspection(inspectionCurrent);
- iv_startEndTask.setSelected(true);
- }
- });
- dialog.setNegativeButton("鍙栨秷", null);
- dialog.show();
- }
-
- //鏄剧ず缁撴潫浠诲姟瀵硅瘽妗�
- private void showEndTaskDialog() {
- AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
- dialog.setTitle("瑕佺粨鏉熶换鍔″悧锛�");
- dialog.setMessage("缁撴潫浠诲姟鍚庨棶棰樺彇璇佸姛鑳藉皢涓嶅彲鐢�");
- dialog.setPositiveButton("纭畾", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- subTaskStatusCurrent = subTaskEnd;
- updateStatus();
- subTaskSelected.setStatus(subTaskEnd);
- subTaskSelected.setExecutionendtime(new Date());
- inspectionCurrent.setExecutionendtime(new Date());
- updateSubtask(subTaskSelected);
- updateInspection(inspectionCurrent);
- }
- });
- dialog.setNegativeButton("鍙栨秷", null);
- dialog.show();
- }
-
- //鎻愪氦subtask淇℃伅
- private void updateSubtask(Subtask subtask) {
- Call<String> updateSubtask = inspectionService.updateSubTask(subtask);
- updateSubtask.enqueue(new Callback<String>() {
- @Override
- public void onResponse(Call<String> call, Response<String> response) {
- if (response.body() != null) {
- System.out.println("SubTask:" + response.body().toString());
-// showToast("鎻愪氦subtask鎴愬姛");
- } else if (response.errorBody() != null) {
- System.out.println("SubTask:" + response.errorBody().toString());
- showToast("鎻愪氦subtask澶辫触");
- }
- }
-
- @Override
- public void onFailure(Call<String> call, Throwable t) {
- System.out.println("SubTask:" + t.toString());
- showToast("鑱旂綉澶辫触");
- }
- });
-
-
- }
-
- //鎻愪氦inspection淇℃伅
- private void updateInspection(Inspection inspection) {
- Call<ResponseBody> updateInspection = inspectionService.updateInspection(inspection);
- updateInspection.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body() != null) {
- System.out.println("inspection:" + response.body().toString());
-// showToast("鎻愪氦inspection鎴愬姛");
- } else if (response.errorBody() != null) {
- System.out.println("inspection:" + response.errorBody().toString());
- showToast("鎻愪氦inspection澶辫触");
- }
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- System.out.println("inspection:" + t.toString());
- showToast("鑱旂綉澶辫触");
- }
- });
- }
-
- //鍒锋柊problem浣嶇疆marker
- private void refreshProblemMarker() {
-
-
- Call<List<ProblemlistVo>> loadProblemList = inspectionService.loadProblemList(inspectionCurrent.getGuid());
- loadProblemList.enqueue(new Callback<List<ProblemlistVo>>() {
- @Override
- public void onResponse(Call<List<ProblemlistVo>> call, Response<List<ProblemlistVo>> response) {
- if (response.body() != null) {
- List<ProblemlistVo> problemlistVoList = response.body();
- if (problemlistVoList != null) {
- addProblemMarkers(problemlistVoList);
- }
- } else if (response.errorBody() != null) {
- showToast("鑾峰彇闂marker澶辫触");
- System.out.println("loadProblemList:" + response.errorBody().toString());
- }
- }
-
- @Override
- public void onFailure(Call<List<ProblemlistVo>> call, Throwable t) {
- showToast("鑱旂綉澶辫触");
- System.out.println("loadProblemList:" + t.toString());
- }
- });
-
- }
-
- //寰�鍦板浘涓婃坊鍔犻棶棰樹綅缃甿arker
- private void addProblemMarkers(List<ProblemlistVo> problemlistVoList) {
- problemListVoListCurrent = problemlistVoList;
- aMap.clear();
- for (int i = 0; i < problemlistVoList.size(); i++) {
- ProblemlistVo problemlistVo = problemlistVoList.get(i);
- //娣诲姞marker鍒板湴鍥句笂
- LatLng latLngNow = new LatLng(problemlistVo.getLatitude(), problemlistVo.getLongitude());
- MarkerOptions options = new MarkerOptions();
- //灏唌arker鏀惧ぇ
- Bitmap bm = BitmapFactory.decodeResource(getResources(), problemNowMarkerList.get(i));
- Matrix matrix = new Matrix();
- matrix.setScale(0.7f, 0.7f);
- Bitmap bmBig = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(),
- bm.getHeight(), matrix, true);
- options.icon(BitmapDescriptorFactory.fromBitmap(bmBig));
-
- options.position(latLngNow);
- options.snippet(problemlistVo.getGuid());
- Marker marker = aMap.addMarker(options);
- marker.setInfoWindowEnable(false);
- }
- //灏嗗満鏅綅缃坊鍔犲埌鍦板浘涓�
- LatLng sourceLatLng = new LatLng(scenseCurrent.getLatitude(), scenseCurrent.getLongitude());
- MarkerOptions options = new MarkerOptions().position(sourceLatLng);
- aMap.addMarker(options);
- }
-
- //鏄剧ず闂鍙栬瘉鐨刣ialog
- private void showTaskEvidenceDialog() {
- final Dialog dialog = new Dialog(getContext());
- dialog.setContentView(R.layout.dialog_take_evidence);
- //璁剧疆dialog瀹藉害
- Window dialogWindow = dialog.getWindow();
- dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
- final WindowManager.LayoutParams p = dialogWindow.getAttributes();
- p.width = (int) (ScreenUtils.getScreenWidth(getContext()) * 1);
- dialog.setCancelable(false);
- //鍒濆鍖栨帶浠�
- final FloatingActionButton fab_ok = (FloatingActionButton) dialog.findViewById(R.id.fab_take_evidence_ok);
- FloatingActionButton fab_Close = (FloatingActionButton) dialog.findViewById(R.id.fab_take_evidence_close);
- miv_add_photo1 = (ImageView) dialog.findViewById(R.id.iv_take_evidence_add_photo1);
- miv_add_photo2 = (ImageView) dialog.findViewById(R.id.iv_take_evidence_add_photo2);
- miv_add_photo3 = (ImageView) dialog.findViewById(R.id.iv_take_evidence_add_photo3);
- final Spinner sp_problemType = (Spinner) dialog.findViewById(R.id.sp_take_evidence_select_problem_type);
- final Spinner sp_problem = (Spinner) dialog.findViewById(R.id.sp_take_evidence_select_problem);
- final Spinner sp_location = (Spinner) dialog.findViewById(R.id.sp_take_evidence_select_location);
- final EditText et_locationRemark = (EditText) dialog.findViewById(R.id.et_take_evidence_location);
- final TextView tv_location = (TextView) dialog.findViewById(R.id.tv_location);
- final EditText et_problemDes = (EditText) dialog.findViewById(R.id.et_take_evidence_problem_des);
-
- //鍒濆鍖栧彉閲�
- pathTempList = new ArrayList<>();
- //2019.3.8 by riku 鏂板娣诲姞鏁存敼寤鸿
- LinearLayout ll_change_suggestion = dialog.findViewById(R.id.ll_change_suggestion);
- final Spinner sp_change_suggestion = dialog.findViewById(R.id.sp_take_evidence_select_suggestion);
- final EditText et_change_suggestion = dialog.findViewById(R.id.et_take_evidence_suggestion);
- final ArrayList<String> suggestionList = new ArrayList<>();
- final ArrayAdapter suggestionAdapter = new ArrayAdapter(getContext(), R.layout.item_spinner_drop_down, suggestionList);
-
- //鍔犺浇浣嶇疆淇℃伅
- List<Domainitem> locationList = domainitemDao.queryBuilder().where(DomainitemDao.Properties.Catelogname.eq("宸ュ湴浣嶇疆缁撴灉闆�")).orderAsc(DomainitemDao.Properties.Value).list();
- if (locationList != null && locationList.size() > 0) {
- DomainItemListAdapter domainItemListAdapter = new DomainItemListAdapter(locationList, getContext());
- sp_location.setAdapter(domainItemListAdapter);
- }
-
- //鍔犺浇闂鏁版嵁
- List<Problemtype> problemtypeList = problemtypeDao.queryBuilder()
- .where(ProblemtypeDao.Properties.Tasktypeid.eq(subTaskSelected.getTypeno()))
- .where(ProblemtypeDao.Properties.Citycode.eq(subTaskSelected.getCitycode()))
- .where(ProblemtypeDao.Properties.Districtcode.eq(subTaskSelected.getDistrictcode()))
- .where(ProblemtypeDao.Properties.Scensetypeid.eq(scenseCurrent.getTypeid()))
- .orderAsc(ProblemtypeDao.Properties.Typeid).list();
-
- if (problemtypeList.size() == 0) {
- Problemtype problemtype = new Problemtype();
- problemtype.setGuid("0");
- problemtype.setTypename("鏃�");
- problemtype.setName("鏃�");
- problemtypeList.add(problemtype);
- }
-
- final List<String> problemTypeStringList = new ArrayList<>();
- final Map<String, List<Problemtype>> problemTypeMap = new HashMap<>();
- for (Problemtype problemtype : problemtypeList) {
- if (problemTypeMap.containsKey(problemtype.getTypename())) {
- problemTypeMap.get(problemtype.getTypename()).add(problemtype);
- } else {
- problemTypeStringList.add(problemtype.getTypename());
- List<Problemtype> problemtypeList1 = new ArrayList<>();
- problemtypeList1.add(problemtype);
- problemTypeMap.put(problemtype.getTypename(), problemtypeList1);
- }
- }
- ArrayAdapter problemTypeAdapter = new ArrayAdapter(getContext(), R.layout.item_spinner_drop_down, problemTypeStringList);
- sp_problemType.setAdapter(problemTypeAdapter);
- final List<Problemtype> problemtypes = new ArrayList<>();
- final ProblemTypeListAdapter problemTypeListAdapter = new ProblemTypeListAdapter(problemtypes, getContext());
- sp_problem.setAdapter(problemTypeListAdapter);
- sp_problemType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
- //褰撻�変腑涓�涓垎绫绘椂锛屼粠map鍔犺浇闂鍒楄〃锛屽~鍏呮暟鎹�
- problemtypes.removeAll(problemtypes);
- problemtypes.addAll(problemTypeMap.get(problemTypeStringList.get(i)));
- problemTypeListAdapter.notifyDataSetChanged();
- if (problemTypeStringList.get(i).equals("鎬佸害")) {
- sp_location.setVisibility(View.GONE);
- et_locationRemark.setVisibility(View.GONE);
- miv_add_photo1.setVisibility(View.GONE);
- miv_add_photo2.setVisibility(View.GONE);
- miv_add_photo3.setVisibility(View.GONE);
- tv_location.setVisibility(View.GONE);
- } else {
- sp_location.setVisibility(View.VISIBLE);
- et_locationRemark.setVisibility(View.VISIBLE);
- miv_add_photo1.setVisibility(View.VISIBLE);
- miv_add_photo2.setVisibility(View.VISIBLE);
- miv_add_photo3.setVisibility(View.VISIBLE);
- tv_location.setVisibility(View.VISIBLE);
- }
-
- sp_problem.setSelection(0);
- //鍒锋柊瀵瑰簲闂鐨勬暣鏀瑰缓璁�
- refreshSuggestion(problemtypes.get(0).getGuid(), suggestionList, suggestionAdapter);
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> adapterView) {
- }
- });
-
- ll_change_suggestion.setVisibility(View.VISIBLE);
- sp_change_suggestion.setAdapter(suggestionAdapter);
-
- sp_problem.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- //褰撻�変腑涓�涓叿浣撻棶棰樻椂锛屽簲璇ユ樉绀哄搴旂殑鏁存敼寤鸿
- refreshSuggestion(problemtypes.get(position).getGuid(), suggestionList, suggestionAdapter);
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
-
- }
- });
-
-
- //璁剧疆纭畾鎸夐挳鐨勭偣鍑讳簨浠�
- fab_ok.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- fab_ok.setClickable(false);
- if (subTaskSelected != null && inspectionCurrent != null && scenseCurrent != null) {
- String problemType = sp_problemType.getSelectedItem().toString();
-
- Problemlist problemlist = new Problemlist();
- problemlist.setGuid(UUIDGenerator.generate16ShortUUID());
- problemlist.setIguid(inspectionCurrent.getGuid());
- problemlist.setStguid(subTaskSelected.getStguid());
- problemlist.setSguid(scenseCurrent.getGuid());
- problemlist.setSensename(scenseCurrent.getName());
- problemlist.setSenseaddress(getScenceAddress());
- Problemtype problemtypeSelected = (Problemtype) sp_problem.getSelectedItem();
- problemlist.setPtguid(problemtypeSelected.getGuid());
- String problemDes = "";
- if (et_problemDes.getText().length() > 0) {
- problemDes = "(" + et_problemDes.getText().toString() + ")";
- }
- problemlist.setProblemname(problemtypeSelected.getName() + problemDes);
-
- String adviceDes = "";
- if (et_change_suggestion.getText().length() > 0) {
- adviceDes = "(" + et_change_suggestion.getText().toString() + ")";
- }
- problemlist.setAdvise(sp_change_suggestion.getSelectedItem().toString() + adviceDes);
- problemlist.setLatitude(latitudeCurrent);
- problemlist.setLongitude(longitudeCurrent);
- Domainitem locationSelected = (Domainitem) sp_location.getSelectedItem();
- if (!problemType.equals("鎬佸害")) {
- problemlist.setLocationid(intToByte(locationSelected.getIndex()));
- String locationRemark = et_locationRemark.getText().toString();
- if (locationRemark.length() > 0) {
- locationRemark = "(" + locationRemark + ")";
- }
- problemlist.setLocation(locationSelected.getText() + locationRemark);
-
- } else {
- problemlist.setLocation("鏃犱綅缃�");
- }
- problemlist.setTime(new Date());
- problemlist.setIsrechecked(false);
- problemlist.setIschanged(false);
-
- if (!problemType.equals("鎬佸害") && pathTempList.size() > 0) {
- //淇濆瓨鐓х墖鍒板搴旀枃浠跺す
- List<File> savePathList = new ArrayList<File>();
- java.util.Calendar calendar = java.util.Calendar.getInstance();
- calendar.setTime(subTaskSelected.getExecutionstarttime());
- String path = "FlightFeather/Photo/" + scenseCurrent.getDistrictname() + "/" + calendar.get(java.util.Calendar.YEAR) + "骞�" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�/" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�" + calendar.get(java.util.Calendar.DAY_OF_MONTH) + "鏃�/" + scenseCurrent.getName() + "/";
- String fileName1 = problemlist.getProblemname() + " " + problemlist.getLocation() + " " + UUIDGenerator.generateUUID(4) + ".jpg";
- String fileName2 = problemlist.getProblemname() + " " + problemlist.getLocation() + " " + UUIDGenerator.generateUUID(4) + ".jpg";
- String fileName3 = problemlist.getProblemname() + " " + problemlist.getLocation() + " " + UUIDGenerator.generateUUID(4) + ".jpg";
- File photo1 = new File(Environment.getExternalStorageDirectory(), (path + fileName1));
- File photo2 = new File(Environment.getExternalStorageDirectory(), (path + fileName2));
- File photo3 = new File(Environment.getExternalStorageDirectory(), (path + fileName3));
- photo1.getParentFile().mkdirs();
-
- savePathList.add(photo1);
- savePathList.add(photo2);
- savePathList.add(photo3);
-
- List<String> fileNameList = new ArrayList<String>();
- fileNameList.add(fileName1);
- fileNameList.add(fileName2);
- fileNameList.add(fileName3);
-
- for (int i = 0; i < pathTempList.size(); i++) {
- File oldFile = pathTempList.get(i);
- File newFile = savePathList.get(i);
- //淇濆瓨鍒癿ediaFile鏁版嵁搴�
- Mediafile mediaFile = new Mediafile();
- mediaFile.setGuid(UUIDGenerator.generate16ShortUUID());
- mediaFile.setIguid(inspectionCurrent.getGuid());
- mediaFile.setBusinessguid(problemlist.getGuid());
- mediaFile.setLongitude(longitudeCurrent);
- mediaFile.setLatitude(latitudeCurrent);
- mediaFile.setAddress(problemlist.getSenseaddress());
- mediaFile.setFiletype(1);
- mediaFile.setBusinesstype("闂");
- mediaFile.setBusinesstypeid(intToByte(1));
- mediaFile.setPath(path);
- mediaFile.setDescription(fileNameList.get(i));
- mediaFile.setSavetime(new Date());
- mediaFile.setIschanged(false);
- String exetension1 = scenseCurrent.getCitycode() + "/" + scenseCurrent.getDistrictcode() + "/" + DateFormatter.dateFormat2.format(calendar.getTime()) + "/" + scenseCurrent.getGuid() + "/";
- mediaFile.setExtension1(exetension1);
- mediaFile.setRemark("鏈笂浼�");
- mediafileDao.insert(mediaFile);
-
- try {
- copyfile(oldFile, newFile);
- } catch (IOException e) {
- e.printStackTrace();
- showToast("鎷疯礉鍑洪敊" + i);
- }
- }
- //涓婁紶闂鐨勫熀鏈暟鎹�
- if (problemlist.getPtguid() == null) {
- Toast.makeText(application, "闂ID涓虹┖", Toast.LENGTH_SHORT).show();
- AlertDialog.Builder d2 = new AlertDialog.Builder(getActivity());
- d2.setTitle("闂ID涓虹┖");
- d2.setPositiveButton("纭畾", null);
- d2.show();
- }
- Call<ResponseBody> putOneProblemLsit = inspectionService.putOneProblemList(problemlist);
- putOneProblemLsit.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body() != null) {
- System.out.println("problemList:" + response.body());
- showToast("鎻愪氦鎴愬姛");
- clearTemp();
- refreshProblemMarker();
- if (inspectionCurrent.getProblemcount() != null) {
- inspectionCurrent.setProblemcount(inspectionCurrent.getProblemcount() + 1);
- } else {
- inspectionCurrent.setProblemcount(1);
- }
- updateInspection(inspectionCurrent);
- dialog.dismiss();
- } else if (response.errorBody() != null) {
- System.out.println("problemList:" + response.errorBody());
- showToast("鎻愪氦澶辫触");
- }
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- System.out.println("problemList:" + t.toString());
- showToast("鑱旂綉澶辫触");
- }
- });
-
- } else {
- showToast("鑷冲皯鎷嶄竴寮犵収鐗�");
- }
- if (problemType.equals("鎬佸害")) {
- //涓婁紶闂鐨勫熀鏈暟鎹�
- Call<ResponseBody> putOneProblemLsit = inspectionService.putOneProblemList(problemlist);
- putOneProblemLsit.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body() != null) {
- System.out.println("problemList:" + response.body());
- showToast("鎻愪氦鎴愬姛");
- clearTemp();
- refreshProblemMarker();
- dialog.dismiss();
- } else if (response.errorBody() != null) {
- System.out.println("problemList:" + response.errorBody());
- showToast("鎻愪氦澶辫触");
- }
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- System.out.println("problemList:" + t.toString());
- showToast("鑱旂綉澶辫触");
- }
- });
- }
-
-
- } else {
- showToast("閿欒锛孋urrent鏁版嵁缂哄け");
- }
-
- }
- });
- //璁剧疆鍙栨秷鎸夐挳鐨勭偣鍑讳簨浠�
- fab_Close.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- clearTemp();
- dialog.dismiss();
-
- }
- });
- clearTemp();
- refreshPhotoClickListener(pathTempList);
- dialog.show();
-
- }
-
- //鍒锋柊闂瀵瑰簲鐨勬暣鏀瑰缓璁�
- private void refreshSuggestion(String ptGuid, final List<String> list, final ArrayAdapter arrayAdapter) {
- dbSource.getAdviceByProblemType(ptGuid)
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(new Observer<List<ChangeAdvice>>() {
- @Override
- public void onSubscribe(Disposable d) {
-
- }
-
- @Override
- public void onNext(List<ChangeAdvice> changeAdvices) {
- List<String> advices = new ArrayList<>();
- for (ChangeAdvice c : changeAdvices) {
- advices.add(c.getAdName());
- }
- advices.add("鏆傛棤寤鸿");
- list.clear();
- list.addAll(advices);
- arrayAdapter.notifyDataSetChanged();
- }
-
- @Override
- public void onError(Throwable e) {
-
- }
-
- @Override
- public void onComplete() {
-
- }
- });
- }
-
- //鏄剧ず闂鍒楄〃
- public void showProblemList(final int type) {
- final Dialog dialog = new Dialog(getContext());
- dialog.setContentView(R.layout.dialog_problem_list);
- //璁剧疆dialog瀹藉害
- Window dialogWindow = dialog.getWindow();
- dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
- final WindowManager.LayoutParams p = dialogWindow.getAttributes();
- p.width = (int) (ScreenUtils.getScreenWidth(getContext()) * 1);
- p.height = (int) (ScreenUtils.getScreenHeight(getContext()) * 0.8);
-
- FloatingActionButton fab_close = (FloatingActionButton) dialog.findViewById(R.id.fab_problem_list_close);
- RecyclerView rv_main = (RecyclerView) dialog.findViewById(R.id.rv_dialog_problem_list_main);
- final TextView tv_titile = (TextView) dialog.findViewById(R.id.tv_title);
- final LinearLayout ll_lastSubTaskData = (LinearLayout) dialog.findViewById(R.id.ll_last_subTask_data);
- final TextView tv_executors = (TextView) dialog.findViewById(R.id.tv_executors);
- final TextView tv_startTime = (TextView) dialog.findViewById(R.id.tv_start_time);
-
- LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
- rv_main.setLayoutManager(linearLayoutManager);
- final List<ProblemlistVo> problemlistVoList = new ArrayList<>();
-
- if (type == PROBLEM_LIST || type == PROBLEM_CHANGE) {
- problemListAdapter = new ProblemListAdapter(getActivity(), problemlistVoList, ProblemListAdapter.PROBLEM_LIST);
- } else if (type == PROBLEM_RECHECK) {
- problemListAdapter = new ProblemListAdapter(getActivity(), problemlistVoList, ProblemListAdapter.RECHECK_LIST);
- }
- rv_main.setAdapter(problemListAdapter);
- rv_main.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), rv_main, new RecyclerItemClickListener.OnItemClickListener() {
- @Override
- public void onItemClick(View view, int position) {
- Intent intent = new Intent(getActivity(), ProblemDetailActivity.class);
- intent.putExtra("problemlistVo", problemlistVoList.get(position));
- intent.putExtra("subTaskSelected", subTaskSelected);
- intent.putExtra("scenseLat", scenseCurrent.getLatitude());
- intent.putExtra("scenseLng", scenseCurrent.getLongitude());
- intent.putExtra("editable", problemEditable);
- intent.putExtra("type", type);
- startActivityForResult(intent, PROBLEM_DETAIL);
- dialog.dismiss();
-
- }
-
- @Override
- public void onItemLongClick(View view, int position) {
-
- }
- }));
-
- if (type == PROBLEM_LIST || type == PROBLEM_CHANGE) {
- if (type == PROBLEM_LIST) {
- tv_titile.setText("闂娓呭崟");
- problemEditable = false;
- } else if (type == PROBLEM_CHANGE) {
- tv_titile.setText("鐜板満鏁存敼");
- problemEditable = true;
- }
-
- Call<List<ProblemlistVo>> loadProblemList = inspectionService.loadProblemList(inspectionCurrent.getGuid());
- loadProblemList.enqueue(new Callback<List<ProblemlistVo>>() {
- @Override
- public void onResponse(Call<List<ProblemlistVo>> call, Response<List<ProblemlistVo>> response) {
- if (response.body() != null) {
- problemlistVoList.addAll(response.body());
- problemListAdapter.notifyDataSetChanged();
- addProblemMarkers(problemlistVoList);
- tv_executors.setText("鍏�" + problemlistVoList.size() + "涓棶棰�");
- int changed = 0;
- for (ProblemlistVo problemlistVo : problemlistVoList) {
- if (problemlistVo.getIschanged()) {
- changed++;
- }
- }
- tv_startTime.setText(changed + "涓凡鏁存敼");
- } else if (response.errorBody() != null) {
- System.out.println("loadProblemList:" + response.errorBody().toString());
- tv_executors.setText("鑾峰彇闂鏁版嵁澶辫触");
- Toast.makeText(application, "鑾峰彇闂鏁版嵁澶辫触", Toast.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public void onFailure(Call<List<ProblemlistVo>> call, Throwable t) {
- System.out.println("loadProblemList:" + t.toString());
- tv_executors.setText("鑱旂綉澶辫触");
- Toast.makeText(application, "鑱旂綉澶辫触", Toast.LENGTH_SHORT).show();
- }
- });
- } else if (type == PROBLEM_RECHECK) {
- tv_titile.setText("闂澶嶆牳");
- problemEditable = true;
- ll_lastSubTaskData.setVisibility(View.INVISIBLE);
- String date = DateFormatter.dateTimeFormat2.format(subTaskSelected.getPlanstarttime());
- Call<LastSubtaskPack> loadLastProblemList = inspectionService.loadLastProblemList(subTaskSelected.getScenseid(), date);
- loadLastProblemList.enqueue(new Callback<LastSubtaskPack>() {
- @Override
- public void onResponse(Call<LastSubtaskPack> call, Response<LastSubtaskPack> response) {
- if (response.body() != null) {
- int rechecked = 0;
- if (response.body().getProblemlistVo() != null && response.body().getProblemlistVo().size() > 0) {
- problemlistVoList.addAll(response.body().getProblemlistVo());
- List<ProblemlistVo> changedList = new ArrayList<ProblemlistVo>();
- for (int i = 0; i < problemlistVoList.size(); i++) {
- ProblemlistVo problemlistVo = problemlistVoList.get(i);
- if (problemlistVo.getIschanged()) {
- changedList.add(problemlistVo);
- }
- if (problemlistVo.getIsrechecked()) {
- rechecked++;
- }
- }
- problemlistVoList.removeAll(changedList);
- problemListAdapter.notifyDataSetChanged();
- }
- try {
- if (response.body().getSubtaskVo() != null) {
- tv_executors.setText("" + response.body().getSubtaskVo().getExecutorrealtimes().replaceAll(Constant.CONNECTOR, Constant.CONNECTOR_FOR_VIEW) + "\n鍏�" + problemlistVoList.size() + "涓棶棰�");
- tv_startTime.setText("" + DateFormatter.dateTimeFormat.format(response.body().getSubtaskVo().getExecutionstarttime()) + "\n" + rechecked + "涓凡澶嶆牳");
- } else {
- tv_executors.setText("鍏�" + problemlistVoList.size() + "涓棶棰�");
- tv_startTime.setText(rechecked + "涓凡澶嶆牳");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- ll_lastSubTaskData.setVisibility(View.VISIBLE);
-
- } else if (response.errorBody() != null) {
- showToast("鑾峰彇涓婁竴娆′换鍔′俊鎭け璐�");
- tv_executors.setText("鑾峰彇涓婁竴娆′换鍔′俊鎭け璐�");
- System.out.println("loadLastProblemList:" + response.errorBody().toString());
- }
- }
-
- @Override
- public void onFailure(Call<LastSubtaskPack> call, Throwable t) {
- showToast("鑱旂綉澶辫触");
- tv_executors.setText("鑱旂綉澶辫触");
- System.out.println("loadLastProblemList:" + t.toString());
- }
- });
- }
- fab_close.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dialog.dismiss();
- }
- });
-
- dialog.show();
- }
-
- //鏄剧ず浠绘剰鎷嶇収鐨刣ialog
- private void showCameraDialog() {
- final Dialog dialog = new Dialog(getContext());
- dialog.setContentView(R.layout.dialog_camera);
- //璁剧疆dialog瀹藉害
- Window dialogWindow = dialog.getWindow();
- dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
- final WindowManager.LayoutParams p = dialogWindow.getAttributes();
- p.width = (int) (ScreenUtils.getScreenWidth(getContext()) * 1);
- p.height = (int) (ScreenUtils.getScreenHeight(getContext()) * 0.8);
-
- FloatingActionButton fab_close = (FloatingActionButton) dialog.findViewById(R.id.fab_problem_list_close);
- final RecyclerView rv_main = (RecyclerView) dialog.findViewById(R.id.rv_photo_list);
- ImageView iv_newPhoto = (ImageView) dialog.findViewById(R.id.iv_new_photo);
- final TextView tv_count = (TextView) dialog.findViewById(R.id.tv_count);
-
- GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 4);
- rv_main.setLayoutManager(gridLayoutManager);
-
-
- Call<List<Mediafile>> loadCameraMediaFileList = inspectionService.loadMediaFileList(inspectionCurrent.getGuid(), BUSSINESS_TYPE_CAMERA);
- loadCameraMediaFileList.enqueue(new Callback<List<Mediafile>>() {
- @Override
- public void onResponse(Call<List<Mediafile>> call, Response<List<Mediafile>> response) {
- List<Mediafile> mediafilesList = new ArrayList<>();
-
- if (response.body() != null) {
- mediafilesList.addAll(response.body());
-
-
- } else if (response.errorBody() != null) {
- Toast.makeText(application, "鑾峰彇鍦ㄧ嚎鍥剧墖鍒楄〃澶辫触", Toast.LENGTH_SHORT).show();
- tv_count.setText("鑾峰彇鍦ㄧ嚎鍥剧墖鍒楄〃澶辫触");
- }
- mediafilesList.addAll(mediafileDao.queryBuilder().where(MediafileDao.Properties.Iguid.eq(inspectionCurrent.getGuid())).where(MediafileDao.Properties.Businesstypeid.eq(BUSSINESS_TYPE_CAMERA)).where(MediafileDao.Properties.Remark.eq("鏈笂浼�")).list());
- PhotoListAdapter photoListAdapter = new PhotoListAdapter(mediafilesList, getContext());
- rv_main.setAdapter(photoListAdapter);
- rv_main.addOnItemTouchListener(imagelistListener(rv_main, mediafilesList));
- tv_count.setText("鍏�" + mediafilesList.size() + "寮犵収鐗�");
- }
-
- @Override
- public void onFailure(Call<List<Mediafile>> call, Throwable t) {
- Toast.makeText(application, "鑱旂綉澶辫触", Toast.LENGTH_SHORT).show();
- List<Mediafile> mediafilesList = new ArrayList<>();
- mediafilesList = mediafileDao.queryBuilder().where(MediafileDao.Properties.Iguid.eq(inspectionCurrent.getGuid())).where(MediafileDao.Properties.Businesstypeid.eq(BUSSINESS_TYPE_CAMERA)).where(MediafileDao.Properties.Remark.eq("鏈笂浼�")).list();
- PhotoListAdapter photoListAdapter = new PhotoListAdapter(mediafilesList, getContext());
- rv_main.setAdapter(photoListAdapter);
- rv_main.addOnItemTouchListener(imagelistListener(rv_main, mediafilesList));
- tv_count.setText("鍏�" + mediafilesList.size() + "寮犵収鐗�");
- }
- });
-
-
- iv_newPhoto.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- showNewPhotoDailog();
- dialog.dismiss();
- }
- });
- fab_close.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dialog.dismiss();
- }
- });
- cameraDialog = dialog;
- dialog.show();
-
- }
-
- //浠绘剰鎷嶇収鍥剧墖鍒楄〃鐨刢licklistener
- private RecyclerView.OnItemTouchListener imagelistListener(RecyclerView rv_main, final List<Mediafile> mediafilesList) {
- RecyclerView.OnItemTouchListener listerner = new RecyclerItemClickListener(getContext(), rv_main, new RecyclerItemClickListener.OnItemClickListener() {
- @Override
- public void onItemClick(View view, int position) {
- List<File> files = new ArrayList<>();
- for (Mediafile m :
- mediafilesList) {
- File f = new File(Environment.getExternalStorageDirectory(), m.getPath() + m.getDescription());
- files.add(f);
- }
-// File file = new File(Environment.getExternalStorageDirectory(), mediafilesList.get(position).getPath() + mediafilesList.get(position).getDescription());
- Intent intent = new Intent(getActivity(), PhotoViewerActivity.class);
-// intent.putExtra("file", file);
- intent.putExtra(PhotoViewerActivity.PARA_FILES, (Serializable) files);
- intent.putExtra("type", PhotoViewerActivity.CAMERA_PHOTO);
- intent.putExtra("deletable", true);
- intent.putExtra("position", position);
-// intent.putExtra("mediaFile", mediafilesList.get(position));
- intent.putExtra(PhotoViewerActivity.PARA_MEDIAS, (Serializable) mediafilesList);
- startActivityForResult(intent, VIEW_CAMERA_PHOTO);
- }
-
- @Override
- public void onItemLongClick(View view, int position) {
-
- }
- });
- return listerner;
- }
-
- //娣诲姞鏂扮殑浠绘剰鎷嶇収鐓х墖
- private void showNewPhotoDailog() {
- final Dialog dialog = new Dialog(getContext());
- dialog.setContentView(R.layout.dialog_new_photo);
- //璁剧疆dialog瀹藉害
- Window dialogWindow = dialog.getWindow();
- dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
- final WindowManager.LayoutParams p = dialogWindow.getAttributes();
- p.width = (int) (ScreenUtils.getScreenWidth(getContext()) * 1);
- dialog.setCancelable(false);
- //鍒濆鍖栨帶浠�
- FloatingActionButton fab_ok = (FloatingActionButton) dialog.findViewById(R.id.fab_take_evidence_ok);
- FloatingActionButton fab_Close = (FloatingActionButton) dialog.findViewById(R.id.fab_take_evidence_close);
- final EditText et_description = (EditText) dialog.findViewById(R.id.et_description);
-
- iv_cameraPhoto1 = (ImageView) dialog.findViewById(R.id.iv_take_evidence_add_photo1);
- iv_cameraPhoto2 = (ImageView) dialog.findViewById(R.id.iv_take_evidence_add_photo2);
- iv_cameraPhoto3 = (ImageView) dialog.findViewById(R.id.iv_take_evidence_add_photo3);
-
- ivCameraList = new ArrayList<>();
- ivCameraList.add(iv_cameraPhoto1);
- ivCameraList.add(iv_cameraPhoto2);
- ivCameraList.add(iv_cameraPhoto3);
-
- pathTempList = new ArrayList<>();
- refreshNewPhotoClickListener();
-
- //纭畾鎸夐挳淇濆瓨鍥剧墖鍜屾暟鎹簱
- fab_ok.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (et_description.getText().toString().length() > 0) {
- java.util.Calendar calendar = java.util.Calendar.getInstance();
- calendar.setTime(subTaskSelected.getExecutionstarttime());
- String path = "FlightFeather/Photo/" + scenseCurrent.getDistrictname() + "/" + calendar.get(java.util.Calendar.YEAR) + "骞�" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�/" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�" + calendar.get(java.util.Calendar.DAY_OF_MONTH) + "鏃�/" + scenseCurrent.getName() + "/浠绘剰鎷嶇収/";
- if (pathTempList != null && pathTempList.size() > 0) {
- for (int i = 0; i < pathTempList.size(); i++) {
- String fileName = et_description.getText().toString() + " " + UUIDGenerator.generateUUID(4) + ".jpg";
- File newFile = new File(Environment.getExternalStorageDirectory(), path + fileName);
- newFile.getParentFile().mkdirs();
- try {
- //鎶婃枃浠朵粠temp澶嶅埗鍒扮壒瀹氭枃浠跺す涓�
- copyfile(pathTempList.get(i), newFile);
- Mediafile mediaFile = new Mediafile();
- mediaFile.setGuid(UUIDGenerator.generate16ShortUUID());
- mediaFile.setIguid(inspectionCurrent.getGuid());
- mediaFile.setLongitude(longitudeCurrent);
- mediaFile.setLatitude(latitudeCurrent);
- mediaFile.setAddress(getScenceAddress());
- mediaFile.setFiletype(1);
- mediaFile.setBusinesstype("甯歌璁板綍");
- mediaFile.setBusinesstypeid(intToByte(5));
- mediaFile.setPath(path);
- mediaFile.setDescription(fileName);
- mediaFile.setSavetime(new Date());
- mediaFile.setIschanged(false);
- String exetension1 = scenseCurrent.getCitycode() + "/" + scenseCurrent.getDistrictcode() + "/" + DateFormatter.dateFormat2.format(calendar.getTime()) + "/" + scenseCurrent.getGuid() + "/";
- mediaFile.setExtension1(exetension1);
- mediaFile.setRemark("鏈笂浼�");
- mediafileDao.insert(mediaFile);
-
- } catch (IOException e) {
- e.printStackTrace();
- Toast.makeText(application, "澶嶅埗鏂囦欢鍑洪敊", Toast.LENGTH_SHORT).show();
- return;
- }
- }
- Toast.makeText(application, "淇濆瓨鎴愬姛", Toast.LENGTH_SHORT).show();
- clearTemp();
- dialog.dismiss();
- } else {
- Toast.makeText(application, "璇疯嚦灏戞媿涓�寮犵収鐗�", Toast.LENGTH_SHORT).show();
- }
-
- } else {
- Toast.makeText(application, "璇峰~鍐欑収鐗囨弿杩�", Toast.LENGTH_SHORT).show();
- }
-
-
- }
- });
- fab_Close.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- clearTemp();
- dialog.dismiss();
- }
- });
- dialog.show();
- }
-
- //娓呴櫎鎷嶇収鍙栬瘉鐨勭紦瀛�
- public void clearTemp() {
- for (int i = 0; i < pathTempList.size(); i++) {
- File file = pathTempList.get(i);
- if (file.exists()) {
- file.delete();
- }
- }
- }
-
- //鍒锋柊浠绘剰鎷嶇収鐨勫浘鐗囩偣鍑讳簨浠�
- public void refreshNewPhotoClickListener() {
- for (int i = 0; i < pathTempList.size(); i++) {
- SetImageTask task1 = new SetImageTask(pathTempList.get(i), ivCameraList.get(i));
- task1.execute();
- ivCameraList.get(i).setOnClickListener(showPhotoClicker(i, PhotoViewerActivity.CAMERA_PHOTO_TEMP, VIEW_CAMERA_TEMP_PHOTO));
- }
- if (pathTempList.size() < 3) {
- ImageView iv_camera = ivCameraList.get(pathTempList.size());
- iv_camera.setImageResource(R.drawable.icon_add_photo);
- iv_camera.setOnClickListener(addPhotoClickListener(CAMERA_PHOTO));
- //灏嗘媿鐓х殑鍥剧墖妗嗗墠鍚庝綅缃缃负绌哄浘鐗囨
- if (pathTempList.size() < 2) {
- ivCameraList.get(pathTempList.size() + 1).setImageResource(R.drawable.icon_add_photo_blank);
- }
- }
- if (pathTempList.size() > 0) {
- ivCameraList.get(pathTempList.size() - 1).setImageResource(R.drawable.icon_add_photo_blank);
- }
- }
-
- //鐐瑰嚮鏄剧ず浠绘剰鎷嶇収鐨勫ぇ鍥�
- private View.OnClickListener showPhotoClicker(final int position, final int type, final int requestCode) {
- View.OnClickListener listener = new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(getActivity(), PhotoViewerActivity.class);
- intent.putExtra("position", position);
- intent.putExtra("type", type);
- intent.putExtra("deletable", true);
-// intent.putExtra("file", pathTempList.get(position));
- intent.putExtra(PhotoViewerActivity.PARA_FILES, (Serializable) pathTempList);
- startActivityForResult(intent, requestCode);
- }
- };
- return listener;
- }
-
-
- //鍒锋柊鍒楄〃鐐瑰嚮浜嬩欢鐘舵��
- public void refreshPhotoClickListener(List<File> files) {
- int a = files.size();
- if (a == 0) {
- miv_add_photo1.setOnClickListener(addPhotoClickListener(PHOTO1));
- miv_add_photo2.setOnClickListener(null);
- miv_add_photo3.setOnClickListener(null);
-
- miv_add_photo1.setImageResource(R.drawable.icon_add_photo);
- miv_add_photo2.setImageResource(R.drawable.icon_add_photo_blank);
- miv_add_photo3.setImageResource(R.drawable.icon_add_photo_blank);
- } else if (a == 1) {
- miv_add_photo1.setOnClickListener(viewPhotoClickListener(PHOTO1));
- miv_add_photo2.setOnClickListener(addPhotoClickListener(PHOTO2));
- miv_add_photo3.setOnClickListener(null);
-
- SetImageTask task1 = new SetImageTask(files.get(PHOTO1), miv_add_photo1);
- task1.execute();
- miv_add_photo2.setImageResource(R.drawable.icon_add_photo);
- miv_add_photo3.setImageResource(R.drawable.icon_add_photo_blank);
- } else if (a == 2) {
- miv_add_photo1.setOnClickListener(viewPhotoClickListener(PHOTO1));
- miv_add_photo2.setOnClickListener(viewPhotoClickListener(PHOTO2));
- miv_add_photo3.setOnClickListener(addPhotoClickListener(PHOTO3));
-
- SetImageTask task1 = new SetImageTask(files.get(PHOTO1), miv_add_photo1);
- task1.execute();
- SetImageTask task2 = new SetImageTask(files.get(PHOTO2), miv_add_photo2);
- task2.execute();
- miv_add_photo3.setImageResource(R.drawable.icon_add_photo);
- } else if (a == 3) {
- miv_add_photo1.setOnClickListener(viewPhotoClickListener(PHOTO1));
- miv_add_photo2.setOnClickListener(viewPhotoClickListener(PHOTO2));
- miv_add_photo3.setOnClickListener(viewPhotoClickListener(PHOTO3));
-
- SetImageTask task1 = new SetImageTask(files.get(PHOTO1), miv_add_photo1);
- task1.execute();
- SetImageTask task2 = new SetImageTask(files.get(PHOTO2), miv_add_photo2);
- task2.execute();
- SetImageTask task3 = new SetImageTask(files.get(PHOTO3), miv_add_photo3);
- task3.execute();
- }
- }
-
- //娣诲姞鍥剧墖鐢ㄧ殑鐐瑰嚮浜嬩欢
- public View.OnClickListener addPhotoClickListener(final int position) {
- View.OnClickListener listener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
- int t = 3 - pathTempList.size();
- final int picNum = t >= 0 ? t : 0;
- switch (position) {
- case PHOTO1:
- pickPhoto(PICK_PHOTO1, picNum);
- break;
- case PHOTO2:
- pickPhoto(PICK_PHOTO2, picNum);
- break;
- case PHOTO3:
- pickPhoto(PICK_PHOTO3, picNum);
- break;
- case CAMERA_PHOTO:
- pickPhoto(PICK_CAMERA_PHTOO, picNum);
- break;
- case GIT_PHOTO:
- pickPhoto(PICK_GIT_PHOTO, picNum);
- }
- }
- };
- return listener;
- }
-
- //鏈夊浘鐗囨椂锛屾煡鐪嬪浘鐗囩殑鐐瑰嚮浜嬩欢(temp)
- public View.OnClickListener viewPhotoClickListener(final int position) {
- View.OnClickListener listener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(getActivity(), PhotoViewerActivity.class);
-
- if (position == PHOTO1 || position == PHOTO2 || position == PHOTO3) {
- intent.putExtra("position", position);
- intent.putExtra("type", PhotoViewerActivity.EVIDENCE_PHOTO_TEMP);
- intent.putExtra("deletable", true);
-// intent.putExtra("file", pathTempList.get(position));
- intent.putExtra(PhotoViewerActivity.PARA_FILES, (Serializable) pathTempList);
- startActivityForResult(intent, VIEW_EVIDENCE_TEMP_PHOTO);
- }
- }
- };
- return listener;
- }
-
- //鏄剧ず鎶�闃叉帾鏂藉垪琛�
- private void showGitListDialog() {
- final Dialog dialog = new Dialog(getContext());
- dialog.setContentView(R.layout.dialog_camera);
- //璁剧疆dialog瀹藉害
- Window dialogWindow = dialog.getWindow();
- dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
- final WindowManager.LayoutParams p = dialogWindow.getAttributes();
- p.width = (int) (ScreenUtils.getScreenWidth(getContext()) * 1);
- p.height = (int) (ScreenUtils.getScreenHeight(getContext()) * 0.8);
-
- TextView tv_title = (TextView) dialog.findViewById(R.id.tv_title);
- FloatingActionButton fab_close = (FloatingActionButton) dialog.findViewById(R.id.fab_problem_list_close);
- final RecyclerView rv_main = (RecyclerView) dialog.findViewById(R.id.rv_photo_list);
- ImageView iv_newPhoto = (ImageView) dialog.findViewById(R.id.iv_new_photo);
- final TextView tv_count = (TextView) dialog.findViewById(R.id.tv_count);
-
- tv_title.setText("鎶�闃叉帾鏂�");
- final List<GitlistVo> gitlistVoList = new ArrayList<>();
- final GitListAdapter gitListAdapter = new GitListAdapter(getContext(), gitlistVoList);
- LinearLayoutManager manager = new LinearLayoutManager(getContext());
- rv_main.setLayoutManager(manager);
- rv_main.setAdapter(gitListAdapter);
- Call<List<GitlistVo>> loadGitList = inspectionService.loadGitList(inspectionCurrent.getGuid());
- loadGitList.enqueue(new Callback<List<GitlistVo>>() {
- @Override
- public void onResponse(Call<List<GitlistVo>> call, Response<List<GitlistVo>> response) {
- if (response.body() != null) {
- gitlistVoList.addAll(response.body());
- gitListAdapter.notifyDataSetChanged();
- tv_count.setText("鍏�" + gitlistVoList.size() + "鏉℃妧闃叉帾鏂�");
- } else if (response.errorBody() != null) {
- Toast.makeText(application, "鑾峰彇鎶�闃叉帾鏂芥暟鎹け璐�", Toast.LENGTH_SHORT).show();
- tv_count.setText("鑾峰彇鎶�闃叉帾鏂芥暟鎹け璐�");
- }
- }
-
- @Override
- public void onFailure(Call<List<GitlistVo>> call, Throwable t) {
- Toast.makeText(application, "缃戠粶杩炴帴澶辫触", Toast.LENGTH_SHORT).show();
- tv_count.setText("缃戠粶杩炴帴澶辫触");
- }
- });
- rv_main.addOnItemTouchListener(new RecyclerItemClickListener(getContext(), rv_main, new RecyclerItemClickListener.OnItemClickListener() {
- @Override
- public void onItemClick(View view, int position) {
- Intent intent = new Intent(getActivity(), GitDetailActivity.class);
- intent.putExtra("gitlistVo", gitlistVoList.get(position));
- intent.putExtra("subTask", subTaskSelected);
- intent.putExtra("inspectionGuid", inspectionCurrent.getGuid());
- intent.putExtra("scenseAddress", getScenceAddress());
- startActivity(intent);
- }
-
- @Override
- public void onItemLongClick(View view, int position) {
-
- }
- }));
- iv_newPhoto.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dialog.dismiss();
- showNewGitDialog();
- }
- });
- fab_close.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dialog.dismiss();
- }
- });
-
- dialog.show();
- }
-
-
- //鏂板涓�鏉℃妧闃叉帾鏂界殑dialog
- private void showNewGitDialog() {
- final Dialog dialog = new Dialog(getContext());
- dialog.setContentView(R.layout.dialog_take_evidence);
- //璁剧疆dialog瀹藉害
- Window dialogWindow = dialog.getWindow();
- dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
- final WindowManager.LayoutParams p = dialogWindow.getAttributes();
- p.width = (int) (ScreenUtils.getScreenWidth(getContext()) * 1);
- dialog.setCancelable(false);
- //鍒濆鍖栨帶浠�
- TextView tv_title = (TextView) dialog.findViewById(R.id.tv_dialog_take_evidence_title);
- TextView tv_type = (TextView) dialog.findViewById(R.id.tv_type);
- TextView tv_chose = (TextView) dialog.findViewById(R.id.tv_chose);
- TextView tv_location = (TextView) dialog.findViewById(R.id.tv_location);
- FloatingActionButton fab_ok = (FloatingActionButton) dialog.findViewById(R.id.fab_take_evidence_ok);
- FloatingActionButton fab_Close = (FloatingActionButton) dialog.findViewById(R.id.fab_take_evidence_close);
- iv_gitPhoto1 = (ImageView) dialog.findViewById(R.id.iv_take_evidence_add_photo1);
- iv_gitPhoto2 = (ImageView) dialog.findViewById(R.id.iv_take_evidence_add_photo2);
- iv_gitPhoto3 = (ImageView) dialog.findViewById(R.id.iv_take_evidence_add_photo3);
- Spinner sp_gitType = (Spinner) dialog.findViewById(R.id.sp_take_evidence_select_problem_type);
- final Spinner sp_git = (Spinner) dialog.findViewById(R.id.sp_take_evidence_select_problem);
- final Spinner sp_location = (Spinner) dialog.findViewById(R.id.sp_take_evidence_select_location);
- final EditText et_locationRemark = (EditText) dialog.findViewById(R.id.et_take_evidence_location);
- final EditText et_problemDes = (EditText) dialog.findViewById(R.id.et_take_evidence_problem_des);
-
- ivGitList = new ArrayList<>();
- ivGitList.add(iv_gitPhoto1);
- ivGitList.add(iv_gitPhoto2);
- ivGitList.add(iv_gitPhoto3);
-
- //璁剧疆鐣岄潰
- tv_title.setText("鏂板鎶�闃叉帾鏂�");
- tv_type.setText("鎺柦绫诲瀷");
- tv_chose.setText("閫夋嫨涓�涓妧闃叉帾鏂�");
- tv_location.setVisibility(View.GONE);
- sp_location.setVisibility(View.GONE);
- et_locationRemark.setVisibility(View.GONE);
- et_problemDes.setVisibility(View.GONE);
- //鍒濆鍖栧彉閲�
- pathTempList = new ArrayList<>();
- refreshNewGitPhotoClickListener();
- //鍔犺浇棰勭疆鏁版嵁
- List<Gittype> gittypeList = gittypeDao.queryBuilder().where(GittypeDao.Properties.Tasktype.eq(subTaskSelected.getType())).where(GittypeDao.Properties.Scensetype.eq(scenseCurrent.getType())).where(GittypeDao.Properties.Districtname.eq(subTaskSelected.getDistrictname())).orderAsc(GittypeDao.Properties.Typeid).list();
- if (gittypeList.size() == 0) {
- Gittype gittype1 = new Gittype();
- gittype1.setGuid("00");
- gittype1.setName("鏃�");
- gittype1.setType("鏃�");
- gittype1.setDesc("鏃�");
- gittypeList.add(gittype1);
- }
-
- final List<String> gitTypeStringList = new ArrayList<>();
- final Map<String, List<Gittype>> gitTypeMap = new HashMap<>();
- for (Gittype gittype : gittypeList) {
- if (gitTypeMap.containsKey(gittype.getType())) {
- gitTypeMap.get(gittype.getType()).add(gittype);
- } else {
- gitTypeStringList.add(gittype.getType());
- List<Gittype> gittypeList1 = new ArrayList<>();
- gittypeList1.add(gittype);
- gitTypeMap.put(gittype.getType(), gittypeList1);
- }
- }
- ArrayAdapter gittypeAdapter = new ArrayAdapter(getContext(), R.layout.item_spinner_drop_down, gitTypeStringList);
- sp_gitType.setAdapter(gittypeAdapter);
- final List<Gittype> gittypeList1 = new ArrayList<>();
- final GitTypeListAdapter gitTypeListAdapter = new GitTypeListAdapter(gittypeList1, getContext());
- sp_git.setAdapter(gitTypeListAdapter);
- sp_gitType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
- //褰撻�変腑涓�涓垎绫绘椂锛屼粠map鍔犺浇闂鍒楄〃锛屽~鍏呮暟鎹�
- gittypeList1.removeAll(gittypeList1);
- gittypeList1.addAll(gitTypeMap.get(gitTypeStringList.get(i)));
- gitTypeListAdapter.notifyDataSetChanged();
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> adapterView) {
-
- }
- });
-
-
- fab_ok.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (pathTempList.size() > 0) {
- //鍑嗗gitlist
- final Gitlist gitlist = new Gitlist();
- gitlist.setGuid(UUIDGenerator.generate16ShortUUID());
- gitlist.setIguid(inspectionCurrent.getGuid());
- gitlist.setStguid(subTaskSelected.getStguid());
- gitlist.setSguid(scenseCurrent.getGuid());
- gitlist.setScensename(scenseCurrent.getName());
- gitlist.setScenseaddress(getScenceAddress());
- final Gittype gitSelected = (Gittype) sp_git.getSelectedItem();
- gitlist.setGtguid(gitSelected.getGuid());
- gitlist.setName(gitSelected.getName());
- gitlist.setType(gitSelected.getType());
- gitlist.setDesc(gitSelected.getDesc());
- gitlist.setCreatedate(new Date());
- gitlist.setUpdatedate(new Date());
- //鍑嗗mediaFIle
- final java.util.Calendar calendar = java.util.Calendar.getInstance();
- calendar.setTime(subTaskSelected.getExecutionstarttime());
- final String path = "FlightFeather/Photo/" + scenseCurrent.getDistrictname() + "/" + calendar.get(java.util.Calendar.YEAR) + "骞�" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�/" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�" + calendar.get(java.util.Calendar.DAY_OF_MONTH) + "鏃�/" + scenseCurrent.getName() + "/鎶�闃叉帾鏂�/";
-
- Call<ResponseBody> putGit = inspectionService.putGitList(gitlist);
- putGit.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body() != null) {
- Toast.makeText(application, "鎻愪氦鎴愬姛", Toast.LENGTH_SHORT).show();
- for (File oldfile : pathTempList) {
- String fileName = gitSelected.getName() + " " + UUIDGenerator.generateUUID(4) + ".jpg";
- Mediafile mediafile = new Mediafile();
- mediafile.setGuid(UUIDGenerator.generate16ShortUUID());
- mediafile.setBusinessguid(gitlist.getGuid());
- mediafile.setIguid(inspectionCurrent.getGuid());
- mediafile.setLongitude(longitudeCurrent);
- mediafile.setLatitude(latitudeCurrent);
- mediafile.setAddress(getScenceAddress());
- mediafile.setFiletype(1);
- mediafile.setBusinesstype("2");
- mediafile.setBusinesstype("鎶�闃叉帾鏂�");
- mediafile.setPath(path);
- mediafile.setDescription(fileName);
- mediafile.setSavetime(new Date());
- String exetension1 = scenseCurrent.getCitycode() + "/" + scenseCurrent.getDistrictcode() + "/" + DateFormatter.dateFormat2.format(calendar.getTime()) + "/" + scenseCurrent.getGuid() + "/";
- mediafile.setExtension1(exetension1);
- mediafile.setRemark("鏈笂浼�");
- try {
- File newfile = new File(Environment.getExternalStorageDirectory(), (path + fileName));
- newfile.getParentFile().mkdirs();
- copyfile(oldfile, newfile);
- mediafileDao.insert(mediafile);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- dialog.dismiss();
- } else if (response.errorBody() != null) {
- Log.e("putGit:", response.errorBody().toString());
- Toast.makeText(application, "鎻愪氦澶辫触", Toast.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- Log.e("putGit:", t.toString());
- Toast.makeText(application, "鑱旂綉澶辫触", Toast.LENGTH_SHORT).show();
- }
- });
-
- } else {
- Toast.makeText(application, "鑷冲皯鎷嶄竴寮犵収鐗�", Toast.LENGTH_SHORT).show();
- }
-
- }
- });
- fab_Close.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dialog.dismiss();
- }
- });
- dialog.show();
- }
-
- //鍒锋柊鎶�闃叉帾鏂芥瘡涓浘鐗囩殑鐐瑰嚮浜嬩欢
- private void refreshNewGitPhotoClickListener() {
- for (int i = 0; i < pathTempList.size(); i++) {
- SetImageTask task1 = new SetImageTask(pathTempList.get(i), ivGitList.get(i));
- task1.execute();
- ivGitList.get(i).setOnClickListener(showPhotoClicker(i, PhotoViewerActivity.GIT_PHOTO_TEMP, VIEW_GIT_TEMP_PHOTO));
- }
- if (pathTempList.size() < 3) {
- ImageView iv_camera = ivGitList.get(pathTempList.size());
- iv_camera.setImageResource(R.drawable.icon_add_photo);
- iv_camera.setOnClickListener(addPhotoClickListener(GIT_PHOTO));
- //灏嗘媿鐓х殑鍥剧墖妗嗗墠鍚庝綅缃缃负绌哄浘鐗囨
- if (pathTempList.size() < 2) {
- ivGitList.get(pathTempList.size() + 1).setImageResource(R.drawable.icon_add_photo_blank);
- }
- }
- if (pathTempList.size() > 0) {
- ivGitList.get(pathTempList.size() - 1).setImageResource(R.drawable.icon_add_photo_blank);
- }
- }
-
- //鎷嶇収
- public void takePhoto(int type) {
- Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- //鍒ゆ柇瑕佽烦杞殑鐩殑鍦版槸鍚︿负绌�
- if (intent.resolveActivity(getContext().getPackageManager()) != null) {
- File path = null;
- if (type == TAKE_PHOTO1 || type == TAKE_PHOTO2 || type == TAKE_PHOTO3 || type == TAKE_CAMERA_PHOTO || type == TAKE_GIT_PHOTO) {
- path = new File(Environment.getExternalStorageDirectory(), "FlightFeather/Temp/" + UUIDGenerator.generateUUID(4) + ".jpg");
- path.getParentFile().mkdirs();
- tempFileCurrent = path;
- }
- //瀹夊崜7.0閫傞厤
- Uri uri;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- uri = FileProvider.getUriForFile(getContext(), "cn.flightfeather.thirdapp.fileProvider", path);
- } else {
- uri = Uri.fromFile(path);
- }
- intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- startActivityForResult(intent, type);
- }
- }
-
- //浠庣浉鍐屼腑閫夋嫨鍥剧墖
- public void pickPhoto(int type, int num) {
-// Intent intent = new Intent();
-// intent.setAction(Intent.ACTION_PICK);//Pick an item from the data
-// intent.setType("image/*");//浠庢墍鏈夊浘鐗囦腑杩涜閫夋嫨
-// startActivityForResult(intent, type);
-
- PhotoUtil.pickPhoto(this, type, num);
- }
-
-
- //鍒濆鍖栨暣鏀规壙璇�
- private void initPromiss() {
- Toast.makeText(application, "鍔犺浇涓绋嶅悗", Toast.LENGTH_SHORT).show();
- Call<List<Mediafile>> loadSignMediaFile = inspectionService.loadMediaFileList(inspectionCurrent.getGuid(), BUSSINESS_TYPE_SIGN);
- loadSignMediaFile.enqueue(new Callback<List<Mediafile>>() {
- @Override
- public void onResponse(Call<List<Mediafile>> call, Response<List<Mediafile>> response) {
- if (response.body() != null) {
- loadSignPhoto(response.body());
-
- } else if (response.errorBody() != null) {
- Log.e("loadSignMediaFIle", response.errorBody().toString());
- Toast.makeText(application, "鑾峰彇绛惧悕鍥剧墖澶辫触", Toast.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public void onFailure(Call<List<Mediafile>> call, Throwable t) {
- Log.e("loadSignMediaFIle", t.toString());
- Toast.makeText(application, "缃戠粶杩炴帴澶辫触", Toast.LENGTH_SHORT).show();
- }
- });
- }
-
- //鍔犺浇绛惧悕鐓х墖
- private void loadSignPhoto(List<Mediafile> mediaFileList) {
- //濡傛灉鑱旂綉浼犺繃鏉ョ殑绛惧悕mediaFile鏄┖鐨勶紝鍒欐煡璇㈡湰鍦扮殑mediaFIle
- if (mediaFileList == null) {
- mediaFileList = new ArrayList<>();
- }
- List<Mediafile> mediaFilelocal = mediafileDao.queryBuilder().where(MediafileDao.Properties.Iguid.eq(inspectionCurrent.getGuid())).where(MediafileDao.Properties.Businesstypeid.eq(BUSSINESS_TYPE_SIGN)).where(MediafileDao.Properties.Remark.eq("鏈笂浼�")).list();
- mediaFileList.addAll(mediaFilelocal);
-
- //鏈�缁堢殑mediafilelist涓湁鏁版嵁灏辨樉绀猴紝娌℃湁灏辨柊澧炵鍚�
- if (mediaFileList.size() > 0) {
- List<File> files = new ArrayList<>();
- for (Mediafile m : mediaFileList) {
- File file = new File(Environment.getExternalStorageDirectory(), (m.getPath() + m.getDescription()));
- files.add(file);
- }
-
- if (files.get(0).exists()) {
- Intent intent = new Intent(getActivity(), PhotoViewerActivity.class);
- intent.putExtra(PhotoViewerActivity.PARA_FILES, (Serializable) files);
- intent.putExtra("type", PhotoViewerActivity.CAMERA_PHOTO);
- intent.putExtra("deletable", true);
- intent.putExtra("mediaFile", (Serializable) mediaFileList);
- startActivityForResult(intent, VIEW_SIGN_PHOTO);
- } else {
- if (mediaFileList.get(0).getRemark().equals("鏈笂浼�")) {
- for (Mediafile m : mediaFileList) {
- mediafileDao.delete(m);
- }
-
- } else if (mediaFileList.get(0).getRemark().equals("宸蹭笂浼�")) {
- for (Mediafile m : mediaFileList) {
- downloadAndSetImage(m);
- }
- }
-
- }
- } else {
- startActivityForResult(new Intent(getActivity(), SignActivity.class), SIGN);
- }
- }
-
- //涓嬭浇骞舵樉绀哄浘鐗�
- private void downloadAndSetImage(final Mediafile mediafile) {
- String url = mediafile.getExtension1() + mediafile.getGuid() + ".jpg";
- Call<ResponseBody> downloadImage = inspectionImageService.downloadImage(url);
- downloadImage.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body() != null) {
- writeResponseBodyToDisk(mediafile, response.body());
- } else if (response.errorBody() != null) {
- Toast.makeText(application, "鑾峰彇鍥剧墖澶辫触", Toast.LENGTH_SHORT).show();
- Log.e("downloadImage:", response.errorBody().toString());
- }
-
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- Toast.makeText(application, "鑱旂綉澶辫触", Toast.LENGTH_SHORT).show();
- Log.e("downloadImage:", t.toString());
- }
- });
- }
-
- //灏嗕笅杞界殑鍥剧墖鍐欏叆纾佺洏
- public void writeResponseBodyToDisk(Mediafile mediafile, ResponseBody body) {
- if (body == null) {
- Toast.makeText(getActivity(), "鍥剧墖婧愰敊璇�", Toast.LENGTH_SHORT).show();
- return;
- }
- try {
- InputStream is = body.byteStream();
- File fileDr = new File(Environment.getExternalStorageDirectory(), (mediafile.getPath()));
- if (!fileDr.exists()) {
- fileDr.mkdir();
- }
- File file = new File(Environment.getExternalStorageDirectory(), (mediafile.getPath() + mediafile.getDescription()));
- if (file.exists()) {
- file.delete();
- file = new File(Environment.getExternalStorageDirectory(), (mediafile.getPath() + mediafile.getDescription()));
- }
- FileOutputStream fos = new FileOutputStream(file);
- BufferedInputStream bis = new BufferedInputStream(is);
- byte[] buffer = new byte[1024];
- int len;
- while ((len = bis.read(buffer)) != -1) {
- fos.write(buffer, 0, len);
- }
- fos.flush();
- fos.close();
- bis.close();
- is.close();
- //鏄剧ず鍥剧墖
- Intent intent = new Intent(getActivity(), PhotoViewerActivity.class);
- List<File> files = new ArrayList<>();
- files.add(file);
- List<Mediafile> mediafiles = new ArrayList<>();
- mediafiles.add(mediafile);
-// intent.putExtra("file", file);
- intent.putExtra(PhotoViewerActivity.PARA_FILES, (Serializable) files);
- intent.putExtra("type", PhotoViewerActivity.CAMERA_PHOTO);
- intent.putExtra("deletable", true);
-// intent.putExtra("mediaFile", mediafile);
- intent.putExtra(PhotoViewerActivity.PARA_MEDIAS, (Serializable) mediafiles);
- startActivityForResult(intent, VIEW_SIGN_PHOTO);
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- //寮�濮嬪鑸�
- private void startNavi() {
- LatLng sourceLatLng = new LatLng(scenseCurrent.getLatitude(), scenseCurrent.getLongitude());
-
- AmapNavi amapNavi = new AmapNavi(getContext());
- amapNavi.startNavi(sourceLatLng.latitude, sourceLatLng.longitude);
- }
-
- private void backToTaskPage() {
- currentPage = TASK_PAGE;
- rl_selectTask.setVisibility(View.VISIBLE);
- rl_content.setVisibility(View.INVISIBLE);
- fab_map.show();
- subTaskListAdapter.notifyDataSetChanged();
- refreshUploadIconStatus();
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.ll_patrol_hide:
- hideIcons();
- break;
- case R.id.ll_patrol_show:
- showIcons();
- break;
- case R.id.ll_show_hide_detail:
- if (iv_showHideDetail.isSelected()) {
- hideTaskDetail();
- iv_showHideDetail.setSelected(false);
- } else {
- showTaskDetail();
- iv_showHideDetail.setSelected(true);
- }
- break;
- case R.id.iv_patrol_back:
- backToTaskPage();
- break;
- case R.id.iv_start_end_task:
- if (iv_startEndTask.isSelected()) {
- if (subTaskStatusCurrent.equals(subTaskRunning)) {
- showEndTaskDialog();
- }
- } else {
- if (subTaskStatusCurrent.equals(subTaskNotStart)) {
- showStartTaskDialog();
- }
- }
- break;
- case R.id.ln_patrol_take_evidence:
- showTaskEvidenceDialog();
- break;
- case R.id.ln_patrol_problem_list:
- OPEN_TYPE = PROBLEM_LIST;
- showProblemList(PROBLEM_LIST);
- break;
- case R.id.ln_patrol_change:
- OPEN_TYPE = PROBLEM_CHANGE;
- showProblemList(PROBLEM_CHANGE);
- break;
- case R.id.ln_patrol_problem_recheck:
- OPEN_TYPE = PROBLEM_RECHECK;
- showProblemList(PROBLEM_RECHECK);
- break;
- case R.id.ln_patrol_camera:
- showCameraDialog();
- break;
- case R.id.ln_patrol_newgit:
- showGitListDialog();
- break;
- case R.id.ln_patrol_promiss:
-// initPromiss();
- java.util.Calendar calendar = java.util.Calendar.getInstance();
- calendar.setTime(subTaskSelected.getExecutionstarttime());
- String path = "FlightFeather/Photo/" + scenseCurrent.getDistrictname() + "/" + calendar.get(java.util.Calendar.YEAR) + "骞�" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�/" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�" + calendar.get(java.util.Calendar.DAY_OF_MONTH) + "鏃�/" + scenseCurrent.getName() + "/绛惧瓧/";
- String fileName1 = "绛惧瓧 " + UUIDGenerator.generateUUID(4) + ".jpg";
- Mediafile mediaFile = new Mediafile();
- mediaFile.setGuid(UUIDGenerator.generate16ShortUUID());
- mediaFile.setIguid(inspectionCurrent.getGuid());
- mediaFile.setLongitude(longitudeCurrent);
- mediaFile.setLatitude(latitudeCurrent);
- mediaFile.setAddress(getScenceAddress());
- mediaFile.setFiletype(1);
- mediaFile.setBusinesstype("绛惧瓧");
- mediaFile.setBusinesstypeid(intToByte(6));
- mediaFile.setPath(path);
- mediaFile.setDescription(fileName1);
- mediaFile.setSavetime(new Date());
- mediaFile.setIschanged(false);
- String exetension1 = scenseCurrent.getCitycode() + "/" + scenseCurrent.getDistrictcode() + "/" + DateFormatter.dateFormat2.format(calendar.getTime()) + "/" + scenseCurrent.getGuid() + "/";
- mediaFile.setExtension1(exetension1);
- mediaFile.setRemark("鏈笂浼�");
-
- Intent intent4 = new Intent(getActivity(), PromiseActivity.class);
- intent4.putExtra("problemlistVoList", (Serializable) problemListVoListCurrent);
- intent4.putExtra("mediaFilePreData", mediaFile);
- intent4.putExtra("inspectionCurrent", inspectionCurrent);
- startActivityForResult(intent4, PROMISE);
- break;
- case R.id.ln_patrol_rate:
-
- Intent intentEvaluation = new Intent(getActivity(), GradeActivity.class);
- intentEvaluation.putExtra("inspectionGuid", inspectionCurrent.getGuid());
- intentEvaluation.putExtra("subtask", subTaskSelected);
- intentEvaluation.putExtra("scense", scenseCurrent);
-
- startActivity(intentEvaluation);
-
-// startActivity(intentEvaluation);
- break;
- case R.id.iv_upload:
- Intent intent = new Intent(getActivity(), UploadMediaFilesActivity.class);
- startActivity(intent);
- break;
- case R.id.ln_patrol_navi:
- startNavi();
- break;
- case R.id.fab_map:
- Intent intent2 = new Intent(getActivity(), SubTaskMapActivity.class);
- intent2.putExtra("subTaskListCurrent", (Serializable) subTaskListCurrent);
- startActivityForResult(intent2, SUBTASK_MAP);
- break;
- case R.id.ln_patrol_chose_latlng:
- Intent intent3 = new Intent(getActivity(), MapActivity.class);
- startActivityForResult(intent3, CHOSE_LATLNG);
-
- break;
- case R.id.ln_patrol_edit:
-// if (scenseCurrent.getType().equals("宸ュ湴")){
- Intent intent1 = new Intent(getActivity(), SceneDetailActivity.class);
- intent1.putExtra("mode", 1);
- intent1.putExtra("updateScene", scenseCurrent);
- startActivityForResult(intent1, EDITE_SCENSE);
-// }else {
-// showToast("鐩墠浠呮敮鎸佷慨鏀瑰伐鍦�");
-// }
- break;
-
- }
- }
-
- //婊戝姩椤甸潰浼氶�夋嫨褰撴湀1鍙�
-// @Override
-// public void onDateChange(Calendar calendar) {
-// tv_title.setText(calendar.getYear() + "骞�" + calendar.getMonth() + "鏈�");
-// calendarCurrent = trans2Calendar(calendar.getYear(), calendar.getMonth(), calendar.getDay());
-// //濡傛灉鍒囨崲鏈堜唤锛屽垯鏌ヨ璇ユ湀鐨勬棩浠诲姟骞舵坊鍔犲埌鏃ュ巻涓�
-// if (calendarCurrent.get(java.util.Calendar.YEAR) != lastMonthCalender.get(java.util.Calendar.YEAR) || calendarCurrent.get(java.util.Calendar.MONTH) != lastMonthCalender.get(java.util.Calendar.MONTH)) {
-// lastMonthCalender.set(java.util.Calendar.YEAR, calendarCurrent.get(java.util.Calendar.YEAR));
-// lastMonthCalender.set(java.util.Calendar.MONTH, calendarCurrent.get(java.util.Calendar.MONTH));
-// showMonthAllTask(calendarCurrent);
-// }
-// showSubTaskByDay(calendarCurrent.get(java.util.Calendar.DAY_OF_MONTH));
-// }
-//
-// @Override
-// public void onYearChange(int year) {
-//
-// }
-//
-// @Override
-// public void onDateSelected(Calendar calendar) {
-//
-// }
-
- //灏唅nt鐨勫勾鏈堟棩杞崲涓篶alendar瀵硅薄
- public java.util.Calendar trans2Calendar(int year, int month, int day) {
- java.util.Calendar calendar = java.util.Calendar.getInstance();
- calendar.set(java.util.Calendar.YEAR, year);
- calendar.set(java.util.Calendar.MONTH, (month - 1));
- calendar.set(java.util.Calendar.DAY_OF_MONTH, day);
- calendar.set(java.util.Calendar.HOUR_OF_DAY, 0);
- calendar.set(java.util.Calendar.MINUTE, 0);
- calendar.set(java.util.Calendar.SECOND, 0);
- calendar.set(java.util.Calendar.MILLISECOND, 0);
-
- return calendar;
- }
-
- @Override
- public void onHiddenChanged(boolean hidden) {
- this.hidden = hidden;
- if (hidden) {
- aMap.setMyLocationEnabled(false);
- } else {
-// String yearMonth = DateFormater.YearMonthFormat.format(new Date());
-// getThreeMonthTask(yearMonth, "Middle", false);
- refreshUploadIconStatus();
- initLocation();
- }
- }
-
- @Override
- public void onMyLocationChange(Location location) {
-
- latitudeCurrent = location.getLatitude();
- longitudeCurrent = location.getLongitude();
-
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- aMap.setMyLocationEnabled(false);
- mv_main.onDestroy();
- for (Disposable d :
- disposables) {
- if (!d.isDisposed()) d.dispose();
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- //鍦╝ctivity鎵цonResume鏃舵墽琛宮MapView.onResume ()锛岄噸鏂扮粯鍒跺姞杞藉湴鍥�
- mv_main.onResume();
-
- refreshUploadIconStatus();
- if (!hidden) {
- initLocation();
- }
-
- }
-
- @Override
- public void onPause() {
- super.onPause();
- //鍦╝ctivity鎵цonPause鏃舵墽琛宮MapView.onPause ()锛屾殏鍋滃湴鍥剧殑缁樺埗
- aMap.setMyLocationEnabled(false);
- mv_main.onPause();
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- //鍦╝ctivity鎵цonSaveInstanceState鏃舵墽琛宮MapView.onSaveInstanceState (outState)锛屼繚瀛樺湴鍥惧綋鍓嶇殑鐘舵��
- mv_main.onSaveInstanceState(outState);
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == TAKE_PHOTO1 || requestCode == TAKE_PHOTO2 || requestCode == TAKE_PHOTO3 || requestCode == TAKE_CAMERA_PHOTO || requestCode == TAKE_GIT_PHOTO) {
- if (resultCode == RESULT_OK) {
- pathTempList.add(tempFileCurrent);
- if (requestCode == TAKE_PHOTO1 || requestCode == TAKE_PHOTO2 || requestCode == TAKE_PHOTO3) {
- refreshPhotoClickListener(pathTempList);
- } else if (requestCode == TAKE_CAMERA_PHOTO) {
- refreshNewPhotoClickListener();
- } else if (requestCode == TAKE_GIT_PHOTO) {
- refreshNewGitPhotoClickListener();
- }
- }
- } else if (requestCode == PICK_PHOTO1 || requestCode == PICK_PHOTO2 || requestCode == PICK_PHOTO3 || requestCode == PICK_CAMERA_PHTOO || requestCode == PICK_GIT_PHOTO) {
- if (resultCode == RESULT_OK) {
-
- List<String> paths = data.getStringArrayListExtra(BaseTakePicActivity.EXTRA_SELECT_IMAGES);
-
-// Uri selectedImage = data.getData(); //鑾峰彇绯荤粺杩斿洖鐨勭収鐗囩殑Uri
-//
-// String[] filePathColumn = {MediaStore.Images.Media.DATA};
-//
-// Cursor cursor = getContext().getContentResolver().query(selectedImage,
-// filePathColumn, null, null, null);//浠庣郴缁熻〃涓煡璇㈡寚瀹歎ri瀵瑰簲鐨勭収鐗�
-// if (cursor!=null){
-// cursor.moveToFirst();
-// int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
-// String picturePath = cursor.getString(columnIndex); //鑾峰彇鐓х墖璺緞
-// oldFile = new File(picturePath);
-// cursor.close();
-// }else {
-// String a =selectedImage.getPath();
-// oldFile = new File(a);
-// }
-
- for (String p : paths) {
- File oldFile = new File(p);
- File newFile = new File(Environment.getExternalStorageDirectory(), "FlightFeather/Temp/" + UUIDGenerator.generateUUID(4) + ".jpg");
- if (!newFile.getParentFile().exists()) {
- newFile.getParentFile().mkdirs();
- }
- try {
- copyfile(oldFile, newFile);
- pathTempList.add(newFile);
- } catch (IOException e) {
- e.printStackTrace();
- Toast.makeText(getContext(), "澶嶅埗鏂囦欢澶辫触", Toast.LENGTH_SHORT).show();
- }
- }
- if (requestCode == PICK_PHOTO1 || requestCode == PICK_PHOTO2 || requestCode == PICK_PHOTO3) {
- refreshPhotoClickListener(pathTempList);
- } else if (requestCode == PICK_CAMERA_PHTOO) {
- refreshNewPhotoClickListener();
- } else if (requestCode == PICK_GIT_PHOTO) {
- refreshNewGitPhotoClickListener();
- }
-
- }
- } else if (requestCode == PROBLEM_DETAIL) {
- showProblemList(OPEN_TYPE);
- } else if (requestCode == VIEW_CAMERA_PHOTO) {
- if (resultCode == RESULT_OK) {
- cameraDialog.dismiss();
- showCameraDialog();
- }
- } else if (requestCode == VIEW_EVIDENCE_TEMP_PHOTO || requestCode == VIEW_CAMERA_TEMP_PHOTO || requestCode == VIEW_GIT_TEMP_PHOTO) {
- if (resultCode == RESULT_OK) {
- int position = data.getIntExtra("position", -1);
- if (position > -1) {
- if (pathTempList.get(position).exists()) {
- pathTempList.get(position).delete();
- }
- pathTempList.remove(position);
- if (requestCode == VIEW_EVIDENCE_TEMP_PHOTO) {
- refreshPhotoClickListener(pathTempList);
- } else if (requestCode == VIEW_CAMERA_TEMP_PHOTO) {
- refreshNewPhotoClickListener();
- } else if (requestCode == VIEW_GIT_TEMP_PHOTO) {
- refreshNewGitPhotoClickListener();
- }
-
- }
- }
- } else if (requestCode == SIGN) {
- //淇濆瓨绛惧瓧鐓х墖
- if (resultCode == RESULT_OK) {
- if (data != null) {
- byte[] bis = data.getByteArrayExtra(Constant.KEY_INTENT_SIGHPIC);
- Bitmap bitmap = BitmapFactory.decodeByteArray(bis, 0, bis.length);
- java.util.Calendar calendar = java.util.Calendar.getInstance();
- calendar.setTime(subTaskSelected.getExecutionstarttime());
- String path = "FlightFeather/Photo/" + scenseCurrent.getDistrictname() + "/" + calendar.get(java.util.Calendar.YEAR) + "骞�" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�/" + (calendar.get(java.util.Calendar.MONTH) + 1) + "鏈�" + calendar.get(java.util.Calendar.DAY_OF_MONTH) + "鏃�/" + scenseCurrent.getName() + "/绛惧瓧/";
- String fileName1 = "绛惧瓧.jpg";
- File file = new File(Environment.getExternalStorageDirectory(), (path + fileName1));
- file.getParentFile().mkdirs();
- if (file.exists()) {
- file.delete();
- }
- try {
- FileOutputStream out = new FileOutputStream(file);
- bitmap.compress(Bitmap.CompressFormat.JPEG, 99, out);
- out.flush();
- out.close();
- //淇濆瓨鍒癿ediaFile鏁版嵁搴�
- Mediafile mediaFile = new Mediafile();
- mediaFile.setGuid(UUIDGenerator.generate16ShortUUID());
- mediaFile.setIguid(inspectionCurrent.getGuid());
- mediaFile.setLongitude(longitudeCurrent);
- mediaFile.setLatitude(latitudeCurrent);
- mediaFile.setAddress(getScenceAddress());
- mediaFile.setFiletype(1);
- mediaFile.setBusinesstype("绛惧瓧");
- mediaFile.setBusinesstypeid(intToByte(6));
- mediaFile.setPath(path);
- mediaFile.setDescription(fileName1);
- mediaFile.setSavetime(new Date());
- mediaFile.setIschanged(false);
- String exetension1 = scenseCurrent.getCitycode() + "/" + scenseCurrent.getDistrictcode() + "/" + DateFormatter.dateFormat2.format(calendar.getTime()) + "/" + scenseCurrent.getGuid() + "/";
- mediaFile.setExtension1(exetension1);
- mediaFile.setRemark("鏈笂浼�");
- mediafileDao.insert(mediaFile);
- Toast.makeText(application, "淇濆瓨鎴愬姛", Toast.LENGTH_SHORT).show();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- Toast.makeText(application, "淇濆瓨澶辫触", Toast.LENGTH_SHORT).show();
- } catch (IOException e) {
- e.printStackTrace();
- Toast.makeText(application, "淇濆瓨澶辫触", Toast.LENGTH_SHORT).show();
- }
-//
- }
- }
- } else if (requestCode == SUBTASK_MAP && resultCode == RESULT_OK) {
- int position = data.getIntExtra("position", -1);
- if (position > -1) {
- subTaskSelected = subTaskListCurrent.get(position);
- loadInspectionData(subTaskSelected.getStguid());
- }
- } else if (requestCode == CHOSE_LATLNG && resultCode == RESULT_OK) {
- Double longitude = data.getDoubleExtra("Longitude", 0);
- Double latitude = data.getDoubleExtra("Latitude", 0);
- if (longitude != 0 && latitude != 0) {
- if (scenseCurrent.getType().equals("宸ュ湴")) {
- scenseCurrent.setLongitude(longitude);
- scenseCurrent.setLatitude(latitude);
- if (siteCurrent != null) {
- siteCurrent.setSitelatitude(latitude);
- siteCurrent.setSitelongitude(longitude);
- Call<ResponseBody> updateSite = inspectionService.updateSite(siteCurrent);
- updateSite.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body() != null) {
- showToast("淇敼鎴愬姛");
- if (siteCurrent != null) {
- siteDao.update(siteCurrent);
- }
- scenseDao.update(scenseCurrent);
- refreshProblemMarker();
- } else if (response.errorBody() != null) {
- showToast("淇敼澶辫触锛岃閲嶈瘯");
- }
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- showToast("缃戠粶杩炴帴閿欒");
- }
- });
- } else {
- Call<ResponseBody> updateScense = inspectionService.updateScense(scenseCurrent);
- updateScense.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body() != null) {
- showToast("淇敼鎴愬姛");
- scenseDao.update(scenseCurrent);
- refreshProblemMarker();
- } else if (response.errorBody() != null) {
- showToast("淇敼澶辫触锛岃閲嶈瘯");
- }
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- showToast("缃戠粶杩炴帴閿欒");
- }
- });
- }
-
-
- } else {
- scenseCurrent.setLongitude(longitude);
- scenseCurrent.setLatitude(latitude);
-
- Call<ResponseBody> updateScense = inspectionService.updateScense(scenseCurrent);
- updateScense.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
- if (response.body() != null) {
- showToast("淇敼鎴愬姛");
- scenseDao.update(scenseCurrent);
- refreshProblemMarker();
- } else if (response.errorBody() != null) {
- showToast("淇敼澶辫触锛岃閲嶈瘯");
- }
- }
-
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- showToast("缃戠粶杩炴帴閿欒");
- }
- });
- }
-
- }
- } else if (requestCode == PROMISE) {
- refreshProblemMarker();
- } else if (requestCode == EDITE_SCENSE) {
- AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
- dialog.setTitle("闇�瑕侀噸鍚�");
- dialog.setMessage("app閲嶅惎鍚庢墠鑳芥洿鏂颁慨鏀瑰悗鐨勫満鏅俊鎭紝瑕佺幇鍦ㄩ��鍑哄悧锛�");
- dialog.setPositiveButton("閫�鍑�", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- getActivity().finish();
- }
- });
- dialog.setNegativeButton("鍙栨秷", null);
- dialog.show();
- }
-
- }
-
- //鑾峰彇string绫诲瀷鐨勫満鏅湴鍧�
- public String getScenceAddress() {
- String a = "";
- if (scenseCurrent != null) {
- if (scenseCurrent.getTownname() == null) {
- scenseCurrent.setTownname("");
- }
- a = scenseCurrent.getCityname() + scenseCurrent.getDistrictname() + scenseCurrent.getTownname() + scenseCurrent.getLocation();
- }
- return a;
- }
-
- //閲嶅懡鍚嶆枃浠�
- public Boolean renameFile(File oldFile, File newFile) {
-
- if (!oldFile.getAbsolutePath().equals(newFile.getAbsolutePath())) {
- if (!oldFile.exists()) {
- showToast("鏃ф枃浠朵笉瀛樺湪");
- return false;
- } else if (newFile.exists()) {
- showToast("鏂版枃浠跺凡瀛樺湪");
- return false;
- } else {
- oldFile.renameTo(newFile);
- return true;
- }
- } else {
- showToast("鏂版枃浠跺拰鏃ф枃浠跺悕鍚嶅瓧鐩稿悓");
- return false;
- }
-
- }
-
- //澶嶅埗鏂囦欢
- public static void copyfile(File oldfile, File newfile) throws IOException {
- FileInputStream ins = new FileInputStream(oldfile);
- FileOutputStream out = new FileOutputStream(newfile);
- //鑷畾涔夌紦鍐插璞�
- byte[] b = new byte[1024];
- int n = 0;
- while ((n = ins.read(b)) != -1) {
- out.write(b, 0, b.length);
- }
- ins.close();
- out.close();
-
- System.out.println("copy success");
- }
-
- public static byte intToByte(int x) {
- return (byte) x;
- }
-
- //鏄剧ずtoast
- public void showToast(String s) {
- Toast.makeText(getActivity(), s, Toast.LENGTH_SHORT).show();
- }
-
-
- //<editor-fold desc="鍔犺浇寮瑰嚭妗嗗紑鍚叧闂�">
- private void showLoadingDialog() {
- if (dialog == null) {
- dialog = DialogUtil.createLoadingDialog(getActivity(), "");
- }
- if (!dialog.isShowing()) {
- dialog.show();
- }
- }
-
- private void loadingOver(boolean b) {
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- if (dialog.isShowing()) {
- dialog.dismiss();
- }
- }
- }, 500);
- if (b) {//鍔犺浇鎴愬姛
-// scrollView.setVisibility(View.VISIBLE);
-// no_data.setVisibility(View.GONE);
- } else {//鍔犺浇澶辫触
-// scrollView.setVisibility(View.GONE);
-// no_data.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- public void onCalendarOutOfRange(Calendar calendar) {
-
- }
-
- @Override
- public void onCalendarSelect(Calendar calendar, boolean isClick) {
-
- }
- //</editor-fold>
-
-}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseActivity.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseActivity.kt
index bcd8e5d..739b530 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseActivity.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseActivity.kt
@@ -12,6 +12,8 @@
import android.support.v7.widget.Toolbar
import android.view.MenuItem
import android.view.ViewGroup
+import com.bumptech.glide.Glide
+import com.bumptech.glide.util.Util
import io.reactivex.disposables.Disposable
import org.greenrobot.eventbus.EventBus
@@ -48,6 +50,7 @@
it.dispose()
}
}
+ Glide.with(applicationContext).pauseRequests()
super.onDestroy()
}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseTakePicActivity.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseTakePicActivity.kt
index 46f614c..9c15188 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseTakePicActivity.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/base/BaseTakePicActivity.kt
@@ -12,6 +12,7 @@
import cn.flightfeather.thirdapp.util.UUIDGenerator
import cn.flightfeather.thirdapp.util.file.FileUtil
import cn.flightfeather.thirdapp.util.photo.PhotoUtil
+import com.bumptech.glide.Glide
import com.lcw.library.imagepicker.ImagePicker
import org.jetbrains.anko.toast
import java.io.File
@@ -91,9 +92,11 @@
when {
i < picSize -> {
imageViewList[i].setOnClickListener(viewPhotoClickListener(i))
- // fixme: 2019/8/2 姝ゅ缁檌mageVIew璁剧疆鍥剧墖鍦ㄥ師浠g爜涓槸鑷畾涔変簡涓�涓狝syncTask锛屼箣鍚庡彲浠ョ敤Glide绛夌涓夋柟妗嗘灦鏇夸唬
imageViewList[i].scaleType = ImageView.ScaleType.CENTER_CROP
- SetImageTask(pathTempList[i].first, imageViewList[i]).execute()
+ Glide.with(this)
+ .load(pathTempList[i].first)
+ .placeholder(R.drawable.icon_add_photo_waite)
+ .into(imageViewList[i])
}
i == picSize -> imageViewList[i].run {
setOnClickListener(takePhotoClickListener(i))
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraActivity.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraActivity.kt
index 44ef3d9..674d3b6 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraActivity.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraActivity.kt
@@ -174,8 +174,7 @@
mediaFile.iguid = inspection?.guid
mediaFile.longitude = lng
mediaFile.latitude = lat
- mediaFile.address = "${scene?.cityname ?: ""} + ${scene?.districtname
- ?: ""} + ${scene?.townname ?: ""} + ${scene?.location ?: ""}"
+ mediaFile.address = "${scene?.cityname ?: ""}${scene?.districtname ?: ""}${scene?.townname ?: ""}${scene?.location ?: ""}"
mediaFile.filetype = 1
mediaFile.businesstype = currentType.des
mediaFile.businesstypeid = currentType.value.toByte()
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuChangeActivity.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuChangeActivity.kt
index f2a5c79..26e2be2 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuChangeActivity.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuChangeActivity.kt
@@ -3,7 +3,6 @@
import android.arch.lifecycle.Observer
import android.os.Bundle
import cn.flightfeather.thirdapp.adapter.ProblemListAdapter
-import cn.flightfeather.thirdapp.fragment.InspectionFragment
import cn.flightfeather.thirdapp.model.event.InspectionEvent
import cn.flightfeather.thirdapp.model.event.ProblemEvent
import kotlinx.android.synthetic.main.dialog_problem_list.*
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceActivity.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceActivity.kt
index 105a3cc..0e6fda9 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceActivity.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceActivity.kt
@@ -158,7 +158,7 @@
toast("褰撳墠宸℃煡鐘舵�侀敊璇紝鏃犳硶涓婁紶闂锛岃灏濊瘯閲嶆柊鍚姩")
}
- val problemType = sp_take_evidence_select_problem_type.selectedItem.toString()
+ val problemType = sp_take_evidence_select_problem_type.selectedItem?.toString()
val pro = Problemlist().apply {
guid = UUIDGenerator.generate16ShortUUID()
@@ -171,26 +171,26 @@
val p = sp_take_evidence_select_problem.selectedItem
if (p is Problemtype) {
ptguid = p.guid
- var problemDes = et_take_evidence_problem_des.text.toString()
+ var problemDes = et_take_evidence_problem_des?.text.toString()
if (problemDes.isNotEmpty()) {
problemDes = "($problemDes)"
}
problemname = p.name + problemDes
}
- var adviceDes = et_take_evidence_suggestion.text.toString()
+ var adviceDes = et_take_evidence_suggestion?.text.toString()
if (adviceDes.isNotEmpty()) {
adviceDes = "($adviceDes)"
}
- advise = sp_take_evidence_select_suggestion.selectedItem.toString() + adviceDes
+ advise = sp_take_evidence_select_suggestion.selectedItem?.toString() + adviceDes
latitude = lat
longitude = lng
val l = sp_take_evidence_select_location.selectedItem
if (l is Domainitem) {
if (problemType != "鎬佸害") {
- var locationRemark = et_take_evidence_location.text.toString()
- if (locationRemark.isNotEmpty()) {
+ var locationRemark = et_take_evidence_location.text?.toString()
+ if (locationRemark?.isNotEmpty() == true) {
locationRemark = "($locationRemark)"
}
locationid = l.index.toByte()
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt
index 12f3f07..a71fdfa 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt
@@ -63,10 +63,13 @@
VIEW_PHOTO -> {
//鏌ョ湅涓存椂鎷嶆憚鍥剧墖鍙互鍒犻櫎
data?.getIntExtra("position", -1)?.let {
- if (it > -1) {
- viewModel.mediaFileList.value?.get(it)?.let {m ->
+ val size = viewModel.mediaFileList.value?.size ?: 0
+ if (it > -1 && it < size) {
+ viewModel.mediaFileList.value?.get(it)?.let { m ->
deleteMediaFileList.add(m)
}
+ } else {
+ toast("瑕佸垹闄ょ殑鍥剧墖涓嶅瓨鍦�")
}
}
}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuRecheckActivity.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuRecheckActivity.kt
index 61c9f9a..375df7a 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuRecheckActivity.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuRecheckActivity.kt
@@ -4,7 +4,6 @@
import android.os.Bundle
import cn.flightfeather.thirdapp.adapter.ProblemListAdapter
import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo
-import cn.flightfeather.thirdapp.fragment.InspectionFragment
import cn.flightfeather.thirdapp.model.event.InspectionEvent
import cn.flightfeather.thirdapp.model.event.ProblemEvent
import cn.flightfeather.thirdapp.util.Constant
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/InspectionInfoFragment.java b/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/InspectionInfoFragment.java
index 57ad469..717f2c7 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/InspectionInfoFragment.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/InspectionInfoFragment.java
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Objects;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -38,6 +39,7 @@
import cn.flightfeather.thirdapp.util.CommonUtils;
import cn.flightfeather.thirdapp.util.Constant;
import cn.flightfeather.thirdapp.util.DateFormatter;
+import cn.flightfeather.thirdapp.util.Domain;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -268,7 +270,7 @@
p.setTotalCount(p.getTotalCount() + 1 );
this.total_problems++;
//宸叉暣鏀归棶棰樻暟绱姞
- if (problemlistVo.getIschanged()){
+ if (problemlistVo.getIschanged() && Objects.equals(problemlistVo.getExtension3(), Domain.CHANGE_CHECK_PASS)) {
p.setIsRectifiedCount(p.getIsRectifiedCount() + 1);
this.changed_problems++;
}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeActivity.java b/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeActivity.java
index fdcd7eb..134d49e 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeActivity.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeActivity.java
@@ -157,10 +157,12 @@
for (int i = 0; i < problemlistVos.size(); i++) {
ProblemlistVo problemlistVoTemp = problemlistVos.get(i);
- if (problemlistVoTemp.getIschanged()) {
- this.changedProblems.add(problemlistVoTemp);
- } else {
+ if (!problemlistVoTemp.getIschanged()) {
this.unChangedProblems.add(problemlistVoTemp);
+ } else if (!Objects.equals(problemlistVoTemp.getExtension3(), Domain.CHANGE_CHECK_PASS)) {
+ this.unChangedProblems.add(problemlistVoTemp);
+ } else {
+ this.changedProblems.add(problemlistVoTemp);
}
}
tabIndicators = new ArrayList<>();
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..8d3e486 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
@@ -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();
}
});
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/repository/SceneRepository.kt b/app/src/main/java/cn/flightfeather/thirdapp/repository/SceneRepository.kt
index be6a3a5..4af18f4 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/repository/SceneRepository.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/repository/SceneRepository.kt
@@ -103,6 +103,7 @@
* 鏂板鍦烘櫙淇℃伅
*/
fun putScene(scene: Scense, resultCallBack: ResultCallBack<ResponseBody>) {
+ sceneDao.insert(scene)
retrofit.create(ScenseService::class.java).putScense(scene)
.enqueue(ResponseBodyCallBack(resultCallBack))
}
@@ -111,6 +112,7 @@
* 鏇存柊鍦烘櫙淇℃伅
*/
fun updateScene(scene: Scense, resultCallBack: ResultCallBack<ResponseBody>) {
+ sceneDao.update(scene)
retrofit.create(ScenseService::class.java).updateScense(scene)
.enqueue(ResponseBodyCallBack(resultCallBack))
}
@@ -119,6 +121,9 @@
* 鎵归噺鏇存柊鍦烘櫙淇℃伅
*/
fun updateSceneList(sceneList: ArrayList<Scense>, resultCallBack: ResultCallBack<ResponseBody>) {
+ sceneList.forEach {
+ sceneDao.update(it)
+ }
retrofit.create(ScenseService::class.java).updateSceneList(sceneList)
.enqueue(ResponseBodyCallBack(resultCallBack))
}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/repository/dao/SceneDao.kt b/app/src/main/java/cn/flightfeather/thirdapp/repository/dao/SceneDao.kt
index f4b3688..4f3747c 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/repository/dao/SceneDao.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/repository/dao/SceneDao.kt
@@ -12,6 +12,10 @@
*/
class SceneDao {
+ fun insert(scene: Scense) {
+ DbFactory.getInstance().scenseDao.insert(scene)
+ }
+
/**
* 鏇存柊鍦烘櫙淇℃伅
*/
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/task/DownloadAndSetImageTask.java b/app/src/main/java/cn/flightfeather/thirdapp/task/DownloadAndSetImageTask.java
index 8fb1993..31530e9 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/task/DownloadAndSetImageTask.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/task/DownloadAndSetImageTask.java
@@ -1,7 +1,6 @@
package cn.flightfeather.thirdapp.task;
import android.app.Activity;
-import android.content.Context;
import android.os.Environment;
import android.util.Log;
import android.widget.ImageView;
@@ -36,17 +35,18 @@
private Activity activity;
//涓嬭浇骞舵樉绀哄浘鐗�
- public DownloadAndSetImageTask(Mediafile mediafile, ImageView imageView, Context context) {
+ public DownloadAndSetImageTask(Mediafile mediafile, ImageView imageView, Activity activity) {
this.mediafile = mediafile;
this.imageView = imageView;
- application = (CommonApplication) context.getApplicationContext();
+ this.activity = activity;
+ application = (CommonApplication) activity.getApplicationContext();
}
//鍙笅杞�
- public DownloadAndSetImageTask(Mediafile mediafile, Context context) {
+ public DownloadAndSetImageTask(Mediafile mediafile, Activity activity) {
this.mediafile = mediafile;
- application = (CommonApplication) context.getApplicationContext();
+ application = (CommonApplication) activity.getApplicationContext();
try {
- activity = (Activity) context;
+ this.activity = (Activity) activity;
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/task/SetImageTask.java b/app/src/main/java/cn/flightfeather/thirdapp/task/SetImageTask.java
index 210a54a..8232a73 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/task/SetImageTask.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/task/SetImageTask.java
@@ -1,98 +1,41 @@
package cn.flightfeather.thirdapp.task;
import android.app.Activity;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.os.AsyncTask;
-import android.os.Build;
-import android.support.annotation.RequiresApi;
import android.widget.ImageView;
+
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.util.Util;
import java.io.File;
import cn.flightfeather.thirdapp.R;
-import cn.flightfeather.thirdapp.module.inspectioninfo.ProblemChangeDetailActivity;
/**
* Created by note_ff_1602 on 2017/10/26.
* 璁剧疆鍥剧墖鐨則ask
+ *
*/
-public class SetImageTask extends AsyncTask {
+// FIXME: 2020/11/12 鍘熸潵鐨勫疄鐜版柟寮忓彲鑳戒細瀵艰嚧oom锛屽洜姝や慨鏀逛负浣跨敤Glide鏉ュ疄鐜板浘鐗囩殑鏄剧ず銆�
+public class SetImageTask {
private File file;
private ImageView miv_photo;
- private ProblemChangeDetailActivity activity;
+ private Activity activity;
public SetImageTask(File file, ImageView miv_photo, Activity activity) {
- super();
this.file = file;
this.miv_photo = miv_photo;
- try {
- this.activity = (ProblemChangeDetailActivity) activity;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public SetImageTask(File file, ImageView miv_photo) {
- super();
- this.file = file;
- this.miv_photo = miv_photo;
- }
-
- //鍘嬬缉鍓嶅厛鎶婂浘鐗囪缃负绛夊緟
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- miv_photo.setImageResource(R.drawable.icon_add_photo_waite);
- }
-
- //鍚庡彴鍘嬬缉鍥剧墖
- @Override
- protected Object doInBackground(Object[] params) {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.RGB_565;
- Bitmap bm = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
- if (bm == null) return null;
- //鍘嬬缉缂╃暐鍥�
- Matrix matrix = new Matrix();
- matrix.setScale(0.12f, 0.12f);
- //鍘嬬缉缂╃暐鍥�
- Bitmap bmSmall = null;
- int normalSize = 100;
- int width,height =0;
- if (bm.getWidth()>=bm.getHeight()){
- width = normalSize;
- height = normalSize*bm.getHeight()/bm.getWidth();
- }else {
- height =normalSize;
- width = normalSize*bm.getWidth()/bm.getHeight();
- }
-
- if (bm!=null){
- bmSmall= Bitmap.createScaledBitmap(bm,width,height,true);
-// bmSmall= Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
- }
-
-
- return bmSmall;
+ this.activity = activity;
}
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- @Override
- protected void onPostExecute(Object o) {
- super.onPostExecute(o);
- Bitmap bmSmall = (Bitmap) o;
- if (bmSmall!=null){
- miv_photo.setImageBitmap(bmSmall);
-// if (activity != null) {
-// activity.postponeEnterTransition();
-// }
+ public void execute() {
+ if (Util.isOnMainThread() && activity != null && !activity.isDestroyed()) {
+ Glide.with(miv_photo)
+ .load(file)
+ .placeholder(R.drawable.icon_add_photo_waite)
+ .into(miv_photo);
}
-
}
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/util/photo/PhotoUtil.java b/app/src/main/java/cn/flightfeather/thirdapp/util/photo/PhotoUtil.java
index fab953b..6f61359 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/util/photo/PhotoUtil.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/util/photo/PhotoUtil.java
@@ -1,7 +1,6 @@
package cn.flightfeather.thirdapp.util.photo;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -65,21 +64,21 @@
* 缁戝畾ImageView鍜屽浘鐗囷紝鏈湴鍔犺浇鎴栬仈缃戝姞杞芥樉绀�(閽堝鍥哄畾鏁伴噺鐨処mageView)
* @param mediaFiles
* @param imageViews
- * @param context
+ * @param activity
* @return 瀹為檯鍔犺浇鐨勫浘鐗囦釜鏁�
*/
- public static int loadImage(List<Mediafile> mediaFiles, List<ImageView> imageViews, Context context){
+ public static int loadImage(List<Mediafile> mediaFiles, List<ImageView> imageViews, Activity activity){
if (mediaFiles!=null){
- int count = mediaFiles.size() >= imageViews.size() ? imageViews.size() : mediaFiles.size();
+ int count = Math.min(mediaFiles.size(), imageViews.size());
for (int i = 0; i < count; i++) {
Mediafile mediaFileTmp = mediaFiles.get(i);
File file = FileUtil.getFileFromMediaFile(mediaFileTmp);
if (file.exists()) {
- SetImageTask task1 = new SetImageTask(file, imageViews.get(i), (Activity) context);
+ SetImageTask task1 = new SetImageTask(file, imageViews.get(i), (Activity) activity);
task1.execute();
} else {
- DownloadAndSetImageTask task = new DownloadAndSetImageTask(mediaFileTmp, imageViews.get(i), context);
+ DownloadAndSetImageTask task = new DownloadAndSetImageTask(mediaFileTmp, imageViews.get(i), activity);
task.execute();
}
}
diff --git a/app/src/main/res/layout/activity_upload_media_files.xml b/app/src/main/res/layout/activity_upload_media_files.xml
index 568203b..8f12a0f 100644
--- a/app/src/main/res/layout/activity_upload_media_files.xml
+++ b/app/src/main/res/layout/activity_upload_media_files.xml
@@ -14,12 +14,12 @@
android:layout_height="50dp"
android:textColor="@color/white"
android:text="涓婁紶"/>
+
<android.support.v7.widget.RecyclerView
android:layout_above="@id/tv_upload"
android:id="@+id/rv_main"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- ></android.support.v7.widget.RecyclerView>
+ android:layout_height="match_parent" />
<android.support.v7.widget.CardView
android:id="@+id/cv_wait"
android:layout_width="70dp"
diff --git a/app/src/main/res/layout/fragment_inspection.xml b/app/src/main/res/layout/fragment_inspection.xml
deleted file mode 100644
index 5236111..0000000
--- a/app/src/main/res/layout/fragment_inspection.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- tools:context="cn.flightfeather.thirdapp.fragment.InspectionFragment">
-
- <!-- TODO: Update blank fragment layout -->
- <include layout="@layout/fragment_inspection_content"/>
- <RelativeLayout
- android:id="@+id/rl_select_Task"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/white"
- android:layout_alignParentTop="true"
- android:layout_alignParentStart="true">
- <LinearLayout
- android:id="@+id/ll_tool_bar"
- android:visibility="visible"
- android:layout_width="match_parent"
- android:layout_height="@dimen/actionbarHeight"
- android:orientation="horizontal"
- android:background="@color/colorPrimary"
- android:paddingLeft="13dp">
- <TextView
- android:id="@+id/tv_title"
- android:paddingTop="13dp"
- android:paddingBottom="13dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="2017骞�10鏈�10鏃�"
- android:textColor="@color/white"
- android:textSize="17dp"/>
- <Spinner
- android:id="@+id/sp_select_month_task"
- android:layout_marginLeft="14dp"
- android:layout_marginRight="-6dp"
- android:layout_weight="1"
- android:layout_width="0dp"
- android:layout_height="match_parent">
- </Spinner>
- <ImageView
- android:id="@+id/iv_upload"
- android:layout_gravity="center_vertical"
- android:layout_width="34dp"
- android:layout_height="34dp"
- android:layout_marginRight="6dp"
- android:background="@drawable/selector_icon_upload"/>
- </LinearLayout>
-
-
- <com.haibin.oldcalendarview.CalendarLayout
- android:layout_below="@id/ll_tool_bar"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:background="#fff"
- app:calendar_content_view_id="@+id/recyclerView">
-
- <com.haibin.oldcalendarview.CalendarView
- android:id="@+id/calendarView"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="#fff"
- app:current_month_text_color="#333333"
- app:min_year="2004"
- app:other_month_text_color="#e1e1e1"
- app:scheme_text="鍋�"
- app:scheme_text_color="#fff"
- app:scheme_theme_color="#128c4b"
- app:selected_text_color="#333"
- app:selected_theme_color="#108cd4"
- app:week_background="#fff"
- app:week_text_color="#111" />
-
- <android.support.v7.widget.RecyclerView
- android:id="@+id/recyclerView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/shap_stroke_top" />
- </com.haibin.oldcalendarview.CalendarLayout>
- </RelativeLayout>
-
-
-<android.support.design.widget.FloatingActionButton
- android:id="@+id/fab_map"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_centerHorizontal="true"
- app:fabSize="mini"
- android:layout_marginBottom="16dp"
- android:src="@drawable/icon_map_white"
- app:backgroundTint="@color/colorPrimary"/>
-
-</RelativeLayout>
-
--
Gitblit v1.9.3