图片存储问题,marker渲染

This commit is contained in:
wds 2021-06-29 18:28:30 +08:00
parent 5ad871a254
commit c65a11659d
8 changed files with 457 additions and 210 deletions

View File

@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
ndkVersion '23.0.7123448'
// ndkVersion '23.0.7123448'
defaultConfig {
applicationId "com.navinfo.outdoor"

View File

@ -1,8 +1,6 @@
package com.navinfo.outdoor.activity;
import android.content.Intent;
import android.os.Bundle;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.base.BaseActivity;
import com.navinfo.outdoor.fragment.AboutFragment;

View File

@ -73,7 +73,6 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
private Button btnSaveLocal;
private PoiDatabase poiDatabase;
private String inode;
private List<String> photoBean;
private CheckBox checkBoxLife, checkBoxRight;
private Spinner spinnerType, spinnerScutcheon, spinnerStake;
String[] type = new String[]{"地上五层", "地上四层", "地上三层", "地上二层", "地上一层", "地下一层", "地下二层", "地下三层", "地下四层", "地下五层"};
@ -390,61 +389,111 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}
int sign_exist = chargingPileEntity.getSign_exist();
spinnerScutcheon.setSelection(sign_exist, true);
if (sign_exist == 0) {
rlFacility.setBackgroundColor(Color.parseColor("#EFEDED"));
rlScutcheon.setVisibility(View.GONE);
rlDevice.setVisibility(View.GONE);
} else if (sign_exist == 1) {
rlFacility.setBackgroundColor(Color.parseColor("#03A9F4"));
rlScutcheon.setVisibility(View.VISIBLE);
rlDevice.setVisibility(View.VISIBLE);
}
int cp_availableState = chargingPileEntity.getCp_availableState();
spinnerStake.setSelection(cp_availableState, true);
int cp_floor = chargingPileEntity.getCp_floor();
spinnerType.setSelection(cp_floor, true);
if (chargingPileEntity.getPhotos() != null) {
photoBean.clear();
ArrayList<String> cList = new ArrayList<>();
ArrayList<String> dList = new ArrayList<>();
ArrayList<String> eList = new ArrayList<>();
for (int i = 0; i < chargingPileEntity.getPhotos().size(); i++) {
String photo = chargingPileEntity.getPhotos().get(i);
String[] split = photo.split("/");
char charAt = split[6].charAt(0);
if (charAt == 'a') {
if (split[split.length - 1].startsWith("a")) {
Glide.with(getActivity()).load(photo).into(ivPanorama);
photoBean.add(photo);
} else if (charAt == 'b') {
ivPanorama.setTag(photo);
} else if (split[split.length - 1].startsWith("b")) {
Glide.with(getActivity()).load(photo).into(ivCoding);
photoBean.add(photo);
} else if (charAt == 'c') {
char charAtc = split[6].charAt(1);
if (charAtc == '1') {
Glide.with(getActivity()).load(photo).into(ivEquipment);
photoBean.add(photo);
} else if (charAtc == '2') {
Glide.with(getActivity()).load(photo).into(ivFacility);
photoBean.add(photo);
} else if (charAtc == '3') {
Glide.with(getActivity()).load(photo).into(ivScutcheon);
photoBean.add(photo);
} else if (charAtc == '4') {
Glide.with(getActivity()).load(photo).into(ivDevice);
photoBean.add(photo);
}
} else if (charAt == 'd') {
char charAtd = split[6].charAt(1);
if (charAtd == '1') {
Glide.with(getActivity()).load(photo).into(ivUsable);
photoBean.add(photo);
} else if (charAtd == '2') {
Glide.with(getActivity()).load(photo).into(ivAvailable);
photoBean.add(photo);
}
} else if (charAt == 'e') {
char charAte =split[6].charAt(1);
if (charAte == '1') {
Glide.with(getActivity()).load(photo).into(ivParking);
photoBean.add(photo);
} else if (charAte == '2') {
Glide.with(getActivity()).load(photo).into(ivNumber);
photoBean.add(photo);
}
ivCoding.setTag(photo);
} else if (split[split.length - 1].startsWith("c")) {
cList.add(photo);
} else if (split[split.length - 1].startsWith("d")) {
dList.add(photo);
} else if (split[split.length - 1].startsWith("e")) {
eList.add(photo);
}
}
setCList(cList);
setDList(dList);
setEList(eList);
}
}
}
public void setCList(ArrayList<String> list) {
switch (list.size()) {
case 1:
Glide.with(getActivity()).load(list.get(0)).into(ivEquipment);
ivEquipment.setTag(list.get(0));
break;
case 2:
Glide.with(getActivity()).load(list.get(0)).into(ivEquipment);
ivEquipment.setTag(list.get(0));
Glide.with(getActivity()).load(list.get(1)).into(ivFacility);
ivFacility.setTag(list.get(1));
break;
case 3:
Glide.with(getActivity()).load(list.get(0)).into(ivEquipment);
ivEquipment.setTag(list.get(0));
Glide.with(getActivity()).load(list.get(1)).into(ivFacility);
ivFacility.setTag(list.get(1));
Glide.with(getActivity()).load(list.get(2)).into(ivScutcheon);
ivScutcheon.setTag(list.get(2));
break;
case 4:
Glide.with(getActivity()).load(list.get(0)).into(ivEquipment);
ivEquipment.setTag(list.get(0));
Glide.with(getActivity()).load(list.get(1)).into(ivFacility);
ivFacility.setTag(list.get(1));
Glide.with(getActivity()).load(list.get(2)).into(ivScutcheon);
ivScutcheon.setTag(list.get(2));
Glide.with(getActivity()).load(list.get(3)).into(ivDevice);
ivDevice.setTag(list.get(3));
break;
}
}
public void setDList(ArrayList<String> list) {
switch (list.size()) {
case 1:
Glide.with(getActivity()).load(list.get(0)).into(ivUsable);
ivUsable.setTag(list.get(0));
break;
case 2:
Glide.with(getActivity()).load(list.get(0)).into(ivUsable);
ivUsable.setTag(list.get(0));
Glide.with(getActivity()).load(list.get(1)).into(ivAvailable);
ivAvailable.setTag(list.get(1));
break;
}
}
public void setEList(ArrayList<String> list) {
switch (list.size()) {
case 1:
Glide.with(getActivity()).load(list.get(0)).into(ivParking);
ivParking.setTag(list.get(0));
break;
case 2:
Glide.with(getActivity()).load(list.get(0)).into(ivParking);
ivParking.setTag(list.get(0));
Glide.with(getActivity()).load(list.get(1)).into(ivNumber);
ivNumber.setTag(list.get(1));
break;
}
}
//禁用所有可操作性控件
private void disables() {
@ -457,9 +506,6 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
@Override
protected void initData() {
super.initData();
//存储图片地址
photoBean = new ArrayList<>();
}
@ -484,6 +530,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
if (all) {
//保存数据库
ChargingPileEntity chargingPileEntity = new ChargingPileEntity();
ArrayList<String> photoBean = new ArrayList<>();
if (inode == null || inode.equals("")) {
Toast.makeText(getActivity(), "请确定点位", Toast.LENGTH_SHORT).show();
return;
@ -500,12 +547,84 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
if (cp_floor != 0) {
chargingPileEntity.setCp_floor(cp_floor);
}
if (photoBean.size() < 4) {
Toast.makeText(getActivity(), "请拍照", Toast.LENGTH_SHORT).show();
String tagPanorama = (String) ivPanorama.getTag();
if (tagPanorama == null || tagPanorama.equals("")) {
Toast.makeText(getActivity(), "请拍照 全景图", Toast.LENGTH_SHORT).show();
return;
} else {
chargingPileEntity.setPhotos(photoBean);
photoBean.add(tagPanorama);
}
String tagCoding = (String) ivCoding.getTag();
if (tagCoding == null || tagCoding.equals("")) {
Toast.makeText(getActivity(), "请拍照 充电桩编码", Toast.LENGTH_SHORT).show();
return;
} else {
photoBean.add(tagCoding);
}
String tagEquipment = (String) ivEquipment.getTag();
if (tagEquipment == null || tagEquipment.equals("")) {
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
return;
} else {
photoBean.add(tagEquipment);
}
String tagFacility = (String) ivFacility.getTag();
if (sign_exist != 0) {
if (tagFacility == null || tagFacility.equals("")) {
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
return;
} else {
photoBean.add(tagFacility);
}
} else {
if (tagFacility != null || !tagFacility.equals("")) {
photoBean.add(tagFacility);
}
}
String tagScutcheon = (String) ivScutcheon.getTag();
if (sign_exist == 1) {
if (tagScutcheon == null || tagScutcheon.equals("")) {
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
return;
} else {
photoBean.add(tagScutcheon);
}
}
String tagDevice = (String) ivDevice.getTag();
if (sign_exist == 1) {
if (tagDevice == null || tagDevice.equals("")) {
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
return;
} else {
photoBean.add(tagDevice);
}
}
String tagUsable = (String) ivUsable.getTag();
if (tagUsable == null || tagUsable.equals("")) {
Toast.makeText(getActivity(), "请拍照 可用状态", Toast.LENGTH_SHORT).show();
return;
} else {
photoBean.add(tagUsable);
}
String tagAvailable = (String) ivAvailable.getTag();
if (tagAvailable != null || !tagAvailable.equals("")) {
photoBean.add(tagAvailable);
}
String tagParking = (String) ivParking.getTag();
if (tagParking == null || tagParking.equals("")) {
Toast.makeText(getActivity(), "请拍照 停车位编号", Toast.LENGTH_SHORT).show();
return;
} else {
photoBean.add(tagPanorama);
}
String tagNumber = (String) ivNumber.getTag();
if (tagNumber != null || !tagNumber.equals("")) {
photoBean.add(tagNumber);
}
chargingPileEntity.setPhotos(photoBean);
chargingPileEntity.setSign_exist(sign_exist);
chargingPileEntity.setCp_availableState(cp_availableState);
String describe = editDescribe.getText().toString().trim();
@ -612,6 +731,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型调用对应的put方法,
ChargingPileEntity chargingPileEntity = new ChargingPileEntity();
ArrayList<String> photo = new ArrayList<>();
if (inode != null) {
chargingPileEntity.setP(inode);
}
@ -622,9 +742,47 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
if (cp_floor != 0) {
chargingPileEntity.setCp_floor(cp_floor);
}
if (photoBean.size() > 0) {
chargingPileEntity.setPhotos(photoBean);
String tagPanorama = (String) ivPanorama.getTag();
if (tagPanorama != null) {
photo.add(tagPanorama);
}
String tagCoding = (String) ivCoding.getTag();
if (tagCoding != null) {
photo.add(tagCoding);
}
String tagEquipment = (String) ivEquipment.getTag();
if (tagEquipment != null) {
photo.add(tagEquipment);
}
String tagFacility = (String) ivFacility.getTag();
if (tagFacility != null) {
photo.add(tagFacility);
}
String tagScutcheon = (String) ivScutcheon.getTag();
if (tagScutcheon != null) {
photo.add(tagScutcheon);
}
String tagDevice = (String) ivDevice.getTag();
if (tagDevice != null) {
photo.add(tagDevice);
}
String tagUsable = (String) ivUsable.getTag();
if (tagUsable != null ) {
photo.add(tagUsable);
}
String tagAvailable = (String) ivAvailable.getTag();
if (tagAvailable != null) {
photo.add(tagAvailable);
}
String tagParking = (String) ivParking.getTag();
if (tagParking != null) {
photo.add(tagPanorama);
}
String tagNumber = (String) ivNumber.getTag();
if (tagNumber != null) {
photo.add(tagNumber);
}
chargingPileEntity.setPhotos(photo);
chargingPileEntity.setSign_exist(sign_exist);
chargingPileEntity.setCp_availableState(cp_availableState);
String describe = editDescribe.getText().toString().trim();
@ -662,7 +820,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "a");
photoBean.add(takePhotoPath);
ivPanorama.setTag(takePhotoPath);
ivPanorama.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 102 && resultCode == RESULT_OK) {
@ -682,7 +840,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "b");
photoBean.add(takePhotoPath);
ivCoding.setTag(takePhotoPath);
ivCoding.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 103 && resultCode == RESULT_OK) {
@ -701,9 +859,9 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c1");
photoBean.add(takePhotoPath);
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c");
ivEquipment.setImageBitmap(bitmap);//显示图像
ivEquipment.setTag(takePhotoPath);
}
} else if (requestCode == 104 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值
@ -721,8 +879,8 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c2");
photoBean.add(takePhotoPath);
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c");
ivFacility.setTag(takePhotoPath);
ivFacility.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 105 && resultCode == RESULT_OK) {
@ -741,8 +899,8 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c3");
photoBean.add(takePhotoPath);
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c");
ivScutcheon.setTag(takePhotoPath);
ivScutcheon.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 106 && resultCode == RESULT_OK) {
@ -761,8 +919,8 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c4");
photoBean.add(takePhotoPath);
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c");
ivDevice.setTag(takePhotoPath);
ivDevice.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 107 && resultCode == RESULT_OK) {
@ -781,8 +939,8 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "d1");
photoBean.add(takePhotoPath);
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "d");
ivUsable.setTag(takePhotoPath);
ivUsable.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 108 && resultCode == RESULT_OK) {
@ -801,8 +959,8 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "d2");
photoBean.add(takePhotoPath);
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "d");
ivAvailable.setTag(takePhotoPath);
ivAvailable.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 109 && resultCode == RESULT_OK) {
@ -821,9 +979,9 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "e1");
photoBean.add(takePhotoPath);
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "e");
ivParking.setImageBitmap(bitmap);//显示图像
ivParking.setTag(takePhotoPath);
}
} else if (requestCode == 110 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值
@ -841,10 +999,9 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "e2");
photoBean.add(takePhotoPath);
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "e");
ivNumber.setImageBitmap(bitmap);//显示图像
ivNumber.setTag(takePhotoPath);
}
}
}

