From 8836e4c30211e199c7369b936491edea29c62984 Mon Sep 17 00:00:00 2001 From: wds Date: Thu, 24 Jun 2021 18:52:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E7=94=B5=E7=AB=99=E5=85=85=E7=94=B5?= =?UTF-8?q?=E6=A1=A9=E4=BF=9D=E5=AD=98=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../outdoor/adapter/ChargingPileAdapter.java | 13 +- .../fragment/ChargingPileFragment.java | 274 ++++++++++++------ .../fragment/ChargingStationFragment.java | 134 +++++++-- .../outdoor/fragment/TreasureFragment.java | 4 +- .../navinfo/outdoor/room/ChargingPileDao.java | 13 - .../outdoor/room/ChargingPileEntity.java | 173 +++-------- .../com/navinfo/outdoor/room/PoiEntity.java | 10 +- .../res/layout/charging_pile_fragment.xml | 74 ++++- .../res/layout/charging_station_fragment.xml | 27 +- .../main/res/layout/item_charging_pile.xml | 35 ++- 11 files changed, 484 insertions(+), 275 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e1e1655..d42c995 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/app/src/main/java/com/navinfo/outdoor/adapter/ChargingPileAdapter.java b/app/src/main/java/com/navinfo/outdoor/adapter/ChargingPileAdapter.java index 5b4d2c6..9926e93 100644 --- a/app/src/main/java/com/navinfo/outdoor/adapter/ChargingPileAdapter.java +++ b/app/src/main/java/com/navinfo/outdoor/adapter/ChargingPileAdapter.java @@ -1,10 +1,12 @@ package com.navinfo.outdoor.adapter; import android.content.Context; +import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.RelativeLayout; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; @@ -38,8 +40,13 @@ public class ChargingPileAdapter extends RecyclerView.Adapter photoBean; + private List photoBean; private CheckBox checkBoxLife, checkBoxRight; private Spinner spinnerType, spinnerScutcheon, spinnerStake; - String[] type = new String[]{"地上五层", "地上四层", "地上三层", "地上二层", "地上一层","地下一层", "地下二层", "地下三层", "地下四层", "地下五层"}; - String[] scutcheon = new String[]{"存在", "不存在"}; - String[] stake = new String[]{"全部", "poi", "道路", "充电站", "其他"}; + String[] type = new String[]{"地上五层", "地上四层", "地上三层", "地上二层", "地上一层", "地下一层", "地下二层", "地下三层", "地下四层", "地下五层"}; + String[] scutcheon = new String[]{"不存在", "存在"}; + String[] stake = new String[]{"可以使用", "不可使用", "维修中", "建设中", "规划中"}; private ArrayAdapter adapterType, adapterScutcheon, adapterStake; private RadioGroup radioGroup; private RadioButton radioButton1, radioButton2, radioButton3, radioButton4, radioButton5, radioButton6; - private RelativeLayout rlPanorama, rlCoding, rlEquipment, rlFacility, rlUsable, rlAvailable, rlParking, rlNumber; - private ImageView ivPanorama, ivCoding, ivEquipment, ivFacility, ivUsable, ivAvailable, ivParking, ivNumber; + private RelativeLayout rlPanorama, rlCoding, rlEquipment, rlFacility, rlUsable, rlAvailable, rlParking, rlNumber, rlScutcheon, rlDevice; + private ImageView ivPanorama, ivCoding, ivEquipment, ivFacility, ivUsable, ivAvailable, ivParking, ivNumber, ivScutcheon, ivDevice; private ChargingPileDao chargingPileDao; + private int cp_floor = 1; + private int sign_exist = 0; + private int cp_availableState = 0; public static ChargingPileFragment newInstance(Bundle bundle) { ChargingPileFragment fragment = new ChargingPileFragment(); @@ -112,20 +116,20 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC @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(); @@ -162,16 +166,48 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC adapterType = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, type); adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式 spinnerType.setAdapter(adapterType); + spinnerType.setSelection(4, true); spinnerType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + case 0: + cp_floor = 5; + break; + case 1: + cp_floor = 4; + break; + case 2: + cp_floor = 3; + break; + case 3: + cp_floor = 2; + break; + case 4: + cp_floor = 1; + break; + case 5: + cp_floor = -1; + break; + case 6: + cp_floor = -2; + break; + case 7: + cp_floor = -3; + break; + case 8: + cp_floor = -4; + break; + case 9: + cp_floor = -5; + break; + + + } } - @Override - public void onNothingSelected(AdapterView parent) { - - } + public void onNothingSelected(AdapterView parent) { } }); spinnerScutcheon = findViewById(R.id.spinner_scutcheon); adapterScutcheon = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, scutcheon); @@ -180,7 +216,20 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC spinnerScutcheon.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - + switch (position) { + case 0: + rlFacility.setBackgroundColor(Color.parseColor("#EFEDED")); + rlScutcheon.setVisibility(View.GONE); + rlDevice.setVisibility(View.GONE); + sign_exist = 0; + break; + case 1: + rlFacility.setBackgroundColor(Color.parseColor("#03A9F4")); + rlScutcheon.setVisibility(View.VISIBLE); + rlDevice.setVisibility(View.VISIBLE); + sign_exist = 1; + break; + } } @Override @@ -195,7 +244,24 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC spinnerStake.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + case 0: + cp_availableState = 0; + break; + case 1: + cp_availableState = 1; + break; + case 2: + cp_availableState = 2; + break; + case 3: + cp_availableState = 3; + break; + case 4: + cp_availableState = 4; + break; + } } @Override @@ -227,6 +293,13 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC rlNumber = findViewById(R.id.rl_number); rlNumber.setOnClickListener(this::onClick); ivNumber = findViewById(R.id.iv_number); + rlScutcheon = findViewById(R.id.rl_scutcheon); + rlScutcheon.setOnClickListener(this::onClick); + ivScutcheon = findViewById(R.id.iv_scutcheon); + 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); @@ -247,6 +320,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC super.initData(); //存储图片地址 photoBean = new ArrayList<>(); + } @@ -271,6 +345,12 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC if (all) { //保存数据库: ChargingPileEntity chargingPileEntity = new ChargingPileEntity(); + if (inode == null || inode.equals("")) { + Toast.makeText(getActivity(), "请确定点位", Toast.LENGTH_SHORT).show(); + return; + } else { + chargingPileEntity.setP(inode); + } String name = editNameContent.getText().toString().trim();//名称 if (name == null || name.equals("")) { Toast.makeText(getActivity(), "请输入 名称", Toast.LENGTH_SHORT).show(); @@ -278,33 +358,24 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else { chargingPileEntity.setName(name); } - if (inode == null || inode.equals("")) { - Toast.makeText(getActivity(), "请确定点位", Toast.LENGTH_SHORT).show(); + if (cp_floor != 0) { + chargingPileEntity.setCp_floor(cp_floor); + } + if (photoBean.size() < 4) { + Toast.makeText(getActivity(), "请拍照", Toast.LENGTH_SHORT).show(); return; } else { - String[] split = inode.split(","); - chargingPileEntity.setX(split[0]); - chargingPileEntity.setY(split[1]); + chargingPileEntity.setPhotos(photoBean); } + chargingPileEntity.setSign_exist(sign_exist); + chargingPileEntity.setCp_availableState(cp_availableState); String describe = editDescribe.getText().toString().trim(); if (describe == null || describe.equals("")) { Toast.makeText(getActivity(), "请输入任务描述", Toast.LENGTH_SHORT).show(); return; } else { - chargingPileEntity.setDescribe(describe); + chargingPileEntity.setMemo(describe); } - if (photoBean.size() < 0) { - Toast.makeText(getActivity(), "请拍照", Toast.LENGTH_SHORT).show(); - return; - } else { - chargingPileEntity.setPhotoInfo(photoBean); - } - DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(System.currentTimeMillis()); - String format = formatter.format(calendar.getTime()); - chargingPileEntity.setCreateTime(format); - Message obtain = Message.obtain(); obtain.what = Constant.CHARGING_PILE_STATION; obtain.obj = chargingPileEntity; @@ -346,22 +417,31 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC Intent intentFacility = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intentFacility, 104); break; + case R.id.rl_scutcheon: + Intent intentScutcheon = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intentScutcheon, 105); + break; + case R.id.rl_device: + Intent intentDevice = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intentDevice, 106); + break; case R.id.rl_usable: Intent intentUsable = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentUsable, 105); + startActivityForResult(intentUsable, 107); break; case R.id.rl_available: Intent intentAvailable = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentAvailable, 106); + startActivityForResult(intentAvailable, 108); break; case R.id.rl_parking: Intent intentParking = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentParking, 107); + startActivityForResult(intentParking, 109); break; case R.id.rl_number: Intent intentNumber = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentNumber, 108); + startActivityForResult(intentNumber, 110); break; + } } @@ -379,16 +459,14 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 101); + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 101); return false; } }); } else { String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); - Info info = new Info(); - info.setPhoto(takePhotoPath); - photoBean.add(info); + photoBean.add(takePhotoPath); ivPanorama.setImageBitmap(bitmap);//显示图像 } } else if (requestCode == 102 && resultCode == RESULT_OK) { @@ -401,16 +479,14 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 102); + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 102); return false; } }); } else { String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); - Info info = new Info(); - info.setPhoto(takePhotoPath); - photoBean.add(info); + photoBean.add(takePhotoPath); ivCoding.setImageBitmap(bitmap);//显示图像 } } else if (requestCode == 103 && resultCode == RESULT_OK) { @@ -423,19 +499,17 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 103); + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 103); return false; } }); } else { String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); - Info info = new Info(); - info.setPhoto(takePhotoPath); - photoBean.add(info); + photoBean.add(takePhotoPath); ivEquipment.setImageBitmap(bitmap);//显示图像 } - }else if (requestCode == 104 && resultCode == RESULT_OK) { + } else if (requestCode == 104 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 int height = bitmap.getHeight(); @@ -445,19 +519,17 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 104); + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 104); return false; } }); } else { String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); - Info info = new Info(); - info.setPhoto(takePhotoPath); - photoBean.add(info); + photoBean.add(takePhotoPath); ivFacility.setImageBitmap(bitmap);//显示图像 } - }else if (requestCode == 105 && resultCode == RESULT_OK) { + } else if (requestCode == 105 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 int height = bitmap.getHeight(); @@ -467,19 +539,57 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 105); + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 105); return false; } }); } else { String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); - Info info = new Info(); - info.setPhoto(takePhotoPath); - photoBean.add(info); + photoBean.add(takePhotoPath); + ivScutcheon.setImageBitmap(bitmap);//显示图像 + } + } else if (requestCode == 106 && resultCode == RESULT_OK) { + Bundle extras = data.getExtras();//从Intent中获取附加值 + Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 + int height = bitmap.getHeight(); + int width = bitmap.getWidth(); + if (height > width) { + DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; + MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 106); + return false; + } + }); + } else { + String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); + photoBean.add(takePhotoPath); + ivDevice.setImageBitmap(bitmap);//显示图像 + } + } else if (requestCode == 107 && resultCode == RESULT_OK) { + Bundle extras = data.getExtras();//从Intent中获取附加值 + Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 + int height = bitmap.getHeight(); + int width = bitmap.getWidth(); + if (height > width) { + DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; + MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 107); + return false; + } + }); + } else { + String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); + photoBean.add(takePhotoPath); ivUsable.setImageBitmap(bitmap);//显示图像 } - }else if (requestCode == 106 && resultCode == RESULT_OK) { + } else if (requestCode == 108 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 int height = bitmap.getHeight(); @@ -489,19 +599,17 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 106); + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 108); return false; } }); } else { String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); - Info info = new Info(); - info.setPhoto(takePhotoPath); - photoBean.add(info); + photoBean.add(takePhotoPath); ivAvailable.setImageBitmap(bitmap);//显示图像 } - }else if (requestCode == 107 && resultCode == RESULT_OK) { + } else if (requestCode == 109 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 int height = bitmap.getHeight(); @@ -511,19 +619,17 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 107); + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 109); return false; } }); } else { String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); - Info info = new Info(); - info.setPhoto(takePhotoPath); - photoBean.add(info); + photoBean.add(takePhotoPath); ivParking.setImageBitmap(bitmap);//显示图像 } - }else if (requestCode == 108 && resultCode == RESULT_OK) { + } else if (requestCode == 110 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 int height = bitmap.getHeight(); @@ -533,16 +639,14 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 108); + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, 110); return false; } }); } else { String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data); - Info info = new Info(); - info.setPhoto(takePhotoPath); - photoBean.add(info); + photoBean.add(takePhotoPath); ivNumber.setImageBitmap(bitmap);//显示图像 } } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java index ac46199..8f7f363 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java @@ -42,6 +42,7 @@ import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.bean.Info; import com.navinfo.outdoor.bean.PoiBean; +import com.navinfo.outdoor.room.ChargingPileDao; import com.navinfo.outdoor.room.ChargingPileEntity; import com.navinfo.outdoor.room.PoiDao; import com.navinfo.outdoor.room.PoiDatabase; @@ -67,8 +68,8 @@ import static android.app.Activity.RESULT_OK; public class ChargingStationFragment extends BaseDrawerFragment implements View.OnClickListener { private EditText editDescribe; - private RelativeLayout rlPanorama, rlName, rlInternalPhotos, rlCard, rlElse,rlScutcheon; - private ImageView ivPanorama, ivName, ivInternal, ivCard, ivElse,ivScutcheon; + private RelativeLayout rlPanorama, rlName, rlInternalPhotos, rlCard, rlElse, rlScutcheon; + private ImageView ivPanorama, ivName, ivInternal, ivCard, ivElse, ivScutcheon; private TextView tvExamine; private EditText editNameContent, editSiteContent; private RecyclerView recyclerPhone; @@ -90,6 +91,12 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. private LinearLayout linearChargingPile; private RecyclerView recyclerStation; private ChargingPileAdapter chargingPileAdapter; + private int station_type = 0; + private boolean aBoolean = false; + private PoiEntity poiEntity; + private PoiEntity showPoiEntity; + private ArrayList chargingPileEntities; + private ChargingPileDao chargingPileDao; public static ChargingStationFragment newInstance(Bundle bundle) { ChargingStationFragment fragment = new ChargingStationFragment(); @@ -115,19 +122,19 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. @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(); @@ -135,6 +142,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. }); } } + @Override public void onStart() { super.onStart(); @@ -155,20 +163,20 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. @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(); @@ -181,6 +189,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. super.initView(); poiDatabase = PoiDatabase.getInstance(getContext()); poiDao = poiDatabase.getPoiDao(); + chargingPileDao = poiDatabase.getChargingPileDao(); checkBoxLife = findViewById(R.id.check_pot_life); checkBoxRight = findViewById(R.id.check_pot_right); checkBoxLife.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @@ -200,9 +209,28 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. spinnerType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + case 0: + station_type = 0; + break; + case 1: + station_type = 1; + break; + case 2: + station_type = 2; + break; + case 3: + station_type = 3; + break; + case 4: + station_type = 4; + break; + } } + @Override - public void onNothingSelected(AdapterView parent) {} + public void onNothingSelected(AdapterView parent) { + } }); //添加桩 linearChargingPile = findViewById(R.id.linear_charging_pile); @@ -232,7 +260,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. rlCard.setOnClickListener(this::onClick); rlElse = findViewById(R.id.rl_else); rlElse.setOnClickListener(this::onClick); - rlScutcheon= findViewById(R.id.rl_scutcheon); + rlScutcheon = findViewById(R.id.rl_scutcheon); rlScutcheon.setOnClickListener(this::onClick); recyclerPhone = findViewById(R.id.recycler_phone); recyclerPhone.setLayoutManager(new LinearLayoutManager(getContext())); @@ -268,14 +296,47 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } }); recyclerStation = findViewById(R.id.recycler_station); - recyclerStation.setLayoutManager(new GridLayoutManager(getContext(),3)); + recyclerStation.setLayoutManager(new GridLayoutManager(getContext(), 3)); chargingPileAdapter = new ChargingPileAdapter(getContext()); recyclerStation.setAdapter(chargingPileAdapter); + /** + * 数据处理 + */ + showPoiEntity = (PoiEntity) getArguments().getSerializable("PoiEntity"); + if (showPoiEntity != null) { + editNameContent.setText(showPoiEntity.getName()); + editDescribe.setText(showPoiEntity.getDescribe()); + editSiteContent.setText(showPoiEntity.getAddress()); + String x = showPoiEntity.getX(); + String y = showPoiEntity.getY(); + int id = showPoiEntity.getId(); + new Thread(new Runnable() { + @Override + public void run() { + List chargingPile = chargingPileDao.getChargingPile(); + for (int i = 0; i < chargingPile.size(); i++) { + ChargingPileEntity chargingPileEntity = chargingPile.get(i); + if (id == chargingPileEntity.getFid()) { + chargingPileEntities.add(chargingPileEntity); + } + } + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + chargingPileAdapter.setChargingPileEntities(chargingPileEntities); + } + }); + + } + }).start(); + } + //禁用所有可操作控件 //disables(); } -//禁用所有可操作性控件 + + //禁用所有可操作性控件 private void disables() { checkBoxLife.setEnabled(false); editNameContent.setEnabled(false); @@ -300,21 +361,30 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. phoneData = new ArrayList<>(); //存储图片地址 photoBean = new ArrayList<>(); + //充电桩的数据 + chargingPileEntities = new ArrayList<>(); + } - - @Subscribe public void onEvent(Message data) { if (data.what == Constant.CHARGING_STATION_WORD) { inode = data.obj.toString(); Toast.makeText(getContext(), inode, Toast.LENGTH_SHORT).show(); - }else if (data.what==Constant.CHARGING_PILE_STATION){ + } else if (data.what == Constant.CHARGING_PILE_STATION) { ChargingPileEntity chargingPileEntity = (ChargingPileEntity) data.obj; + chargingPileEntity.setFid(poiEntity.getId()); + new Thread(new Runnable() { + @Override + public void run() { + chargingPileDao.insertChargingPileEntity(chargingPileEntity); + } + }).start(); ArrayList chargingPileEntities = new ArrayList<>(); chargingPileEntities.add(chargingPileEntity); chargingPileAdapter.setChargingPileEntities(chargingPileEntities); + aBoolean = true; } } @@ -330,7 +400,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. public void onGranted(List permissions, boolean all) { if (all) { //保存数据库: - PoiEntity poiEntity = new PoiEntity(); + poiEntity = new PoiEntity(); String name = editNameContent.getText().toString().trim();//名称 if (name == null || name.equals("")) { Toast.makeText(getActivity(), "请输入充电站 名称", Toast.LENGTH_SHORT).show(); @@ -358,7 +428,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. Toast.makeText(getActivity(), "请输入任务描述", Toast.LENGTH_SHORT).show(); return; } else { - poiEntity.setDescribe(describe); + poiEntity.setMemo(describe); } if (phoneData.size() <= 0) { Toast.makeText(getActivity(), "请输入手机号", Toast.LENGTH_SHORT).show(); @@ -366,12 +436,19 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } else { poiEntity.setTelPhone(phoneData.get(0)); } - if (photoBean.size() < 0) { + if (photoBean.size() != 6) { Toast.makeText(getActivity(), "请拍照", Toast.LENGTH_SHORT).show(); return; } else { poiEntity.setPhotoInfo(photoBean); } + poiEntity.setStation_type(station_type); + if (!aBoolean) { + Toast.makeText(getActivity(), "请添加桩", Toast.LENGTH_SHORT).show(); + return; + } else { + aBoolean = false; + } DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); @@ -382,7 +459,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. new Thread(new Runnable() { @Override public void run() { - poiDao.insertPoiEntity(poiEntity); + poiDao.insertPoiEntity(poiEntity); } }).start(); Message obtains = Message.obtain(); @@ -565,7 +642,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. ivElse.setImageBitmap(bitmap);//显示图像 } - }else if (requestCode==106 &&resultCode ==RESULT_OK){ + } else if (requestCode == 106 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 int height = bitmap.getHeight(); @@ -589,6 +666,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } } } + @Override public void onDestroy() { if (EventBus.getDefault().isRegistered(this))//加上判断 diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java index da7ad9d..149d8ee 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java @@ -194,11 +194,11 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen showSlidingFragment(roadFragment); break; case 2: - ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(new Bundle()); + ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle); showSlidingFragment(chargingStationFragment); break; case 3: - OtherFragment otherFragment = OtherFragment.newInstance(new Bundle()); + OtherFragment otherFragment = OtherFragment.newInstance(bundle); showSlidingFragment(otherFragment); break; } diff --git a/app/src/main/java/com/navinfo/outdoor/room/ChargingPileDao.java b/app/src/main/java/com/navinfo/outdoor/room/ChargingPileDao.java index d56d17b..d99c561 100644 --- a/app/src/main/java/com/navinfo/outdoor/room/ChargingPileDao.java +++ b/app/src/main/java/com/navinfo/outdoor/room/ChargingPileDao.java @@ -49,14 +49,6 @@ public interface ChargingPileDao { @Delete void deleteAll(List chargingPileEntities); - /** - * 根据条件删除 - * @param taskStatus - */ - @Query("DELETE FROM pile where taskStatus=:taskStatus") - void deleteFormName(int taskStatus); - - /** * 全部删除 */ @@ -70,10 +62,5 @@ public interface ChargingPileDao { @Query("SELECT * FROM pile ORDER BY pileId DESC") List getAllChargingPileEntity(); - @Query("SELECT * FROM pile where userId = :userId") - ChargingPileEntity queryChargingPileEntity(int userId); - - @Query("DELETE FROM pile where userId = :userId") - void deleteChargingPileEntity(int userId); } diff --git a/app/src/main/java/com/navinfo/outdoor/room/ChargingPileEntity.java b/app/src/main/java/com/navinfo/outdoor/room/ChargingPileEntity.java index 2deca23..f2b21f5 100644 --- a/app/src/main/java/com/navinfo/outdoor/room/ChargingPileEntity.java +++ b/app/src/main/java/com/navinfo/outdoor/room/ChargingPileEntity.java @@ -7,6 +7,7 @@ import androidx.room.TypeConverters; import com.navinfo.outdoor.bean.Info; import com.navinfo.outdoor.util.PhotoInfoConverter; +import com.navinfo.outdoor.util.StringTypeConverter; import java.util.List; @@ -21,26 +22,16 @@ import static androidx.room.ForeignKey.CASCADE; public class ChargingPileEntity { @PrimaryKey(autoGenerate = true) // 设置主键,并且自动生长 private int pileId; - private int pid; //采集id 保存本地或提交数据时时返回 - private int taskId;//任务id - private int userId;//用户id - private String createTime; //创建时间/采集时间 private String name;//名称 - private String describe;//任务描述 - private String address;//地址 - private String telPhone;//电话 - private String memo;//备注 - private double precision;//金额 - private String photo;//照片信息 - //ROOM不支持直接存储集合 - @TypeConverters(PhotoInfoConverter.class) - private List photoInfo;//照片信息 - private int existence;//是否存在 - private String x;//经度 - private String y;//纬度 - private String detail;//深度信息 - private int taskStatus;//任务状态 0.待提交,1.已提交,2 已领取 - private int type;//0.poi,1.道路,2.充电站,3.其他 + private String p;//经纬度 + private int exist;//是否存在 0不存在1存在 + private int cp_floor;//充电桩地面层 地面层是1 ,地上二层为2,向上依次加1,地下一层为-1,向下依次减1.默认为1 + private int sign_exist;//设备标牌是否存在 0不存在1存在 + private int cp_availableState;//可以状态 0(可以使用(有电),默认),1(不可使用(没电)),2(维修中),3(建设中)4(规划中) + private String memo;//备注 默认为空 + @TypeConverters(StringTypeConverter.class) + private List photos;//照片组 + private int fid;//对应充电站id public int getPileId() { return pileId; @@ -49,53 +40,6 @@ public class ChargingPileEntity { public void setPileId(int pileId) { this.pileId = pileId; } - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public int getTaskStatus() { - return taskStatus; - } - - public void setTaskStatus(int taskStatus) { - this.taskStatus = taskStatus; - } - - public int getPid() { - return pid; - } - - public void setPid(int pid) { - this.pid = pid; - } - - public int getTaskId() { - return taskId; - } - - public void setTaskId(int taskId) { - this.taskId = taskId; - } - - public int getUserId() { - return userId; - } - - public void setUserId(int userId) { - this.userId = userId; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } public String getName() { return name; @@ -105,28 +49,44 @@ public class ChargingPileEntity { this.name = name; } - public String getDescribe() { - return describe; + public String getP() { + return p; } - public void setDescribe(String describe) { - this.describe = describe; + public void setP(String p) { + this.p = p; } - public String getAddress() { - return address; + public int getExist() { + return exist; } - public void setAddress(String address) { - this.address = address; + public void setExist(int exist) { + this.exist = exist; } - public String getTelPhone() { - return telPhone; + public int getCp_floor() { + return cp_floor; } - public void setTelPhone(String telPhone) { - this.telPhone = telPhone; + public void setCp_floor(int cp_floor) { + this.cp_floor = cp_floor; + } + + public int getSign_exist() { + return sign_exist; + } + + public void setSign_exist(int sign_exist) { + this.sign_exist = sign_exist; + } + + public int getCp_availableState() { + return cp_availableState; + } + + public void setCp_availableState(int cp_availableState) { + this.cp_availableState = cp_availableState; } public String getMemo() { @@ -137,60 +97,19 @@ public class ChargingPileEntity { this.memo = memo; } - public double getPrecision() { - return precision; + public List getPhotos() { + return photos; } - public void setPrecision(double precision) { - this.precision = precision; + public void setPhotos(List photos) { + this.photos = photos; } - public String getPhoto() { - return photo; + public int getFid() { + return fid; } - public void setPhoto(String photo) { - this.photo = photo; + public void setFid(int fid) { + this.fid = fid; } - - public List getPhotoInfo() { - return photoInfo; - } - - public void setPhotoInfo(List infoList) { - this.photoInfo = infoList; - } - - public int getExistence() { - return existence; - } - - public void setExistence(int existence) { - this.existence = existence; - } - - public String getX() { - return x; - } - - public void setX(String x) { - this.x = x; - } - - public String getY() { - return y; - } - - public void setY(String y) { - this.y = y; - } - - public String getDetail() { - return detail; - } - - public void setDetail(String detail) { - this.detail = detail; - } - } diff --git a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java index 79e1a54..29ed6e1 100644 --- a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java +++ b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java @@ -17,7 +17,6 @@ import java.util.List; public class PoiEntity implements Serializable { @PrimaryKey(autoGenerate = true) // 设置主键,并且自动生长 private int id; - private int pid; //采集id 保存本地或提交数据时时返回 private int taskId;//任务id private int userId;//用户id @@ -57,6 +56,15 @@ public class PoiEntity implements Serializable { private String detail;//深度信息 private int taskStatus;//任务状态 0.待提交,1.已提交,2 已领取 private int type;//0.poi,1.道路,2.充电站,3.其他 + private int station_type;//0.全部,1.poi,2.道路,3.充电站,4.其他 + + public int getStation_type() { + return station_type; + } + + public void setStation_type(int station_type) { + this.station_type = station_type; + } public int getType() { return type; diff --git a/app/src/main/res/layout/charging_pile_fragment.xml b/app/src/main/res/layout/charging_pile_fragment.xml index 19edf5f..3549eb1 100644 --- a/app/src/main/res/layout/charging_pile_fragment.xml +++ b/app/src/main/res/layout/charging_pile_fragment.xml @@ -104,7 +104,7 @@ android:layout_marginLeft="18dp" android:layout_toRightOf="@id/tv_name" android:background="@color/white" - android:hint="充电桩" + android:text="充电桩" android:layout_toEndOf="@id/tv_name" android:textSize="15sp" android:textColor="#333" /> @@ -419,7 +419,77 @@ android:layout_height="match_parent" /> - + + + + + + + + + + + @@ -468,23 +471,31 @@ android:id="@+id/recycler_station" android:layout_width="match_parent" android:layout_height="wrap_content" - app:layout_constraintTop_toBottomOf="@+id/tv_03" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/linear_charging_pile" /> + + android:orientation="vertical" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@+id/linear_photograph"> + + + android:text="添加桩" /> + app:layout_constraintTop_toBottomOf="@id/recycler_station" /> - + app:layout_constraintTop_toTopOf="parent"> + + + + + \ No newline at end of file