充电站和充电桩 的存储逻辑
This commit is contained in:
parent
d3c725ac57
commit
286b9dfc89
@ -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"
|
||||
|
@ -18,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.bean.PoiBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -25,11 +26,15 @@ import java.util.List;
|
||||
*/
|
||||
public class PoiRecycleAdapter extends RecyclerView.Adapter<PoiRecycleAdapter.MyViewHolder> {
|
||||
private Context context;
|
||||
private List<PoiBean> list;
|
||||
private List<PoiBean> list=new ArrayList<>();
|
||||
|
||||
public PoiRecycleAdapter(Context context, List<PoiBean> list) {
|
||||
public PoiRecycleAdapter(Context context) {
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public void setList(List<PoiBean> list) {
|
||||
this.list.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +33,8 @@ public class Constant {
|
||||
//筛选
|
||||
public static final int FILTER_CODE = 0x200;
|
||||
|
||||
public static final String DATA_FILE = "dataFile";
|
||||
|
||||
|
||||
|
||||
//message word 值
|
||||
@ -42,6 +44,7 @@ public class Constant {
|
||||
public static final int FILTER_LIST = 4;//筛选列表所有数据地图显示
|
||||
public static final int FILTER_LIST_ITEM = 5;//点击筛选的item
|
||||
public static final int GATHER_GET = 6;//点击开始采集
|
||||
public static final int GATHER_IS_SLIDING_GET =2;//通知抽屉不收回
|
||||
public static final int TREASURE_GATHER_GET_WORD = 7;//领取采集页面其他marker 的回传
|
||||
public static final int MAIN_BUTTON_VISIABLE = 8; // 控制主界面各个按钮显隐状态的what值
|
||||
public static final int MAIN_HEADER = 9; // 控制主界面各个header
|
||||
|
@ -76,7 +76,7 @@ public abstract class BaseDrawerFragment extends BaseFragment {
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = getActivity().getSharedPreferences("dataFile", 0);
|
||||
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
|
@ -87,6 +87,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
private int cp_availableState = 0;
|
||||
private CheckBox checkButton1, checkButton2, checkButton3, checkButton4, checkButton5, checkButton6;
|
||||
private int pid;
|
||||
private String station;
|
||||
|
||||
public static ChargingPileFragment newInstance(Bundle bundle) {
|
||||
ChargingPileFragment fragment = new ChargingPileFragment();
|
||||
@ -356,31 +357,34 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
rlDevice = findViewById(R.id.rl_device);
|
||||
rlDevice.setOnClickListener(this::onClick);
|
||||
ivDevice = findViewById(R.id.iv_device);
|
||||
|
||||
editDescribe = findViewById(R.id.edit_describe);
|
||||
btnSaveLocal = findViewById(R.id.btn_save_local);
|
||||
btnSaveLocal.setOnClickListener(this::onClick);
|
||||
|
||||
//展示数据
|
||||
initShowPileSharePre();
|
||||
initShowPileSharePre();
|
||||
|
||||
}
|
||||
|
||||
private void initShowPileSharePre() {
|
||||
station = getArguments().getString("station");
|
||||
if (station!=null){
|
||||
PoiEntity poiEntity = new Gson().fromJson(station, PoiEntity.class);
|
||||
pid = poiEntity.getId();
|
||||
}
|
||||
// 添加信息:
|
||||
pid = getArguments().getInt("pid", 0);
|
||||
ChargingPileEntity chargingPileEntity = (ChargingPileEntity) getArguments().getSerializable("chargingPileEntity");
|
||||
if (chargingPileEntity != null) {
|
||||
String name = chargingPileEntity.getName();//名称
|
||||
if (name != null || !name.equals("")) {
|
||||
if (name != null) {
|
||||
editNameContent.setText(name + "");
|
||||
}
|
||||
String p = chargingPileEntity.getP();
|
||||
if (p != null || !p.equals("")) {
|
||||
if (p != null) {
|
||||
inode = p;
|
||||
}
|
||||
String memo = chargingPileEntity.getMemo();
|
||||
if (memo != null || !memo.equals("")) {
|
||||
if (memo != null) {
|
||||
editDescribe.setText(memo);
|
||||
}
|
||||
int fid = chargingPileEntity.getFid();
|
||||
@ -548,21 +552,21 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
chargingPileEntity.setCp_floor(cp_floor);
|
||||
}
|
||||
String tagPanorama = (String) ivPanorama.getTag();
|
||||
if (tagPanorama == null || tagPanorama.equals("")) {
|
||||
if (tagPanorama == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 全景图", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
photoBean.add(tagPanorama);
|
||||
}
|
||||
String tagCoding = (String) ivCoding.getTag();
|
||||
if (tagCoding == null || tagCoding.equals("")) {
|
||||
if (tagCoding == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 充电桩编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
photoBean.add(tagCoding);
|
||||
}
|
||||
String tagEquipment = (String) ivEquipment.getTag();
|
||||
if (tagEquipment == null || tagEquipment.equals("")) {
|
||||
if (tagEquipment == null ) {
|
||||
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
@ -570,21 +574,21 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
}
|
||||
String tagFacility = (String) ivFacility.getTag();
|
||||
if (sign_exist != 0) {
|
||||
if (tagFacility == null || tagFacility.equals("")) {
|
||||
if (tagFacility == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
photoBean.add(tagFacility);
|
||||
}
|
||||
} else {
|
||||
if (tagFacility != null || !tagFacility.equals("")) {
|
||||
if (tagFacility != null ) {
|
||||
photoBean.add(tagFacility);
|
||||
}
|
||||
}
|
||||
|
||||
String tagScutcheon = (String) ivScutcheon.getTag();
|
||||
if (sign_exist == 1) {
|
||||
if (tagScutcheon == null || tagScutcheon.equals("")) {
|
||||
if (tagScutcheon == null ) {
|
||||
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
@ -594,7 +598,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
|
||||
String tagDevice = (String) ivDevice.getTag();
|
||||
if (sign_exist == 1) {
|
||||
if (tagDevice == null || tagDevice.equals("")) {
|
||||
if (tagDevice == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
@ -603,25 +607,25 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
}
|
||||
|
||||
String tagUsable = (String) ivUsable.getTag();
|
||||
if (tagUsable == null || tagUsable.equals("")) {
|
||||
if (tagUsable == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 可用状态", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
photoBean.add(tagUsable);
|
||||
}
|
||||
String tagAvailable = (String) ivAvailable.getTag();
|
||||
if (tagAvailable != null || !tagAvailable.equals("")) {
|
||||
if (tagAvailable != null) {
|
||||
photoBean.add(tagAvailable);
|
||||
}
|
||||
String tagParking = (String) ivParking.getTag();
|
||||
if (tagParking == null || tagParking.equals("")) {
|
||||
if (tagParking == null ) {
|
||||
Toast.makeText(getActivity(), "请拍照 停车位编号", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
photoBean.add(tagPanorama);
|
||||
}
|
||||
String tagNumber = (String) ivNumber.getTag();
|
||||
if (tagNumber != null || !tagNumber.equals("")) {
|
||||
if (tagNumber != null ) {
|
||||
photoBean.add(tagNumber);
|
||||
}
|
||||
chargingPileEntity.setPhotos(photoBean);
|
||||
@ -726,7 +730,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = getActivity().getSharedPreferences("dataFile", 0);
|
||||
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
@ -736,7 +740,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
chargingPileEntity.setP(inode);
|
||||
}
|
||||
String name = editNameContent.getText().toString().trim();//名称
|
||||
if (name != null || !name.equals("")) {
|
||||
if (name != null ||!name.equals("")) {
|
||||
chargingPileEntity.setName(name);
|
||||
}
|
||||
if (cp_floor != 0) {
|
||||
@ -795,6 +799,9 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
String newChargingPileEntity = new Gson().toJson(chargingPileEntity);
|
||||
//以键值对的形式添加新值。
|
||||
edit.putString("chargingPileEntity", newChargingPileEntity);
|
||||
if (station!=null){
|
||||
edit.putString("poiEntity", station);
|
||||
}
|
||||
//提交新值。必须执行,否则前面的操作都无效。
|
||||
edit.commit();
|
||||
Log.d("TAG", "initPileSharePre: " + newChargingPileEntity);
|
||||
|
@ -87,7 +87,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
private String inode;
|
||||
private CheckBox checkBoxLife;
|
||||
private CheckBox checkBoxRight;
|
||||
private String phone;
|
||||
private String phone=null;
|
||||
private Spinner spinnerType;
|
||||
String[] ctype = new String[]{"全部", "poi", "道路", "充电站", "其他"};
|
||||
private ArrayAdapter<String> adapter;
|
||||
@ -228,10 +228,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
}
|
||||
public void onNothingSelected(AdapterView<?> parent) {}
|
||||
});
|
||||
//添加桩
|
||||
linearChargingPile = findViewById(R.id.linear_charging_pile);
|
||||
@ -263,8 +261,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
recyclerPhone = findViewById(R.id.recycler_phone);
|
||||
recyclerPhone.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerPhone.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
|
||||
poiBeans.add(new PoiBean("电话*", phone, R.drawable.icon_add_bg));
|
||||
poiRecycleAdapter = new PoiRecycleAdapter(getContext(), poiBeans);
|
||||
poiRecycleAdapter = new PoiRecycleAdapter(getContext());
|
||||
recyclerPhone.setAdapter(poiRecycleAdapter);
|
||||
poiRecycleAdapter.setInitPoiClick(new PoiRecycleAdapter.initPoiClick() {
|
||||
@Override
|
||||
@ -309,11 +306,11 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
|
||||
if (showPoiEntity != null) {
|
||||
String name = showPoiEntity.getName();//名称
|
||||
if (name != null || !name.equals("")) {
|
||||
if (name != null) {
|
||||
editNameContent.setText(name + "");
|
||||
}
|
||||
String address = showPoiEntity.getAddress();//地址
|
||||
if (address != null || !address.equals("")) {
|
||||
if (address != null) {
|
||||
editSiteContent.setText(address);
|
||||
}
|
||||
String x = showPoiEntity.getX();
|
||||
@ -322,15 +319,15 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
inode = x + "," + y;
|
||||
}
|
||||
String describe = showPoiEntity.getDescribe();//任务描述
|
||||
if (describe != null || !describe.equals("")) {
|
||||
if (describe != null) {
|
||||
editDescribe.setText(describe);
|
||||
}
|
||||
String telPhone = showPoiEntity.getTelPhone();
|
||||
if (telPhone != null) {
|
||||
phoneData.add(showPoiEntity.getTelPhone());
|
||||
poiBeans.add(new PoiBean("电话*", telPhone, R.drawable.icon_add_bg));
|
||||
poiRecycleAdapter.setList(poiBeans);
|
||||
}
|
||||
|
||||
if (showPoiEntity.getPhotoInfo() != null) {
|
||||
for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) {
|
||||
String photo = showPoiEntity.getPhotoInfo().get(i).getPhoto();
|
||||
@ -373,17 +370,46 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
poiBeans.add(new PoiBean("电话*", phone, R.drawable.icon_add_bg));
|
||||
poiRecycleAdapter.setList(poiBeans);
|
||||
}
|
||||
ChargingPileEntity chargingPileEntity = (ChargingPileEntity) getArguments().getSerializable("chargingPileEntity");
|
||||
if (chargingPileEntity != null) {
|
||||
initPile();
|
||||
}
|
||||
|
||||
private void initPile() {
|
||||
//根据保存时所用的name属性,获取SharedPreferences对象
|
||||
SharedPreferences dataFile = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
String pileFileString = dataFile.getString("chargingPileEntity", null);
|
||||
if (pileFileString!=null){
|
||||
ChargingPileEntity chargingPileEntity = new Gson().fromJson(pileFileString, ChargingPileEntity.class);
|
||||
Message obtains = Message.obtain();
|
||||
obtains.what = Constant.CHARGING_STATION_PILE;
|
||||
obtains.obj = chargingPileEntity;
|
||||
EventBus.getDefault().post(obtains);
|
||||
initRemovePileSharePre();
|
||||
|
||||
String showStation = initShowStation();
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.CHARGING_STATION;
|
||||
obtain.obj = showStation;
|
||||
EventBus.getDefault().post(obtain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void initRemovePileSharePre() {
|
||||
//获取SharedPreferences对象,方法中两个参数的意思为:第一个name
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,以键值对的形式添加新值。
|
||||
edit.putString("chargingPileEntity", null);
|
||||
//提交新值。必须执行,否则前面的操作都无效。
|
||||
edit.commit();
|
||||
}
|
||||
//禁用所有可操作性控件
|
||||
private void disables() {
|
||||
checkBoxLife.setEnabled(false);
|
||||
@ -474,35 +500,35 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
}
|
||||
|
||||
String tagPanorama = (String) ivPanorama.getTag();
|
||||
if (tagPanorama == null || tagPanorama.equals("")) {
|
||||
if (tagPanorama == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 全景图", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
infoPhoto.add(new Info(tagPanorama));
|
||||
}
|
||||
String tagName = (String) ivName.getTag();
|
||||
if (tagName == null || tagName.equals("")) {
|
||||
if (tagName == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 充电桩编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
infoPhoto.add(new Info(tagName));
|
||||
}
|
||||
String tagInternal = (String) ivInternal.getTag();
|
||||
if (tagInternal == null || tagInternal.equals("")) {
|
||||
if (tagInternal == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
infoPhoto.add(new Info(tagInternal));
|
||||
}
|
||||
String tagElse = (String) ivElse.getTag();
|
||||
if (tagElse == null || tagElse.equals("")) {
|
||||
if (tagElse == null ) {
|
||||
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
infoPhoto.add(new Info(tagElse));
|
||||
}
|
||||
String tagScutcheon = (String) ivScutcheon.getTag();
|
||||
if (tagScutcheon == null || tagScutcheon.equals("")) {
|
||||
if (tagScutcheon == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
@ -524,10 +550,16 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
poiEntity.setCreateTime(format);
|
||||
poiEntity.setType(2);
|
||||
poiEntity.setTaskStatus(0);
|
||||
poiEntity.setTaskId(101);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<PoiEntity> allPoi = poiDao.getAllPoi();
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
poiEntity.setTaskId(allPoi.size()+1);
|
||||
}
|
||||
});
|
||||
poiDao.insertPoiEntity(poiEntity);
|
||||
}
|
||||
}).start();
|
||||
@ -578,14 +610,83 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
startActivityForResult(intentScutcheon, 105);
|
||||
break;
|
||||
case R.id.linear_charging_pile:
|
||||
String showStation = initShowStation();
|
||||
Message obtains = Message.obtain();
|
||||
obtains.what = Constant.CHARGING_STATION;
|
||||
obtains.obj = 101;
|
||||
obtains.obj = showStation;
|
||||
EventBus.getDefault().post(obtains);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private String initShowStation() {
|
||||
PoiEntity poiEntity = new PoiEntity();
|
||||
List<Info> infoPhoto = new ArrayList<>();
|
||||
String name = editNameContent.getText().toString().trim();//名称
|
||||
if (name != null || !name.equals("")) {
|
||||
poiEntity.setName(name);
|
||||
}
|
||||
String site = editSiteContent.getText().toString().trim();
|
||||
if (site != null || !site.equals("")) {
|
||||
poiEntity.setAddress(site);
|
||||
}
|
||||
if (inode != null) {
|
||||
String[] split = inode.split(",");
|
||||
poiEntity.setX(split[0]);
|
||||
poiEntity.setY(split[1]);
|
||||
}
|
||||
String describe = editDescribe.getText().toString().trim();
|
||||
if (describe != null || !describe.equals("")) {
|
||||
poiEntity.setDescribe(describe);
|
||||
}
|
||||
if (phoneData.size() > 0) {
|
||||
poiEntity.setTelPhone(phoneData.get(0));
|
||||
}
|
||||
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();
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
String format = formatter.format(calendar.getTime());
|
||||
poiEntity.setCreateTime(format);
|
||||
poiEntity.setType(2);
|
||||
poiEntity.setTaskStatus(0);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<PoiEntity> allPoi = poiDao.getAllPoi();
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
poiEntity.setTaskId(allPoi.size()+1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
String newPoiEntity = new Gson().toJson(poiEntity);
|
||||
return newPoiEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
@ -600,7 +701,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = getActivity().getSharedPreferences("dataFile", 0);
|
||||
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
@ -656,7 +757,18 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
poiEntity.setCreateTime(format);
|
||||
poiEntity.setType(2);
|
||||
poiEntity.setTaskStatus(0);
|
||||
poiEntity.setTaskId(101);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<PoiEntity> allPoi = poiDao.getAllPoi();
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
poiEntity.setTaskId(allPoi.size()+1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
String newPoiEntity = new Gson().toJson(poiEntity);
|
||||
//以键值对的形式添加新值。
|
||||
edit.putString("poiEntity", newPoiEntity);
|
||||
|
@ -10,6 +10,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.base.BaseFragment;
|
||||
import com.navinfo.outdoor.room.PoiEntity;
|
||||
|
||||
@ -46,6 +47,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
}
|
||||
//主界面获取焦点
|
||||
private void getFocus() {
|
||||
boolean aBoolean = getArguments().getBoolean("boolean", true);
|
||||
getView().setFocusableInTouchMode(true);
|
||||
getView().requestFocus();
|
||||
getView().setOnKeyListener(new View.OnKeyListener() {
|
||||
@ -54,7 +56,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.GATHER_GET_RETURN;
|
||||
obtain.obj = true;
|
||||
obtain.obj = aBoolean;
|
||||
EventBus.getDefault().post(obtain);
|
||||
return true;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ 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 RelativeLayout rlPicture;
|
||||
@ -156,9 +156,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
case 4:
|
||||
Toast.makeText(getActivity(), others[4], Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case 5:
|
||||
Toast.makeText(getActivity(), others[5], Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,14 +210,14 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
|
||||
if (showPoiEntity != null) {
|
||||
String name = showPoiEntity.getName();//名称
|
||||
if (name != null || !name.equals("")) {
|
||||
if (name != null ) {
|
||||
editTaskName.setText(name + ""); }
|
||||
String x = showPoiEntity.getX();
|
||||
String y = showPoiEntity.getY();
|
||||
if (x != null && y != null) {
|
||||
inode = x + "," + y; }
|
||||
String describe = showPoiEntity.getDescribe();//任务描述
|
||||
if (describe != null || !describe.equals("")) {
|
||||
if (describe != null) {
|
||||
editOtherDescribe.setText(describe); }
|
||||
if (showPoiEntity.getPhotoInfo() != null) {
|
||||
for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) {
|
||||
@ -286,14 +284,14 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
poiEntity.setDescribe(describe);
|
||||
}
|
||||
String tagPicture = (String) ivPicture.getTag();
|
||||
if (tagPicture == null || tagPicture.equals("")) {
|
||||
if (tagPicture == null) {
|
||||
Toast.makeText(getActivity(), "请 拍照", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
infoList.add(new Info(tagPicture));
|
||||
}
|
||||
String tagPictures = (String) ivPictures.getTag();
|
||||
if (tagPictures == null || tagPictures.equals("")) {
|
||||
if (tagPictures == null ) {
|
||||
Toast.makeText(getActivity(), "请 拍照", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
@ -344,7 +342,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = getActivity().getSharedPreferences("dataFile", 0);
|
||||
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
|
@ -180,8 +180,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
recyclerPhone = findViewById(R.id.recycler_phone);
|
||||
recyclerPhone.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerPhone.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
|
||||
|
||||
poiRecycleAdapter = new PoiRecycleAdapter(getContext(), poiBeans);
|
||||
poiRecycleAdapter = new PoiRecycleAdapter(getContext());
|
||||
recyclerPhone.setAdapter(poiRecycleAdapter);
|
||||
poiRecycleAdapter.setInitPoiClick(new PoiRecycleAdapter.initPoiClick() {
|
||||
@Override
|
||||
@ -223,11 +222,11 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
|
||||
if (showPoiEntity != null) {
|
||||
String name = showPoiEntity.getName();//名称
|
||||
if (name != null || !name.equals("")) {
|
||||
if (name != null) {
|
||||
editNameContent.setText(name + "");
|
||||
}
|
||||
String address = showPoiEntity.getAddress();//地址
|
||||
if (address != null || !address.equals("")) {
|
||||
if (address != null) {
|
||||
editSiteContent.setText(address);
|
||||
}
|
||||
String x = showPoiEntity.getX();
|
||||
@ -236,13 +235,15 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
inode = x + "," + y;
|
||||
}
|
||||
String describe = showPoiEntity.getDescribe();//任务描述
|
||||
if (describe != null || !describe.equals("")) {
|
||||
if (describe != null) {
|
||||
editDescribe.setText(describe);
|
||||
}
|
||||
String telPhone = showPoiEntity.getTelPhone();
|
||||
if (telPhone != null) {
|
||||
phoneData.add(showPoiEntity.getTelPhone());
|
||||
poiBeans.add(new PoiBean("电话*", telPhone, R.drawable.icon_add_bg));
|
||||
poiRecycleAdapter.setList(poiBeans);
|
||||
|
||||
}
|
||||
if (showPoiEntity.getPhotoInfo() != null) {
|
||||
for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) {
|
||||
@ -266,6 +267,9 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
poiBeans.add(new PoiBean("电话*", "", R.drawable.icon_add_bg));
|
||||
poiRecycleAdapter.setList(poiBeans);
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,29 +358,29 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
poiEntity.setTelPhone(phoneData.get(0));
|
||||
}
|
||||
String tagPanorama = (String) ivPanorama.getTag();
|
||||
if (tagPanorama == null || tagPanorama.equals("")) {
|
||||
if (tagPanorama == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 全景图", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
infoPhoto.add(new Info(tagPanorama));
|
||||
}
|
||||
String tagName = (String) ivName.getTag();
|
||||
if (tagName == null || tagName.equals("")) {
|
||||
if (tagName == null) {
|
||||
Toast.makeText(getActivity(), "请拍照 充电桩编码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
infoPhoto.add(new Info(tagName));
|
||||
}
|
||||
String tagInternal = (String) ivInternal.getTag();
|
||||
if (tagInternal != null || !tagInternal.equals("")) {
|
||||
if (tagInternal != null) {
|
||||
infoPhoto.add(new Info(tagInternal));
|
||||
}
|
||||
String tagElse = (String) ivElse.getTag();
|
||||
if (tagElse != null ||! tagElse.equals("")) {
|
||||
if (tagElse != null) {
|
||||
infoPhoto.add(new Info(tagElse));
|
||||
}
|
||||
String tagCard = (String) ivCard.getTag();
|
||||
if (tagCard != null || !tagCard.equals("")) {
|
||||
if (tagCard != null) {
|
||||
infoPhoto.add(new Info(tagCard));
|
||||
}
|
||||
poiEntity.setPhotoInfo(infoPhoto);
|
||||
@ -457,7 +461,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = getActivity().getSharedPreferences("dataFile", 0);
|
||||
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
|
@ -271,7 +271,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = getActivity().getSharedPreferences("dataFile", 0);
|
||||
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
|
@ -35,6 +35,9 @@ import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.room.PoiEntity;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -152,7 +155,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
}
|
||||
}
|
||||
|
||||
private void disables() {
|
||||
private void disables() throws JSONException {
|
||||
etRoadName.setEnabled(false);
|
||||
rgType.setEnabled(false);
|
||||
ivRoadPicture.setEnabled(false);
|
||||
@ -276,7 +279,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = getActivity().getSharedPreferences("dataFile", 0);
|
||||
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
|
@ -99,6 +99,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
private LinearLayout dragView;
|
||||
private ImageView ivMessage;
|
||||
private PoiDao poiDao;
|
||||
private ChargingPileEntity chargingPileEntity;
|
||||
|
||||
public static TreasureFragment newInstance(Bundle bundle) {
|
||||
TreasureFragment fragment = new TreasureFragment();
|
||||
@ -183,7 +184,28 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
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));
|
||||
Marker marker = tencentMap.addMarker(new MarkerOptions(position));
|
||||
marker.setClickable(true);
|
||||
PoiEntity poiEntity = allPoi.get(i);
|
||||
tencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() {
|
||||
@Override
|
||||
public boolean onMarkerClick(Marker marker) {
|
||||
sliding_layout.setPanelHeight(0);
|
||||
sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
|
||||
frameLayout.setVisibility(View.VISIBLE);
|
||||
setMainButtonVisiable(View.GONE);
|
||||
fragmentTransaction = supportFragmentManager.beginTransaction();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("poiEntity",poiEntity);
|
||||
bundle.putBoolean("boolean",false);
|
||||
gatherGetFragment = GatherGetFragment.newInstance(bundle);
|
||||
fragmentTransaction.replace(R.id.frame_layout, gatherGetFragment);
|
||||
fragmentTransaction.commit();
|
||||
Toast.makeText(getActivity(), marker.getId()+"", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -193,10 +215,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
|
||||
private void initSharePre() {
|
||||
//根据保存时所用的name属性,获取SharedPreferences对象
|
||||
SharedPreferences dataFile = getActivity().getSharedPreferences("dataFile", 0);
|
||||
SharedPreferences dataFile = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//根据数据类型,调用对应的get方法,通过键取得对应的值。
|
||||
String dataFileString = dataFile.getString("poiEntity", null);
|
||||
|
||||
if (dataFileString!=null){
|
||||
PoiEntity poiEntity = new Gson().fromJson(dataFileString, PoiEntity.class);
|
||||
switch (poiEntity.getType()){
|
||||
@ -272,35 +293,18 @@ 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;
|
||||
MessageDialog.show((AppCompatActivity) getContext(), "提示", "你充电桩页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("chargingPileEntity",chargingPileEntity);
|
||||
ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
|
||||
showSlidingFragment(chargingStationFragment);
|
||||
initRemovePoiSharePre();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
public void initRemovePoiSharePre() {
|
||||
//获取SharedPreferences对象,方法中两个参数的意思为:第一个name
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = getActivity().getSharedPreferences("dataFile", 0);
|
||||
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
//以键值对的形式添加新值。
|
||||
edit.putString("poiEntity", null);
|
||||
edit.putString("chargingPileEntity", null);
|
||||
//提交新值。必须执行,否则前面的操作都无效。
|
||||
edit.commit();
|
||||
}
|
||||
@ -379,19 +383,20 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
frameLayout.setVisibility(View.GONE);
|
||||
sliding_layout.setPanelHeight(1000);
|
||||
sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
|
||||
}else {
|
||||
setMainButtonVisiable(View.VISIBLE);
|
||||
}
|
||||
} else if (data.what == Constant.CHARGING_STATION) {//充电站的充电桩
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("isSliding", false); // 通知抽屉不收回
|
||||
bundle.putInt("pid", (Integer) data.obj);
|
||||
bundle.putString("station", (String) data.obj);
|
||||
if (chargingPileEntity!=null){
|
||||
bundle.putSerializable("chargingPileEntity",chargingPileEntity);
|
||||
}
|
||||
ChargingPileFragment chargingPileFragment = ChargingPileFragment.newInstance(bundle);
|
||||
showSlidingFragment(chargingPileFragment);
|
||||
} else if (data.what == Constant.CHARGING_STATION_PILE) {//充电站的充电桩
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("isSliding", false); // 通知抽屉不收回
|
||||
bundle.putSerializable("chargingPileEntity",(ChargingPileEntity) data.obj);
|
||||
ChargingPileFragment chargingPileFragment = ChargingPileFragment.newInstance(bundle);
|
||||
showSlidingFragment(chargingPileFragment);
|
||||
chargingPileEntity = (ChargingPileEntity) data.obj;
|
||||
}
|
||||
}
|
||||
|
||||
@ -650,6 +655,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
fragmentTransaction.hide(filterFragment);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(fragment instanceof ChargingStationFragment)) {
|
||||
ChargingStationFragment chargingStationFragment = (ChargingStationFragment) supportFragmentManager.findFragmentByTag(ChargingStationFragment.class.getName());
|
||||
if (chargingStationFragment != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user