View File

@ -85,7 +85,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
private PoiDatabase poiDatabase;
private PoiDao poiDao;
private String inode;
private List<Info> photoBean;
private CheckBox checkBoxLife;
private CheckBox checkBoxRight;
private String phone;
@ -97,7 +96,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
private ChargingPileAdapter chargingPileAdapter;
private int station_type = 0;
private boolean aBoolean = false;
private PoiEntity poiEntity;
private PoiEntity showPoiEntity;
private ChargingPileDao chargingPileDao;
@ -305,6 +303,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
//disables();
}
private void initShowPoi() {
// 添加信息
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
@ -333,27 +332,24 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}
if (showPoiEntity.getPhotoInfo() != null) {
photoBean.clear();
for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) {
String photo =showPoiEntity.getPhotoInfo().get(i).getPhoto();
String photo = showPoiEntity.getPhotoInfo().get(i).getPhoto();
String[] split = photo.split("/");
char charAt = split[6].charAt(0);
if (charAt=='a'){
if (split[split.length - 1].startsWith("a")) {
Glide.with(getActivity()).load(photo).into(ivPanorama);
photoBean.add(new Info(photo));
}else if (charAt=='b'){
ivPanorama.setTag(photo);
} else if (split[split.length - 1].startsWith("b")) {
Glide.with(getActivity()).load(photo).into(ivName);
photoBean.add(new Info(photo));
}else if (charAt=='c'){
ivName.setTag(photo);
} else if (split[split.length - 1].startsWith("c")) {
Glide.with(getActivity()).load(photo).into(ivInternal);
photoBean.add(new Info(photo));
}else if (charAt=='d'){
ivInternal.setTag(photo);
} else if (split[split.length - 1].startsWith("d")) {
Glide.with(getActivity()).load(photo).into(ivElse);
photoBean.add(new Info(photo));
}else if (charAt=='e'){
ivElse.setTag(photo);
} else if (split[split.length - 1].startsWith("e")) {
Glide.with(getActivity()).load(photo).into(ivScutcheon);
photoBean.add(new Info(photo));
ivScutcheon.setTag(photo);
}
}
}
@ -379,7 +375,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}).start();
}
ChargingPileEntity chargingPileEntity = (ChargingPileEntity) getArguments().getSerializable("chargingPileEntity");
if (chargingPileEntity!=null){
if (chargingPileEntity != null) {
Message obtains = Message.obtain();
obtains.what = Constant.CHARGING_STATION_PILE;
obtains.obj = chargingPileEntity;
@ -410,9 +406,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
poiBeans = new ArrayList<>();
//存储手机号
phoneData = new ArrayList<>();
//存储图片地址
photoBean = new ArrayList<>();
}
@ -442,7 +435,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
public void onGranted(List<String> permissions, boolean all) {
if (all) {
//保存数据库
poiEntity = new PoiEntity();
PoiEntity poiEntity = new PoiEntity();
List<Info> infoPhoto = new ArrayList<>();
String name = editNameContent.getText().toString().trim();//名称
if (name == null || name.equals("")) {
Toast.makeText(getActivity(), "请输入充电站 名称", Toast.LENGTH_SHORT).show();
@ -478,12 +472,44 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
} else {
poiEntity.setTelPhone(phoneData.get(0));
}
if (photoBean.size() != 6) {
Toast.makeText(getActivity(), "请拍照", Toast.LENGTH_SHORT).show();
String tagPanorama = (String) ivPanorama.getTag();
if (tagPanorama == null || tagPanorama.equals("")) {
Toast.makeText(getActivity(), "请拍照 全景图", Toast.LENGTH_SHORT).show();
return;
} else {
poiEntity.setPhotoInfo(photoBean);
infoPhoto.add(new Info(tagPanorama));
}
String tagName = (String) ivName.getTag();
if (tagName == null || tagName.equals("")) {
Toast.makeText(getActivity(), "请拍照 充电桩编码", Toast.LENGTH_SHORT).show();
return;
} else {
infoPhoto.add(new Info(tagName));
}
String tagInternal = (String) ivInternal.getTag();
if (tagInternal == null || tagInternal.equals("")) {
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
return;
} else {
infoPhoto.add(new Info(tagInternal));
}
String tagElse = (String) ivElse.getTag();
if (tagElse == null || tagElse.equals("")) {
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
return;
} else {
infoPhoto.add(new Info(tagElse));
}
String tagScutcheon = (String) ivScutcheon.getTag();
if (tagScutcheon == null || tagScutcheon.equals("")) {
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
return;
} else {
infoPhoto.add(new Info(tagScutcheon));
}
poiEntity.setPhotoInfo(infoPhoto);
poiEntity.setStation_type(station_type);
if (!aBoolean) {
Toast.makeText(getActivity(), "请添加桩", Toast.LENGTH_SHORT).show();
@ -569,7 +595,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
/**
* 防止当页面崩溃后出现数据丢失
*/
public void initStationSharePre(){
public void initStationSharePre() {
//获取SharedPreferences对象方法中两个参数的意思为第一个name
//表示文件名系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件第二个mode表示创建的模式通过查看
@ -579,7 +605,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型调用对应的put方法,
poiEntity = new PoiEntity();
PoiEntity poiEntity = new PoiEntity();
List<Info> infoPhoto = new ArrayList<>();
String name = editNameContent.getText().toString().trim();//名称
if (name != null || !name.equals("")) {
poiEntity.setName(name);
@ -588,7 +615,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
if (site != null || !site.equals("")) {
poiEntity.setAddress(site);
}
if (inode != null ) {
if (inode != null) {
String[] split = inode.split(",");
poiEntity.setX(split[0]);
poiEntity.setY(split[1]);
@ -600,9 +627,27 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
if (phoneData.size() > 0) {
poiEntity.setTelPhone(phoneData.get(0));
}
if (photoBean.size() > 0) {
poiEntity.setPhotoInfo(photoBean);
String tagPanorama = (String) ivPanorama.getTag();
if (tagPanorama != null) {
infoPhoto.add(new Info(tagPanorama));
}
String tagName = (String) ivName.getTag();
if (tagName != null) {
infoPhoto.add(new Info(tagName));
}
String tagInternal = (String) ivInternal.getTag();
if (tagInternal != null) {
infoPhoto.add(new Info(tagInternal));
}
String tagElse = (String) ivElse.getTag();
if (tagElse != null) {
infoPhoto.add(new Info(tagElse));
}
String tagScutcheon = (String) ivScutcheon.getTag();
if (tagScutcheon != null ) {
infoPhoto.add(new Info(tagScutcheon));
}
poiEntity.setPhotoInfo(infoPhoto);
poiEntity.setStation_type(station_type);
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
@ -617,7 +662,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
edit.putString("poiEntity", newPoiEntity);
//提交新值必须执行否则前面的操作都无效
edit.commit();
Log.d("TAG", "initPoiSharePre: "+newPoiEntity);
Log.d("TAG", "initPoiSharePre: " + newPoiEntity);
}
@Override
@ -639,8 +684,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"a");
photoBean.add(new Info(takePhotoPath));
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "a");
ivPanorama.setTag(takePhotoPath);
ivPanorama.setImageBitmap(bitmap);//显示图像
}
@ -660,8 +705,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"b");
photoBean.add(new Info(takePhotoPath));
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "b");
ivName.setTag(takePhotoPath);
ivName.setImageBitmap(bitmap);//显示图像
}
@ -681,8 +726,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"c");
photoBean.add(new Info(takePhotoPath));
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c");
ivInternal.setTag(takePhotoPath);
ivInternal.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 104 && resultCode == RESULT_OK) {
@ -701,8 +746,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"d");
photoBean.add(new Info(takePhotoPath));
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "d");
ivElse.setTag(takePhotoPath);
ivElse.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 105 && resultCode == RESULT_OK) {
@ -721,8 +766,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"e");
photoBean.add(new Info(takePhotoPath));
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "e");
ivScutcheon.setTag(takePhotoPath);
ivScutcheon.setImageBitmap(bitmap);//显示图像
}

