Merge branch 'master' of gitee.com:navinfo-out-door/navinfo-out-door-data-collect

This commit is contained in:
XiaoYan 2021-08-06 23:11:03 +08:00
commit 1a298b8be0
5 changed files with 251 additions and 84 deletions

View File

@ -4,8 +4,10 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.provider.MediaStore;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -51,6 +53,7 @@ import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.PhotoPathUtil; import com.navinfo.outdoor.util.PhotoPathUtil;
import com.navinfo.outdoor.util.PhotoUtils;
import com.navinfo.outdoor.util.PictureUtil; import com.navinfo.outdoor.util.PictureUtil;
import com.navinfo.outdoor.util.ToastUtil; import com.navinfo.outdoor.util.ToastUtil;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
@ -109,6 +112,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
private ArrayList<File> phoneLists; private ArrayList<File> phoneLists;
private PoiEntity poiEntity; private PoiEntity poiEntity;
private File file;
public static ChargingPileFragment newInstance(Bundle bundle) { public static ChargingPileFragment newInstance(Bundle bundle) {
ChargingPileFragment fragment = new ChargingPileFragment(); ChargingPileFragment fragment = new ChargingPileFragment();
@ -796,45 +800,65 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
break; break;
case R.id.rl_panorama: case R.id.rl_panorama:
Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("a",latLng);
intentPanorama.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentPanorama, 101); startActivityForResult(intentPanorama, 101);
initPileSharePre(); initPileSharePre();
break; break;
case R.id.rl_coding: case R.id.rl_coding:
Intent intentCoding = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentCoding = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("b", latLng);
intentCoding.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentCoding, 102); startActivityForResult(intentCoding, 102);
initPileSharePre(); initPileSharePre();
break; break;
case R.id.rl_equipment: case R.id.rl_equipment:
Intent intentEquipment = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentEquipment = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("c", latLng);
intentEquipment.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentEquipment, 103); startActivityForResult(intentEquipment, 103);
initPileSharePre(); initPileSharePre();
break; break;
case R.id.rl_facility: case R.id.rl_facility:
Intent intentFacility = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentFacility = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("c", latLng);
intentFacility.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentFacility, 104); startActivityForResult(intentFacility, 104);
break; break;
case R.id.rl_scutcheon: case R.id.rl_scutcheon:
Intent intentScutcheon = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentScutcheon = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("c",latLng);
intentScutcheon.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentScutcheon, 105); startActivityForResult(intentScutcheon, 105);
break; break;
case R.id.rl_device: case R.id.rl_device:
Intent intentDevice = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentDevice = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("c", latLng);
intentDevice.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentDevice, 106); startActivityForResult(intentDevice, 106);
break; break;
case R.id.rl_usable: case R.id.rl_usable:
Intent intentUsable = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentUsable = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("d", latLng);
intentUsable.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentUsable, 107); startActivityForResult(intentUsable, 107);
break; break;
case R.id.rl_available: case R.id.rl_available:
Intent intentAvailable = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentAvailable = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("d", latLng);
intentAvailable.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentAvailable, 108); startActivityForResult(intentAvailable, 108);
break; break;
case R.id.rl_parking: case R.id.rl_parking:
Intent intentParking = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentParking = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("e", latLng);
intentParking.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentParking, 109); startActivityForResult(intentParking, 109);
break; break;
case R.id.rl_number: case R.id.rl_number:
Intent intentNumber = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentNumber = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("e",latLng);
intentNumber.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentNumber, 110); startActivityForResult(intentNumber, 110);
break; break;
@ -928,11 +952,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 101 && resultCode == RESULT_OK) { if (requestCode == 101 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
tvPanorama.setTag(takePhotoPath1);
ivPanorama.setImageBitmap(bitmap);//显示图像 }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivPanorama);
tvPanorama.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {
@ -949,11 +977,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}*/ }*/
} else if (requestCode == 102 && resultCode == RESULT_OK) { } else if (requestCode == 102 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "b", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
tvCoding.setTag(takePhotoPath2);
ivCoding.setImageBitmap(bitmap);//显示图像 }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivCoding);
tvCoding.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {
@ -970,11 +1002,16 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}*/ }*/
} else if (requestCode == 103 && resultCode == RESULT_OK) { } else if (requestCode == 103 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath3 = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
ivEquipment.setImageBitmap(bitmap);//显示图像
tvEquipment.setTag(takePhotoPath3); }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivEquipment);
tvEquipment.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {
@ -991,11 +1028,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}*/ }*/
} else if (requestCode == 104 && resultCode == RESULT_OK) { } else if (requestCode == 104 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath4 = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
tvFacility.setTag(takePhotoPath4);
ivFacility.setImageBitmap(bitmap);//显示图像 }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivFacility);
tvFacility.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {
@ -1012,11 +1053,16 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}*/ }*/
} else if (requestCode == 105 && resultCode == RESULT_OK) { } else if (requestCode == 105 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath5 = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
tvScutcheon.setTag(takePhotoPath5);
ivScutcheon.setImageBitmap(bitmap);//显示图像 }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivScutcheon);
tvScutcheon.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {
@ -1033,11 +1079,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}*/ }*/
} else if (requestCode == 106 && resultCode == RESULT_OK) { } else if (requestCode == 106 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath6 = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
tvDevice.setTag(takePhotoPath6);
ivDevice.setImageBitmap(bitmap);//显示图像 }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivDevice);
tvDevice.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {
@ -1054,11 +1104,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}*/ }*/
} else if (requestCode == 107 && resultCode == RESULT_OK) { } else if (requestCode == 107 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath7 = PhotoPathUtil.getTakePhotoPath(data, "d", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
tvUsable.setTag(takePhotoPath7);
ivUsable.setImageBitmap(bitmap);//显示图像 }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivUsable);
tvUsable.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {
@ -1075,11 +1129,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}*/ }*/
} else if (requestCode == 108 && resultCode == RESULT_OK) { } else if (requestCode == 108 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath8 = PhotoPathUtil.getTakePhotoPath(data, "d", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
tvAvailable.setTag(takePhotoPath8);
ivAvailable.setImageBitmap(bitmap);//显示图像 }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivAvailable);
tvAvailable.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {
@ -1096,11 +1154,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}*/ }*/
} else if (requestCode == 109 && resultCode == RESULT_OK) { } else if (requestCode == 109 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath9 = PhotoPathUtil.getTakePhotoPath(data, "e", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
ivParking.setImageBitmap(bitmap);//显示图像
tvParking.setTag(takePhotoPath9); }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivParking);
tvParking.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {
@ -1117,11 +1179,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}*/ }*/
} else if (requestCode == 110 && resultCode == RESULT_OK) { } else if (requestCode == 110 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
takePhotoPath10 = PhotoPathUtil.getTakePhotoPath(data, "e", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); return;
ivNumber.setImageBitmap(bitmap);//显示图像
tvNumber.setTag(takePhotoPath10); }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivNumber);
tvNumber.setTag(s);
}
file=null;
/* int height = bitmap.getHeight(); /* int height = bitmap.getHeight();
int width = bitmap.getWidth(); int width = bitmap.getWidth();
if (height > width) { if (height > width) {

View File

@ -4,8 +4,10 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.provider.MediaStore;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -21,6 +23,7 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -54,6 +57,7 @@ import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.PhotoPathUtil; import com.navinfo.outdoor.util.PhotoPathUtil;
import com.navinfo.outdoor.util.PhotoUtils;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -92,6 +96,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
private int station_type = 5; private int station_type = 5;
private ArrayList<File> otherUploadList; private ArrayList<File> otherUploadList;
private CheckBox checkPot; private CheckBox checkPot;
private File file;
public static OtherFragment newInstance(Bundle bundle) { public static OtherFragment newInstance(Bundle bundle) {
OtherFragment fragment = new OtherFragment(); OtherFragment fragment = new OtherFragment();
@ -325,13 +330,15 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
switch (v.getId()) { switch (v.getId()) {
case R.id.rl_picture: case R.id.rl_picture:
Intent intentPicture = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentPicture = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("a", latLng);
intentPicture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentPicture, 101); startActivityForResult(intentPicture, 101);
initOtherSharePre();
break; break;
case R.id.rl_pictures: case R.id.rl_pictures:
Intent intentPictures = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentPictures = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("b",latLng);
intentPictures.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentPictures, 102); startActivityForResult(intentPictures, 102);
initOtherSharePre();
break; break;
case R.id.btn_other_local: case R.id.btn_other_local:
initPoiSaveLocal(false); initPoiSaveLocal(false);
@ -425,7 +432,6 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
} }
}); });
} }
private void otherUploadByNet(int body, List<File> otherUploadList) { private void otherUploadByNet(int body, List<File> otherUploadList) {
if (body == 0) { if (body == 0) {
Toast.makeText(getActivity(), "没有保存本地", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "没有保存本地", Toast.LENGTH_SHORT).show();
@ -534,6 +540,11 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
dismissDialog(); dismissDialog();
} }
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
initOtherSharePre();
}
/** /**
* 防止当页面崩溃后出现数据丢失 * 防止当页面崩溃后出现数据丢失
*/ */
@ -559,19 +570,25 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 101 && resultCode == RESULT_OK) { if (requestCode == 101 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
//照片路径 return;
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "a", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); }else {
tvPicture.setTag(takePhotoPath); String s = PhotoUtils.showPhotoAndGetPath(file, ivPicture);
ivPicture.setImageBitmap(bitmap);//显示图像 tvPicture.setTag(s);
}
file=null;
} else if (requestCode == 102 && resultCode == RESULT_OK) { } else if (requestCode == 102 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
//照片路径 //照片路径
String takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "b", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); if (file == null || !file.exists()) {
tvPictures.setTag(takePhotoPath2); Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
ivPictures.setImageBitmap(bitmap);//显示图像 return;
}else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivPictures);
tvPictures.setTag(s);
}
file=null;
} }
} }

