DownloadAndSetImageTask和SetImageTask两个类由于在子线程执行,会经常出现activity关闭后继续执行导致报错崩溃问题,修复此bug
| | |
| | | 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 |
| | |
| | | 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); |
| | |
| | | } |
| | | 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)); |
| | |
| | | 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); |
| | | |
| | |
| | | //å·²æ´æ¹çå¾ç |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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)); |
| | |
| | | pb_uploading.setMax(photoTotal); |
| | | pb_uploading.setProgress(photoUploaded); |
| | | tv_status.setText("å缩ä¸..."); |
| | | if (uploadingDialog2 != null && !uploadingDialog2.isShowing()) { |
| | | uploadingDialog2.show(); |
| | | } else { |
| | | uploadingDialog2 = uploadingDialog.show(); |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | //å¼å§ä¸ä¼ |
| | | public void startUplaod(List<File> outputFileList){ |
| | |
| | | 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. |
| | |
| | | @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); |
| | |
| | | |
| | | @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)); |
| | | } |
| | |
| | | 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; |
| | |
| | | |
| | | 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 |
| | |
| | | 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 { |
| | |
| | | // 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"); |
| | | } |
| | |
| | | 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; |
| | |
| | | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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(); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | void initView() { |
| | | if (subtask == null) return; |
| | | tv_info.setText(subtask.getName()); |
| | | tv_address.setText(subtask.getScenseaddress()); |
| | | try { |
| | |
| | | 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 |
| | | |
| | |
| | | it.dispose() |
| | | } |
| | | } |
| | | Glide.with(applicationContext).pauseRequests() |
| | | super.onDestroy() |
| | | } |
| | | |
| | |
| | | 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 |
| | |
| | | when { |
| | | i < picSize -> { |
| | | imageViewList[i].setOnClickListener(viewPhotoClickListener(i)) |
| | | // fixme: 2019/8/2 æ¤å¤ç»imageVIew设置å¾çå¨å代ç 䏿¯èªå®ä¹äºä¸ä¸ªAsyncTaskï¼ä¹åå¯ä»¥ç¨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)) |
| | |
| | | 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() |
| | |
| | | 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.* |
| | |
| | | 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() |
| | |
| | | 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() |
| | |
| | | VIEW_PHOTO -> { |
| | | //æ¥çä¸´æ¶ææå¾çå¯ä»¥å é¤ |
| | | data?.getIntExtra("position", -1)?.let { |
| | | if (it > -1) { |
| | | val size = viewModel.mediaFileList.value?.size ?: 0 |
| | | if (it > -1 && it < size) { |
| | | viewModel.mediaFileList.value?.get(it)?.let {m -> |
| | | deleteMediaFileList.add(m) |
| | | } |
| | | } else { |
| | | toast("è¦å é¤çå¾çä¸åå¨") |
| | | } |
| | | } |
| | | } |
| | |
| | | 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 |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import butterknife.BindView; |
| | | import butterknife.ButterKnife; |
| | |
| | | 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; |
| | |
| | | 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++; |
| | | } |
| | |
| | | |
| | | 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<>(); |
| | |
| | | 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()) { |
| | |
| | | |
| | | //<editor-fold desc="ç¹å»äºä»¶"> |
| | | private void refreshProblemStatus() { |
| | | //æ´æ¹å¾çå
¨å é¤åï¼é®é¢éåæªæ´æ¹å®¡æ ¸éè¿ç¶æ |
| | | 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.setChangecatalog(Domain.UNPROMISE_CHANGE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //æäº¤é®é¢ |
| | | Dialog loadingDialog; |
| | |
| | | // } |
| | | 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(); |
| | | } |
| | | }); |
| | | }else { |
| | | Toast.makeText(application, R.string.take_one_change_photo_at_least, Toast.LENGTH_SHORT).show(); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private void upLoadPic() { |
| | | |
| | | //çéâæªä¸ä¼ âçå¾ç |
| | | List<Mediafile> mediafiles = new ArrayList<>(); |
| | | for (Mediafile m : this.mediafileListChange) { |
| | | if (m.getRemark().equals("æªä¸ä¼ ")) { |
| | | mediafiles.add(m); |
| | | } |
| | | } |
| | | |
| | | PhotoUtil photoUtil = new PhotoUtil(mediafiles.size(), application, new OnUpLoadListener() { |
| | | private void uploadProblem() { |
| | | refreshProblemStatus(); |
| | | Call<ResponseBody> updateProblemList = application.getRetrofit().create(ProblemListService.class).updateProblemList(this.problemlistVo); |
| | | updateProblemList.enqueue(new Callback<ResponseBody>() { |
| | | @Override |
| | | public void onSuccess() { |
| | | Toast.makeText(application, "ä¸ä¼ æå", Toast.LENGTH_SHORT).show(); |
| | | 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(); |
| | | } |
| | |
| | | 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() { |
| | | |
| | | //çéâæªä¸ä¼ âçå¾ç |
| | | List<Mediafile> mediafiles = new ArrayList<>(); |
| | | for (Mediafile m : this.mediafileListChange) { |
| | | if (m.getRemark().equals("æªä¸ä¼ ")) { |
| | | mediafiles.add(m); |
| | | } |
| | | } |
| | | |
| | | PhotoUtil photoUtil = new PhotoUtil(mediafiles.size(), application, new OnUpLoadListener() { |
| | | @Override |
| | | public void onSuccess() { |
| | | 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(); |
| | | } |
| | | }); |
| | | |
| | |
| | | * æ°å¢åºæ¯ä¿¡æ¯ |
| | | */ |
| | | fun putScene(scene: Scense, resultCallBack: ResultCallBack<ResponseBody>) { |
| | | sceneDao.insert(scene) |
| | | retrofit.create(ScenseService::class.java).putScense(scene) |
| | | .enqueue(ResponseBodyCallBack(resultCallBack)) |
| | | } |
| | |
| | | * æ´æ°åºæ¯ä¿¡æ¯ |
| | | */ |
| | | fun updateScene(scene: Scense, resultCallBack: ResultCallBack<ResponseBody>) { |
| | | sceneDao.update(scene) |
| | | retrofit.create(ScenseService::class.java).updateScense(scene) |
| | | .enqueue(ResponseBodyCallBack(resultCallBack)) |
| | | } |
| | |
| | | * æ¹éæ´æ°åºæ¯ä¿¡æ¯ |
| | | */ |
| | | fun updateSceneList(sceneList: ArrayList<Scense>, resultCallBack: ResultCallBack<ResponseBody>) { |
| | | sceneList.forEach { |
| | | sceneDao.update(it) |
| | | } |
| | | retrofit.create(ScenseService::class.java).updateSceneList(sceneList) |
| | | .enqueue(ResponseBodyCallBack(resultCallBack)) |
| | | } |
| | |
| | | */ |
| | | class SceneDao { |
| | | |
| | | fun insert(scene: Scense) { |
| | | DbFactory.getInstance().scenseDao.insert(scene) |
| | | } |
| | | |
| | | /** |
| | | * æ´æ°åºæ¯ä¿¡æ¯ |
| | | */ |
| | |
| | | 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; |
| | |
| | | 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(); |
| | | } |
| | |
| | | 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. |
| | | * 设置å¾ççtask |
| | | * |
| | | */ |
| | | |
| | | 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); |
| | | this.activity = activity; |
| | | } |
| | | |
| | | |
| | | return bmSmall; |
| | | 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); |
| | | } |
| | | |
| | | |
| | | |
| | | @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(); |
| | | // } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | 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; |
| | |
| | | * ç»å®ImageViewåå¾çï¼æ¬å°å è½½æèç½å è½½æ¾ç¤º(é对åºå®æ°éçImageView) |
| | | * @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(); |
| | | } |
| | | } |
| | |
| | | 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" |