View File

@ -62,20 +62,17 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
private Spinner spinnerOther;
String[] others = new String[]{"下拉选择", "门牌","道路施工","标牌采集","公交","其他"};
String[] others = new String[]{"下拉选择", "门牌", "道路施工", "标牌采集", "公交", "其他"};
private String inode;
private EditText editTaskName,editOtherDescribe;
private EditText editTaskName, editOtherDescribe;
private RelativeLayout rlPicture;
private ImageView ivPicture;
private RelativeLayout rlPictures;
private ImageView ivPictures;
private Button btnOtherLocal;
private Button btnOtherUploading;
private List<Info> photoBean;
private PoiDatabase poiDatabase;
private PoiDao poiDao;
private boolean aBoolean=false;
private boolean bBoolean=false;
private PoiEntity showPoiEntity;
public static OtherFragment newInstance(Bundle bundle) {
@ -88,6 +85,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
protected int getLayout() {
return R.layout.fragment_other;
}
@Override
public void onStart() {
super.onStart();
@ -96,6 +94,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
}
}
@Override
public void onResume() {
super.onResume();
@ -108,26 +107,27 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
@Override
public void onClick(View v) {
Bundle arguments = getArguments();
if (arguments!=null) {
isSliding= arguments.getBoolean("isSliding",true);
Log.d("TAG", "onCreatessss: "+isSliding);
if (arguments != null) {
isSliding = arguments.getBoolean("isSliding", true);
Log.d("TAG", "onCreatessss: " + isSliding);
}
if (isSliding) {
// 监听到返回按钮点击事件
Message obtain = Message.obtain();
obtain.what= Constant.TREASURE_FRAGMENT;
obtain.obj=isSliding;
obtain.what = Constant.TREASURE_FRAGMENT;
obtain.obj = isSliding;
EventBus.getDefault().post(obtain);
Message mainButtonVisiableMsg = Message.obtain();
mainButtonVisiableMsg.what= Constant.MAIN_BUTTON_VISIABLE;
mainButtonVisiableMsg.obj= View.VISIBLE;
mainButtonVisiableMsg.what = Constant.MAIN_BUTTON_VISIABLE;
mainButtonVisiableMsg.obj = View.VISIBLE;
EventBus.getDefault().post(mainButtonVisiableMsg);
}
onBackPressed();
}
});
}
@Override
protected void initView() {
super.initView();
@ -161,8 +161,11 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
public void onNothingSelected(AdapterView<?> parent) {
}
});
CheckBox checkPot = findViewById(R.id.check_pot);
checkPot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@ -190,6 +193,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
initShowPoi();
}
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.OTHER_WORD) {
@ -197,12 +201,10 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
Toast.makeText(getContext(), inode, Toast.LENGTH_SHORT).show();
}
}
@Override
protected void initData() {
super.initData();
//存储图片地址
photoBean = new ArrayList<>();
}
private void initShowPoi() {
@ -211,32 +213,25 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
if (showPoiEntity != null) {
String name = showPoiEntity.getName();//名称
if (name != null || !name.equals("")) {
editTaskName.setText(name + "");
}
editTaskName.setText(name + ""); }
String x = showPoiEntity.getX();
String y = showPoiEntity.getY();
if (x != null && y != null) {
inode = x + "," + y;
}
inode = x + "," + y; }
String describe = showPoiEntity.getDescribe();//任务描述
if (describe != null || !describe.equals("")) {
editOtherDescribe.setText(describe);
}
editOtherDescribe.setText(describe); }
if (showPoiEntity.getPhotoInfo() != null) {
photoBean.clear();
for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) {
String photo =showPoiEntity.getPhotoInfo().get(i).getPhoto();
String[] split = photo.split("/");
char charAt = split[6].charAt(0);
if (charAt=='a'){
Glide.with(getActivity()).load(photo).into(ivPicture);
photoBean.add(new Info(photo));
aBoolean=true;
}else if (charAt=='b'){
Glide.with(getActivity()).load(photo).into(ivPictures);
photoBean.add(new Info(photo));
bBoolean =true;
}
for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) {
String photo = showPoiEntity.getPhotoInfo().get(i).getPhoto();
String[] split = photo.split("/");
if (split[split.length - 1].startsWith("a")) {
Glide.with(getActivity()).load(photo).into(ivPicture);
ivPicture.setTag(photo);
} else if (split[split.length - 1].startsWith("b")) {
Glide.with(getActivity()).load(photo).into(ivPictures);
ivPictures.setTag(photo);
}
}
}
}
@ -265,6 +260,8 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
if (all) {
//保存数据库
PoiEntity poiEntity = new PoiEntity();
List<Info> infoList = new ArrayList<>();
String name = editTaskName.getText().toString().trim();//名称
if (name == null || name.equals("")) {
Toast.makeText(getActivity(), "请输入poi 名称", Toast.LENGTH_SHORT).show();
@ -288,20 +285,21 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
} else {
poiEntity.setDescribe(describe);
}
if (photoBean.size() < 0) {
Toast.makeText(getActivity(), "请拍照", Toast.LENGTH_SHORT).show();
String tagPicture = (String) ivPicture.getTag();
if (tagPicture == null || tagPicture.equals("")) {
Toast.makeText(getActivity(), "请 拍照", Toast.LENGTH_SHORT).show();
return;
} else {
poiEntity.setPhotoInfo(photoBean);
infoList.add(new Info(tagPicture));
}
if (!aBoolean) {
Toast.makeText(getActivity(), "请拍照 全景图", Toast.LENGTH_SHORT).show();
return;
}
if (!bBoolean) {
Toast.makeText(getActivity(), "请拍照 名称", Toast.LENGTH_SHORT).show();
String tagPictures = (String) ivPictures.getTag();
if (tagPictures == null || tagPictures.equals("")) {
Toast.makeText(getActivity(), "请 拍照", Toast.LENGTH_SHORT).show();
return;
} else {
infoList.add(new Info(tagPictures));
}
poiEntity.setPhotoInfo(infoList);
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
@ -337,10 +335,11 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
break;
}
}
/**
* 防止当页面崩溃后出现数据丢失
*/
public void initOtherSharePre(){
public void initOtherSharePre() {
//获取SharedPreferences对象方法中两个参数的意思为第一个name
//表示文件名系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件第二个mode表示创建的模式通过查看
@ -350,6 +349,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型调用对应的put方法,
PoiEntity poiEntity = new PoiEntity();
ArrayList<Info> arrayList = new ArrayList<>();
String name = editTaskName.getText().toString().trim();//名称
if (name != null || !name.equals("")) {
poiEntity.setName(name);
@ -364,9 +364,15 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
if (describe != null || !describe.equals("")) {
poiEntity.setDescribe(describe);
}
if (photoBean.size() >0) {
poiEntity.setPhotoInfo(photoBean);
String tagPicture = (String) ivPicture.getTag();
if (tagPicture != null) {
arrayList.add(new Info(tagPicture));
}
String tagPictures = (String) ivPictures.getTag();
if (tagPictures!= null) {
arrayList.add(new Info(tagPictures));
}
poiEntity.setPhotoInfo(arrayList);
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
@ -379,7 +385,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
edit.putString("poiEntity", newPoiEntity);
//提交新值必须执行否则前面的操作都无效
edit.commit();
Log.d("TAG", "initPoiSharePre: "+newPoiEntity);
Log.d("TAG", "initPoiSharePre: " + newPoiEntity);
}
@Override
@ -401,12 +407,10 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"a");//照片路径
photoBean.add(new Info(takePhotoPath));
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "a");//照片路径
ivPicture.setTag(takePhotoPath);
ivPicture.setImageBitmap(bitmap);//显示图像
String[] split = takePhotoPath.split("/");
Log.d("TAG", "onActivityResult: "+takePhotoPath+" "+split[0]+" "+split[1]+" "+split[2]+" "+split[3]+" "+split[4]+" "+split[6]);
aBoolean=true;
}
} else if (requestCode == 102 && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();//从Intent中获取附加值
@ -424,10 +428,9 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
}
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"b");//照片路径
photoBean.add(new Info(takePhotoPath));
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "b");//照片路径
ivPictures.setTag(takePhotoPath);
ivPictures.setImageBitmap(bitmap);//显示图像
bBoolean=true;
}
}
}

