充电站充电桩保存到数据库

This commit is contained in:
wds 2021-06-24 18:52:40 +08:00
parent deca4550cf
commit 8836e4c302
11 changed files with 484 additions and 275 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,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<ChargingPileAdapte
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
String photo = chargingPileEntities.get(position).getPhotoInfo().get(0).getPhoto();
Glide.with(context).load(photo).into(holder.imageView);
holder.rlItem.setBackgroundColor(Color.parseColor("#03A9F4"));
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
@Override
@ -49,9 +56,11 @@ public class ChargingPileAdapter extends RecyclerView.Adapter<ChargingPileAdapte
public class ViewHolder extends RecyclerView.ViewHolder {
ImageView imageView;
RelativeLayout rlItem;
public ViewHolder(@NonNull View itemView) {
super(itemView);
imageView=itemView.findViewById(R.id.image);
rlItem=itemView.findViewById(R.id.rl_item);
}
}
}

View File

@ -2,6 +2,7 @@ package com.navinfo.outdoor.fragment;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
@ -68,18 +69,21 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
private Button btnSaveLocal;
private PoiDatabase poiDatabase;
private String inode;
private List<Info> photoBean;
private List<String> 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<String> 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);//显示图像
}
}

View File

@ -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<ChargingPileEntity> 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<ChargingPileEntity> 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<ChargingPileEntity> 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<String> 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))//加上判断

View File

@ -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;
}

View File

@ -49,14 +49,6 @@ public interface ChargingPileDao {
@Delete
void deleteAll(List<ChargingPileEntity> 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<ChargingPileEntity> getAllChargingPileEntity();
@Query("SELECT * FROM pile where userId = :userId")
ChargingPileEntity queryChargingPileEntity(int userId);
@Query("DELETE FROM pile where userId = :userId")
void deleteChargingPileEntity(int userId);
}

View File

@ -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<Info> 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<String> 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<String> getPhotos() {
return photos;
}
public void setPrecision(double precision) {
this.precision = precision;
public void setPhotos(List<String> 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<Info> getPhotoInfo() {
return photoInfo;
}
public void setPhotoInfo(List<Info> 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;
}
}

View File

@ -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;

View File

@ -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"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_scutcheon"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:background="#03A9F4"
android:visibility="gone"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_marginRight="5dp"
android:layout_marginBottom="10dp">
<ImageView
android:id="@+id/image_scutcheon"
android:layout_centerHorizontal="true"
android:layout_width="20dp"
android:layout_marginTop="30dp"
android:background="@drawable/equipsign"
android:layout_height="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="*设备标牌"
android:textSize="8sp"
android:layout_margin="5dp"
android:textColor="@color/pickerview_wheelview_textcolor_divider"
android:layout_below="@id/image_scutcheon"
/>
<ImageView
android:id="@+id/iv_scutcheon"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_device"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:background="#03A9F4"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:layout_marginRight="5dp"
android:layout_marginBottom="10dp">
<ImageView
android:id="@+id/image_device"
android:layout_centerHorizontal="true"
android:layout_width="20dp"
android:layout_marginTop="30dp"
android:background="@drawable/equipsign"
android:layout_height="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="*设备标牌"
android:textSize="8sp"
android:layout_margin="5dp"
android:textColor="@color/pickerview_wheelview_textcolor_divider"
android:layout_below="@id/image_device"
/>
<ImageView
android:id="@+id/iv_device"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/linear_stake"

View File

@ -2,6 +2,7 @@
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scroller_view"
@ -455,12 +456,14 @@
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/tv_03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="03.添加"
android:layout_margin="10dp"
android:text="03.添加"
app:layout_constraintBottom_toTopOf="@+id/recycler_station"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/linear_photograph" />
@ -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" />
<LinearLayout
android:id="@+id/linear_charging_pile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginStart="10dp"
android:orientation="vertical"
android:background="@drawable/underline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/recycler_station">
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear_photograph">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:background="@drawable/plus" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/plus" />
android:text="添加桩" />
</LinearLayout>
<TextView
android:id="@+id/tv_04"
@ -493,7 +504,7 @@
android:text="04.描述"
android:layout_margin="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/linear_charging_pile" />
app:layout_constraintTop_toBottomOf="@id/recycler_station" />
<LinearLayout
android:id="@+id/linear_describe"
android:layout_width="match_parent"

View File

@ -2,13 +2,36 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="120dp"
android:layout_height="120dp"
<RelativeLayout
android:id="@+id/rl_item"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_margin="10dp"
android:background="#03A9F4"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/image"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="@drawable/chartall" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/image"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
android:text="*充电桩"
android:textColor="@color/pickerview_wheelview_textcolor_divider"
android:textSize="8sp" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>