fix: 充电站拍照过程优化

This commit is contained in:
XiaoYan 2021-08-06 23:10:49 +08:00
parent ec501bc6d2
commit e2cbf5fb4e

View File

@ -4,8 +4,10 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.provider.MediaStore;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -63,6 +65,8 @@ import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.ui.view.ContactView;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.PhotoPathUtil;
import com.navinfo.outdoor.util.PhotoUtils;
import com.navinfo.outdoor.util.ToastUtil;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import org.greenrobot.eventbus.EventBus;
@ -120,6 +124,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
// private Integer chargingPileBody;
private ArrayList<File> chargingStationList;
// private ArrayList<File> fileList;
private File photoFile; // 拍照保存的路径
public static ChargingStationFragment newInstance(Bundle bundle) {
ChargingStationFragment fragment = new ChargingStationFragment();
@ -780,22 +785,32 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
break;
case R.id.rl_panorama:
Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE");
photoFile = PhotoUtils.showPhotoFile("a", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
intentPanorama.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intentPanorama, 101);
break;
case R.id.rl_name:
Intent intentName = new Intent("android.media.action.IMAGE_CAPTURE");
photoFile = PhotoUtils.showPhotoFile("b", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
intentName.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intentName, 102);
break;
case R.id.rl_internal_photos:
Intent intentInternal = new Intent("android.media.action.IMAGE_CAPTURE");
photoFile = PhotoUtils.showPhotoFile("c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
intentInternal.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intentInternal, 103);
break;
case R.id.rl_else:
Intent intentElse = new Intent("android.media.action.IMAGE_CAPTURE");
photoFile = PhotoUtils.showPhotoFile("d", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
intentElse.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intentElse, 104);
break;
case R.id.rl_scutcheon:
Intent intentScutcheon = new Intent("android.media.action.IMAGE_CAPTURE");
photoFile = PhotoUtils.showPhotoFile("e", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
intentScutcheon.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intentScutcheon, 105);
break;
case R.id.linear_charging_pile:
@ -1116,11 +1131,13 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 101 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "a", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
tvPanorama.setTag(takePhotoPath);
ivPanorama.setImageBitmap(bitmap);//显示图像
if (photoFile == null || !photoFile.exists()) {
ToastUtil.showShort(getActivity(), "取消拍照");
return;
}
String photoPath = PhotoUtils.showPhotoAndGetPath(photoFile, ivPanorama);
tvPanorama.setTag(photoPath);
photoFile = null;
/* int height = bitmap.getHeight();
int width = bitmap.getWidth();
if (height > width) {
@ -1137,11 +1154,13 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}*/
} else if (requestCode == 102 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "b", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
tvName.setTag(takePhotoPath);
ivName.setImageBitmap(bitmap);//显示图像
if (photoFile == null || !photoFile.exists()) {
ToastUtil.showShort(getActivity(), "取消拍照");
return;
}
String photoPath = PhotoUtils.showPhotoAndGetPath(photoFile, ivName);
tvName.setTag(photoPath);
photoFile = null;
/*int height = bitmap.getHeight();
int width = bitmap.getWidth();
if (height > width) {
@ -1158,11 +1177,13 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}*/
} else if (requestCode == 103 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
tvInternal.setTag(takePhotoPath);
ivInternal.setImageBitmap(bitmap);//显示图像
if (photoFile == null || !photoFile.exists()) {
ToastUtil.showShort(getActivity(), "取消拍照");
return;
}
String photoPath = PhotoUtils.showPhotoAndGetPath(photoFile, ivInternal);
tvInternal.setTag(photoPath);
photoFile = null;
/*int height = bitmap.getHeight();
int width = bitmap.getWidth();
if (height > width) {
@ -1179,11 +1200,13 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}*/
} else if (requestCode == 104 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "d", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
tvElse.setTag(takePhotoPath);
ivElse.setImageBitmap(bitmap);//显示图像
if (photoFile == null || !photoFile.exists()) {
ToastUtil.showShort(getActivity(), "取消拍照");
return;
}
String photoPath = PhotoUtils.showPhotoAndGetPath(photoFile, ivElse);
tvElse.setTag(photoPath);
photoFile = null;
/* int height = bitmap.getHeight();
int width = bitmap.getWidth();
if (height > width) {
@ -1200,11 +1223,13 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}*/
} else if (requestCode == 105 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "e", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
tvScutcheon.setTag(takePhotoPath);
ivScutcheon.setImageBitmap(bitmap);//显示图像
if (photoFile == null || !photoFile.exists()) {
ToastUtil.showShort(getActivity(), "取消拍照");
return;
}
String photoPath = PhotoUtils.showPhotoAndGetPath(photoFile, ivScutcheon);
tvScutcheon.setTag(photoPath);
photoFile = null;
/* int height = bitmap.getHeight();
int width = bitmap.getWidth();
if (height > width) {