View File

@ -79,9 +79,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
private PoiDatabase poiDatabase;
private PoiDao poiDao;
private String inode;
private List<Info> photoBean;
private boolean aBoolean = false;
private boolean bBoolean = false;
private CheckBox checkBoxLife;
private CheckBox checkBoxRight;
private PoiEntity showPoiEntity;
@ -248,27 +245,24 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
poiBeans.add(new PoiBean("电话*", telPhone, R.drawable.icon_add_bg));
}
if (showPoiEntity.getPhotoInfo() != null) {
photoBean.clear();
for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) {
String photo =showPoiEntity.getPhotoInfo().get(i).getPhoto();
String[] split = photo.split("/");
char charAt = split[6].charAt(0);
if (charAt=='a'){
if (split[split.length - 1].startsWith("a")){
Glide.with(getActivity()).load(photo).into(ivPanorama);
photoBean.add(new Info(photo));
}else if (charAt=='b'){
ivPanorama.setTag(photo);
}else if (split[split.length - 1].startsWith("b")){
Glide.with(getActivity()).load(photo).into(ivName);
photoBean.add(new Info(photo));
}else if (charAt=='c'){
ivName.setTag(photo);
}else if (split[split.length - 1].startsWith("c")){
Glide.with(getActivity()).load(photo).into(ivInternal);
photoBean.add(new Info(photo));
}else if (charAt=='d'){
ivInternal.setTag(photo);
}else if (split[split.length - 1].startsWith("d")){
Glide.with(getActivity()).load(photo).into(ivCard);
photoBean.add(new Info(photo));
}else if (charAt=='e'){
ivCard.setTag(photo);
}else if (split[split.length - 1].startsWith("e")){
Glide.with(getActivity()).load(photo).into(ivElse);
photoBean.add(new Info(photo));
ivElse.setTag(photo);
}
}
}
@ -299,8 +293,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
poiBeans = new ArrayList<>();
//存储手机号
phoneData = new ArrayList<>();
//存储图片地址
photoBean = new ArrayList<>();
}
@ -325,6 +317,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
if (all) {
//保存数据库
PoiEntity poiEntity = new PoiEntity();
ArrayList<Info> infoPhoto = new ArrayList<>();
String name = editNameContent.getText().toString().trim();//名称
if (name == null || name.equals("")) {
Toast.makeText(getActivity(), "请输入poi 名称", Toast.LENGTH_SHORT).show();
@ -360,20 +353,33 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
} else {
poiEntity.setTelPhone(phoneData.get(0));
}
if (photoBean.size() < 0) {
Toast.makeText(getActivity(), "请拍照", Toast.LENGTH_SHORT).show();
return;
} else {
poiEntity.setPhotoInfo(photoBean);
}
if (!aBoolean) {
String tagPanorama = (String) ivPanorama.getTag();
if (tagPanorama == null || tagPanorama.equals("")) {
Toast.makeText(getActivity(), "请拍照 全景图", Toast.LENGTH_SHORT).show();
return;
} else {
infoPhoto.add(new Info(tagPanorama));
}
if (!bBoolean) {
Toast.makeText(getActivity(), "请拍照 名称", Toast.LENGTH_SHORT).show();
String tagName = (String) ivName.getTag();
if (tagName == null || tagName.equals("")) {
Toast.makeText(getActivity(), "请拍照 充电桩编码", Toast.LENGTH_SHORT).show();
return;
} else {
infoPhoto.add(new Info(tagName));
}
String tagInternal = (String) ivInternal.getTag();
if (tagInternal != null || !tagInternal.equals("")) {
infoPhoto.add(new Info(tagInternal));
}
String tagElse = (String) ivElse.getTag();
if (tagElse != null ||! tagElse.equals("")) {
infoPhoto.add(new Info(tagElse));
}
String tagCard = (String) ivCard.getTag();
if (tagCard != null || !tagCard.equals("")) {
infoPhoto.add(new Info(tagCard));
}
poiEntity.setPhotoInfo(infoPhoto);
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
@ -457,6 +463,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
//根据要保存的数据的类型调用对应的put方法,
PoiEntity poiEntity = new PoiEntity();
ArrayList<Info> infoPhoto = new ArrayList<>();
String name = editNameContent.getText().toString().trim();//名称
if (name != null || !name.equals("")) {
poiEntity.setName(name);
@ -477,9 +484,27 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
if (phoneData.size() > 0) {
poiEntity.setTelPhone(phoneData.get(0));
}
if (photoBean.size() > 0) {
poiEntity.setPhotoInfo(photoBean);
String tagPanorama = (String) ivPanorama.getTag();
if (tagPanorama!=null) {
infoPhoto.add(new Info(tagPanorama));
}
String tagName = (String) ivName.getTag();
if (tagName!= null) {
infoPhoto.add(new Info(tagName));
}
String tagInternal = (String) ivInternal.getTag();
if (tagInternal!= null) {
infoPhoto.add(new Info(tagInternal));
}
String tagElse = (String) ivElse.getTag();
if (tagElse!=null) {
infoPhoto.add(new Info(tagElse));
}
String tagCard = (String) ivCard.getTag();
if (tagCard != null) {
infoPhoto.add(new Info(tagCard));
}
poiEntity.setPhotoInfo(infoPhoto);
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
@ -517,9 +542,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"a");
photoBean.add(new Info(takePhotoPath));
ivPanorama.setTag(takePhotoPath);
ivPanorama.setImageBitmap(bitmap);//显示图像
aBoolean = true;
}
} else if (requestCode == 102 && resultCode == RESULT_OK) {
@ -539,9 +563,9 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"b");
photoBean.add(new Info(takePhotoPath));
ivName.setTag(takePhotoPath);
ivName.setImageBitmap(bitmap);//显示图像
bBoolean = true;
}
} else if (requestCode == 103 && resultCode == RESULT_OK) {
@ -561,7 +585,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"c");
photoBean.add(new Info(takePhotoPath));
ivInternal.setTag(takePhotoPath);
ivInternal.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 104 && resultCode == RESULT_OK) {
@ -581,7 +605,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"d");
photoBean.add(new Info(takePhotoPath));
ivCard.setTag(takePhotoPath);
ivCard.setImageBitmap(bitmap);//显示图像
}
} else if (requestCode == 105 && resultCode == RESULT_OK) {
@ -601,7 +625,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
});
} else {
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data,"e");
photoBean.add(new Info(takePhotoPath));
ivElse.setTag(takePhotoPath);
ivElse.setImageBitmap(bitmap);//显示图像
}