View File

@ -62,6 +62,7 @@ import com.navinfo.outdoor.ui.view.ContactView;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.NetWorkUtils; import com.navinfo.outdoor.util.NetWorkUtils;
import com.navinfo.outdoor.util.PhotoPathUtil; import com.navinfo.outdoor.util.PhotoPathUtil;
import com.navinfo.outdoor.util.PhotoUtils;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -109,6 +110,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
private ContactView contactView; private ContactView contactView;
private ArrayList<File> poiPicList; private ArrayList<File> poiPicList;
private String tagPanorama; private String tagPanorama;
private File file;
public static PoiFragment newInstance(Bundle bundle) { public static PoiFragment newInstance(Bundle bundle) {
PoiFragment fragment = new PoiFragment(); PoiFragment fragment = new PoiFragment();
@ -588,7 +590,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
break; break;
case R.id.rl_panorama: case R.id.rl_panorama:
Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE");
File file = new File(Constant.PICTURE_FOLDER+"/aaaaaa.jpg"); file = PhotoUtils.showPhotoFile("a",latLng);
intentPanorama.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); intentPanorama.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentPanorama, 101); startActivityForResult(intentPanorama, 101);
break; break;

View File

@ -4,7 +4,9 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@ -28,7 +30,9 @@ import com.navinfo.outdoor.base.BaseFragment;
import com.navinfo.outdoor.bean.NameAuthenticationBean; import com.navinfo.outdoor.bean.NameAuthenticationBean;
import com.navinfo.outdoor.http.DialogCallback; import com.navinfo.outdoor.http.DialogCallback;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.PhotoPathUtil; import com.navinfo.outdoor.util.PhotoPathUtil;
import com.navinfo.outdoor.util.PhotoUtils;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -57,6 +61,7 @@ public class UserAttestationFragment extends BaseFragment implements View.OnClic
private ImageView ivHera3; private ImageView ivHera3;
private TextView tvCard3; private TextView tvCard3;
private SharedPreferences.Editor navInfoEditor; private SharedPreferences.Editor navInfoEditor;
private File file;
public static UserAttestationFragment newInstance(Bundle bundle) { public static UserAttestationFragment newInstance(Bundle bundle) {
@ -111,14 +116,20 @@ public class UserAttestationFragment extends BaseFragment implements View.OnClic
break; break;
case R.id.iv_attestation1: case R.id.iv_attestation1:
Intent ivAttestation1 = new Intent("android.media.action.IMAGE_CAPTURE"); Intent ivAttestation1 = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("a", null);
ivAttestation1.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(ivAttestation1, 100); startActivityForResult(ivAttestation1, 100);
break; break;
case R.id.iv_attestation2: case R.id.iv_attestation2:
Intent ivAttestation2 = new Intent("android.media.action.IMAGE_CAPTURE"); Intent ivAttestation2 = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("a", null);
ivAttestation2.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(ivAttestation2, 200); startActivityForResult(ivAttestation2, 200);
break; break;
case R.id.iv_attestation3: case R.id.iv_attestation3:
Intent ivAttestation3 = new Intent("android.media.action.IMAGE_CAPTURE"); Intent ivAttestation3 = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("a", null);
ivAttestation3.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(ivAttestation3, 300); startActivityForResult(ivAttestation3, 300);
break; break;
case R.id.btn_attestation: case R.id.btn_attestation:
@ -247,10 +258,15 @@ public class UserAttestationFragment extends BaseFragment implements View.OnClic
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 100 && resultCode == RESULT_OK) { if (requestCode == 100 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 if (file == null || !file.exists()) {
String takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a", ""); Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
ivAttestation1.setTag(takePhotoPath1); return;
ivAttestation1.setImageBitmap(bitmap);//显示图像
}else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivAttestation1);
ivAttestation1.setTag(s);
}
file=null;
ivHera1.setVisibility(View.GONE); ivHera1.setVisibility(View.GONE);
tvCard1.setVisibility(View.GONE); tvCard1.setVisibility(View.GONE);
// int height = bitmap.getHeight(); // int height = bitmap.getHeight();
@ -268,11 +284,15 @@ public class UserAttestationFragment extends BaseFragment implements View.OnClic
// } // }
} }
if (requestCode == 200 && resultCode == RESULT_OK) { if (requestCode == 200 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
String takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "a", ""); return;
ivAttestation2.setTag(takePhotoPath2);
ivAttestation2.setImageBitmap(bitmap);//显示图像 }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivAttestation2);
ivAttestation2.setTag(s);
}
file=null;
ivHera2.setVisibility(View.GONE); ivHera2.setVisibility(View.GONE);
tvCard2.setVisibility(View.GONE); tvCard2.setVisibility(View.GONE);
// int height = bitmap.getHeight(); // int height = bitmap.getHeight();
@ -290,11 +310,15 @@ public class UserAttestationFragment extends BaseFragment implements View.OnClic
// } // }
} }
if (requestCode == 300 && resultCode == RESULT_OK) { if (requestCode == 300 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值 if (file == null || !file.exists()) {
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 Toast.makeText(getContext(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
String takePhotoPath3 = PhotoPathUtil.getTakePhotoPath(data, "a", ""); return;
ivAttestation3.setTag(takePhotoPath3);
ivAttestation3.setImageBitmap(bitmap);//显示图像 }else {
String s = PhotoUtils.showPhotoAndGetPath(file, ivAttestation3);
ivAttestation3.setTag(s);
}
file=null;
ivHera3.setVisibility(View.GONE); ivHera3.setVisibility(View.GONE);
tvCard3.setVisibility(View.GONE); tvCard3.setVisibility(View.GONE);
// int height = bitmap.getHeight(); // int height = bitmap.getHeight();

View File

@ -6,25 +6,83 @@ import android.widget.ImageView;
import androidx.exifinterface.media.ExifInterface; import androidx.exifinterface.media.ExifInterface;
import com.bumptech.glide.Glide;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.BitSet;
import static org.greenrobot.eventbus.EventBus.TAG; import static org.greenrobot.eventbus.EventBus.TAG;
public class PhotoUtils { public class PhotoUtils {
private static int numbits = 6 * 5;
// 为了加密所以改了base32编码代码表
final static char[] digits = { 'd', 'f', 'g', 'y', 'n', 't', 'u', 'v', 'q',
'b', '9', 's', 'z', '7', 'i', '2', 'h', '5', '0', 'p', '4', 'm',
'8', 'x', 'c', 'j', '6', 'e', '1', 'r', '3', 'k' };
public static String showPhotoAndGetPath(File file, ImageView imageView) { public static String showPhotoAndGetPath(File file, ImageView imageView) {
return null; Glide.with(imageView.getContext()).load(file).into(imageView);
return file.getAbsolutePath();
} }
public static File showPhotoFile(String d,String lat) {
long time=System.currentTimeMillis(); public static File showPhotoFile(String d, LatLng latLng) {
File file = new File(Constant.PICTURE_FOLDER, d+time+"_p"+lat+"_a"+0+".jpg"); String lat="";
if (latLng!=null){
lat= initEncode(latLng);
}
long time = System.currentTimeMillis();
File file = new File(Constant.PICTURE_FOLDER, d + time + "_p" + lat + "_a" + 0 + ".jpg");
return file; return file;
} }
public static String initEncode(LatLng latLng) {
BitSet latbits = getBits(latLng.latitude, -90, 90);
BitSet lonbits = getBits(latLng.longitude, -180, 180);
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < numbits; i++) {
buffer.append((lonbits.get(i)) ? '1' : '0');
buffer.append((latbits.get(i)) ? '1' : '0');
}
return base32(Long.parseLong(buffer.toString(), 2));
}
private static BitSet getBits(double lat, double floor, double ceiling) {
BitSet buffer = new BitSet(numbits);
for (int i = 0; i < numbits; i++) {
double mid = (floor + ceiling) / 2;
if (lat >= mid) {
buffer.set(i);
floor = mid;
} else {
ceiling = mid;
}
}
return buffer;
}
public static String base32(long i) {
char[] buf = new char[65];
int charPos = 64;
boolean negative = (i < 0);
if (!negative)
i = -i;
while (i <= -32) {
buf[charPos--] = digits[(int) (-(i % 32))];
i /= 32;
}
buf[charPos] = digits[(int) (-i)];
if (negative)
buf[--charPos] = '-';
return new String(buf, charPos, (65 - charPos));
}
/** /**
* 获取图片旋转角度 * 获取图片旋转角度
*
* @param filepath * @param filepath
* @return * @return
*/ */
@ -39,7 +97,7 @@ public class PhotoUtils {
if (exif != null) { if (exif != null) {
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
if (orientation != -1) { if (orientation != -1) {
switch(orientation) { switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90: case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90; degree = 90;
break; break;