View File

@ -45,9 +45,7 @@ public class SetFragment extends BaseFragment implements View.OnClickListener {
@Override
protected void initData() {
super.initData();
}
super.initData(); }
@Override
protected void initView() {

View File

@ -40,6 +40,8 @@ import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.base.BaseFragment;
import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.PoiDao;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.NetWorkUtils;
import com.navinfo.outdoor.util.ToastUtil;
@ -96,6 +98,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
private GatherGetFragment gatherGetFragment;
private LinearLayout dragView;
private ImageView ivMessage;
private PoiDao poiDao;
public static TreasureFragment newInstance(Bundle bundle) {
TreasureFragment fragment = new TreasureFragment();
@ -115,6 +118,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
EventBus.getDefault().register(this);
//fragment 管理器
supportFragmentManager = getActivity().getSupportFragmentManager();
PoiDatabase poiDatabase = PoiDatabase.getInstance(getContext());
poiDao = poiDatabase.getPoiDao();
sliding_layout = findViewById(R.id.sliding_layout);
dragView = findViewById(R.id.dragView);
frameLayout = findViewById(R.id.frame_layout);
@ -163,16 +168,35 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
checkNetWork();
//检查是否有没有填完的页面
initSharePre();
//数据库
initThread();
}
private void initThread() {
new Thread(new Runnable() {
@Override
public void run() {
List<PoiEntity> allPoi = poiDao.getAllPoi();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < allPoi.size(); i++) {
LatLng position = new LatLng(Double.valueOf(allPoi.get(i).getX()), Double.valueOf(allPoi.get(i).getY()));
tencentMap.addMarker(new MarkerOptions(position));
}
}
});
}
}).start();
}
private void initSharePre() {
//根据保存时所用的name属性获取SharedPreferences对象
SharedPreferences dataFile = getActivity().getSharedPreferences("dataFile", 0);
//根据数据类型调用对应的get方法通过键取得对应的值
String dataFileString = dataFile.getString("poiEntity", null);
String pileFileString = dataFile.getString("chargingPileEntity", null);
if (dataFileString!=null){
PoiEntity poiEntity = new Gson().fromJson(dataFileString, PoiEntity.class);
switch (poiEntity.getType()){
@ -248,6 +272,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
break;
}
}
String pileFileString = dataFile.getString("chargingPileEntity", null);
if (pileFileString!=null){
ChargingPileEntity chargingPileEntity = new Gson().fromJson(pileFileString, ChargingPileEntity.class);
DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
@ -349,7 +374,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
if ((boolean) data.obj) {
dragView.removeAllViews();
}
} else if (data.what == Constant.GATHER_GET_RETURN) {//item 点击页面的返回事件的处理
if ((boolean) data.obj) {
frameLayout.setVisibility(View.GONE);
@ -369,8 +393,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
ChargingPileFragment chargingPileFragment = ChargingPileFragment.newInstance(bundle);
showSlidingFragment(chargingPileFragment);
}
}
/**