修改二级bug,纪录提交

This commit is contained in:
wds 2021-07-27 19:22:45 +08:00
parent 1f29e7cbc2
commit bdf5032111
19 changed files with 559 additions and 238 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

@ -24,8 +24,10 @@ import com.navinfo.outdoor.R;
import com.google.android.material.tabs.TabLayout;
import com.gyf.immersionbar.ImmersionBar;
import com.navinfo.outdoor.util.TecentLocationUtils;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.util.ArrayList;
@ -36,15 +38,21 @@ public class HomeActivity extends BaseActivity{
private NoSlideViewPager mViewPager;
private TabLayout mTab;
private final String[] names = {"寻宝", "记录", "发现", "我的"};
private final int[] pic = {R.mipmap.map_select,R.mipmap.task_select,R.mipmap.article_select,R.mipmap.mine_select};
private final int[] pic1 = {R.mipmap.map,R.mipmap.task,R.mipmap.article,R.mipmap.mine};
private final int[] pic = {R.drawable.selector_map,R.drawable.selector_task,R.drawable.selector_article,R.drawable.selector_mine};
private RecordFragment recordFragment;
@Override
protected int getLayout() {
return R.layout.activity_home;
}
@Override
public void onStart() {
super.onStart();
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this);
}
}
@Override
protected void initView() {
super.initView();
@ -96,14 +104,14 @@ public class HomeActivity extends BaseActivity{
mViewPager.setNoScrollAnim(false);
mTab.setupWithViewPager(mViewPager);
mTab.getTabAt(0).setText(names[0]).setIcon(pic[0]);
mTab.getTabAt(1).setText(names[1]).setIcon(pic1[1]);
mTab.getTabAt(2).setText(names[2]).setIcon(pic1[2]);
mTab.getTabAt(3).setText(names[3]).setIcon(pic1[3]);
mTab.getTabAt(1).setText(names[1]).setIcon(pic[1]);
mTab.getTabAt(2).setText(names[2]).setIcon(pic[2]);
mTab.getTabAt(3).setText(names[3]).setIcon(pic[3]);
mTab.getTabAt(0).select();
mTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
//禁止table layout效果
@Override
public void onTabSelected(TabLayout.Tab tab) {
mTab.getTabAt(tab.getPosition()).setIcon(pic[tab.getPosition()]);
if (tab.getPosition()==1){
Message obtain = Message.obtain();
obtain.what = Constant.HOME_TREASURE;
@ -120,8 +128,6 @@ public class HomeActivity extends BaseActivity{
//点击table layout效果
@Override
public void onTabUnselected(TabLayout.Tab tab) {
mTab.getTabAt(tab.getPosition()).setIcon(pic1[tab.getPosition()]);
}
@Override
@ -131,15 +137,16 @@ public class HomeActivity extends BaseActivity{
});
}
public View getTabView(String name,int image) {
View view = LayoutInflater.from(this).inflate(R.layout.item_tab, null);
TextView txt_title = (TextView) view.findViewById(R.id.txt_title);
txt_title.setText(name);
ImageView img_title = (ImageView) view.findViewById(R.id.img_title);
img_title.setImageResource(image);
return view;
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.EVENT_WORK_HOME) {
if ((boolean)data.obj){
mTab.getTabAt(0).select();
}
}
}
@Override
public void onBackPressed() {
if (!BackHandlerHelper.handleBackPress(this)) {
@ -149,6 +156,8 @@ public class HomeActivity extends BaseActivity{
@Override
protected void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
}
}

View File

@ -26,8 +26,6 @@ public class BankAdapter extends RecyclerView.Adapter<BankAdapter.ViewHolder> {
this.context = context;
}
@NonNull
@NotNull
@Override
public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
View inflate = LayoutInflater.from(context).inflate(R.layout.bankadapteritem, parent, false);

View File

@ -31,6 +31,10 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
this.context = context;
}
public List<PoiEntity> getAllRoad() {
return allRoad;
}
public void setAllRoad(List<PoiEntity> allRoad) {
this.allRoad.clear();

View File

@ -84,8 +84,9 @@ public class Constant {
public static final int EVENT_WHAT_CURRENT_MARKER = 41; // 显示当前正在编辑的POI类型数据的Event的What值
//CompleteTask
public static final int EVENT_WHAT_COMPLETE_TASK = 42; // 点击记录跳转开始采集
public static final int EVENT_STAY_REFRESH = 44; // 刷新记录页面
public static final int EVENT_WORK_HOME = 45; //切换到寻宝
public static String USER_ATTESTATION_NAME; //实名认证姓名 银行卡
public static int NUMBER = 200; //任务个数
public static int LIMIT_TTPE = -1; //权限类型普通任务-0专属任务-1

View File

@ -442,6 +442,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
if (showPoiEntity.getName() != null) {
linearExist.setVisibility(View.VISIBLE);
spinnerExist.setSelection(showPoiEntity.getExistence(), true);
existence=showPoiEntity.getExistence();
}
if (showPoiEntity.getPhotoInfo() != null) {
for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) {
@ -816,18 +817,30 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
} else {
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));
if (existence==0){
String tagInternal = (String) ivInternal.getTag();
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) {
Toast.makeText(getActivity(), "请拍照 充电站指引牌", Toast.LENGTH_SHORT).show();
return;
}else {
infoPhoto.add(new Info(tagElse));
}
String tagScutcheon = (String) ivScutcheon.getTag();
if (tagScutcheon == null) {
Toast.makeText(getActivity(), "请拍照 收费标牌", Toast.LENGTH_SHORT).show();
return;
}else {
infoPhoto.add(new Info(tagScutcheon));
}
}
poiEntity.setExistence(existence);
poiEntity.setPhotoInfo(infoPhoto);
poiEntity.setStation_type(station_type);
@ -949,7 +962,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
* */
private void chargingStationSaveByWork(PoiEntity poiEntity, boolean isLocal) {
showLoadingDialog();
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("sptype", poiEntity.getStation_type());
@ -1317,7 +1329,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
new Thread(new Runnable() {
/* new Thread(new Runnable() {
@Override
public void run() {
PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
@ -1326,6 +1338,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
chargingPileDao.deleteChargingFidPileEntity(showPoiEntity.getId());
}
}
}).start();
}).start();*/
}
}

View File

@ -686,7 +686,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
}).build();
}
private void senMessageMarker(int type,String y,String x) {
@Override
public void onDestroy() {
super.onDestroy();
}
private void senMessageMarker(int type, String y, String x) {
Message markerMsg = Message.obtain();
markerMsg.what = Constant.EVENT_WHAT_CURRENT_MARKER;
LatLng latLng = new LatLng(Double.parseDouble(y), Double.parseDouble(x));

View File

@ -614,6 +614,8 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
// new Thread(new Runnable() {
// @Override

View File

@ -762,7 +762,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal) {
poiUploadByNetWork(body, poiPicList);//上传
} else {
@ -983,6 +982,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
// new Thread(new Runnable() {
// @Override

View File

@ -88,7 +88,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
private PoiDatabase poiDatabase;
private PoiDao poiDao;
private PoiEntity showPoiEntity;
private File videoFile;
private Button btnPoiVideoUpload;
private String videoPath;
private File fileZip;
@ -174,9 +173,10 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override
public boolean onLongClick(View v) {
DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
MessageDialog.show((AppCompatActivity) getContext(), "提示", "否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
MessageDialog.show((AppCompatActivity) getContext(), "提示", "否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
File videoFile = (File) ivPoiVideoPicture.getTag();
if (videoFile != null) {
videoFile.delete();
//获取文件名
@ -205,12 +205,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
if (name != null && !name.equals("")) {
etRoadName.setText(name + "");
}
String extend = showPoiEntity.getExtend();
if (extend != null && !extend.equals("")) {
RoadExtend roadExtend = new Gson().fromJson(extend, RoadExtend.class);
int type = roadExtend.getType();
showPictureType(type);
}
int work_type = showPoiEntity.getWork_type();
showPictureType(work_type);
String describe = showPoiEntity.getDescribe();//任务描述
if (describe != null && !describe.equals("")) {
etDesc.setText(describe);
@ -226,8 +222,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
}
}
//判断是否是已做完任务并保存成功
if (showPoiEntity.getTaskStatus() == 3){
disables();//禁用所有可操作的控件
if (showPoiEntity.getTaskStatus() == 3) {
disables();//禁用所有可操作的控件
}
}
@ -286,20 +282,21 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
case R.id.btn_poi_video_upload:
ArrayList<File> videoFileList = new ArrayList<>();
if (videoFile != null) {
if (ivPoiVideoPicture.getTag() != null) {
File videoFile = (File) ivPoiVideoPicture.getTag();
videoFileList.add(videoFile);
File file = new File(videoFile.getPath()+".txt");
videoFileList.add(file);
}
fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
ZipUtil.zipFiles(videoFileList, fileZip,null);
ZipUtil.zipFiles(videoFileList, fileZip, null);
new Thread(new Runnable() {
@Override
public void run() {
PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
if (poiDaoPoiEntity == null||poiDaoPoiEntity.getTaskStatus()==1||poiDaoPoiEntity.getTaskStatus()==2||poiDaoPoiEntity.getTaskStatus()==0){
if (poiDaoPoiEntity == null || poiDaoPoiEntity.getTaskStatus() == 1 || poiDaoPoiEntity.getTaskStatus() == 2 || poiDaoPoiEntity.getTaskStatus() == 0) {
initPoiSaveLocal(true);
}else {
} else {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
@ -313,6 +310,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
break;
}
}
public void initPoiSaveLocal(boolean isLocal) {
XXPermissions.with(getContext())
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
@ -323,8 +321,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
PoiEntity poiEntity = showPoiEntity;
String roadName = etRoadName.getText().toString().trim();
if (roadName != null && !roadName.equals("")) {
poiEntity.setName(roadName+"");
}else {
poiEntity.setName(roadName + "");
} else {
DateFormat formatters = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
Calendar calendars = Calendar.getInstance();
calendars.setTimeInMillis(System.currentTimeMillis());
@ -332,11 +330,11 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
String city = Constant.currentLocation.getCity();//返回当前位置的城市.
String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
StringBuilder sb = new StringBuilder("poi录像上报");
if (city!=null&&!"".equals(city)) {
if (city != null && !"".equals(city)) {
sb.append("-");
sb.append(city);
}
if (district!=null&&!"".equals(district)) {
if (district != null && !"".equals(district)) {
sb.append(district);
}
sb.append("-").append(formats);
@ -349,16 +347,13 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
}
});
}
RoadExtend roadExtend = new RoadExtend();
int type = getPictureType();
if (type == -1) {
int pictureType = getPictureType();
if (pictureType == -1) {
Toast.makeText(getContext(), "请选择拍照方式", Toast.LENGTH_SHORT).show();
return;
} else {
poiEntity.setWork_type(pictureType);
}
roadExtend.setType(type);
Gson gson = new Gson();
String roadExtendJson = gson.toJson(roadExtend);
poiEntity.setExtend(roadExtendJson);
String desc = etDesc.getText().toString().trim();
if (desc != null && !desc.equals("")) {
poiEntity.setDescribe(desc);
@ -370,7 +365,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
}
if (ivPoiVideoPicture.getTag() != null) {
File videoFile = (File) ivPoiVideoPicture.getTag();
String path = videoFile.getPath()+".txt";
String path = videoFile.getPath() + ".txt";
poiEntity.setPhoto(videoFile.getAbsolutePath());
List<String> strings = FileUtils.readFileToList(path, "utf-8");
ArrayList<LatLng> latLngs = new ArrayList<>();
@ -381,14 +376,15 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
latLng.setLongitude(Double.valueOf(split[3]));
latLngs.add(latLng);
}
if (strings.size()==1){
if (strings.size() == 1) {
LatLng latLng = latLngs.get(0);
latLngs.add(latLng);
}
String lineString = GeometryTools.getLineString(latLngs);
Log.d("TAG", "onGranted: "+lineString);
Log.d("TAG", "onGranted: " + lineString);
poiEntity.setGeoWkt(lineString);
}
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
@ -405,13 +401,13 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoSave(poiEntity,isLocal);
poiVideoSave(poiEntity, isLocal);
}
});
}
}).start();
//onBackPressed();
}else {
} else {
Toast.makeText(getActivity(), "没有申请权限,请手动申请", Toast.LENGTH_SHORT).show();
}
}
@ -428,13 +424,12 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
}
private void poiVideoUpload(int poiVideoBody, File fileZip) {
if (poiVideoBody == 0) {
Toast.makeText(getActivity(), "请先保存本地在上传", Toast.LENGTH_SHORT).show();
return;
}
if (fileZip==null){
if (fileZip == null) {
Toast.makeText(getActivity(), "未压缩完成", Toast.LENGTH_SHORT).show();
return;
}
@ -442,8 +437,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
// 请求方式和请求url
.<OtherUploadPicBean>post(HttpInterface.POI_VIDEO_UPLOAD_PIC)
// 请求的 tag, 主要用于取消对应的请求
.params("auditId",poiVideoBody)
.params("file",fileZip)
.params("auditId", poiVideoBody)
.params("file", fileZip)
.tag(this)
.execute(new DialogCallback<OtherUploadPicBean>(OtherUploadPicBean.class) {
@Override
@ -470,24 +465,19 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
public void onError(Response<OtherUploadPicBean> response) {
super.onError(response);
dismissLoadingDialog();
Toast.makeText(getActivity(), response.code()+"", Toast.LENGTH_SHORT).show();
Log.d("TAG", "onError: " + response.code()+"");
Toast.makeText(getActivity(), response.code() + "", Toast.LENGTH_SHORT).show();
Log.d("TAG", "onError: " + response.code() + "");
}
});
}
private void poiVideoSave(PoiEntity poiEntity,boolean isLocal) {
private void poiVideoSave(PoiEntity poiEntity, boolean isLocal) {
showLoadingDialog();
int pictureType = getPictureType();
if (pictureType == -1) {
Toast.makeText(getContext(), "请选择拍照方式", Toast.LENGTH_SHORT).show();
return;
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", pictureType);
httpParams.put("workType", poiEntity.getWork_type());
httpParams.put("memo", poiEntity.getMemo());
OkGoBuilder.getInstance()
.Builder(getActivity())
@ -500,7 +490,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
public void onSuccess(PoiVideoBean poiVideoBean, int id) {
dismissLoadingDialog();
Integer poiVideoBody = poiVideoBean.getBody();
if (poiVideoBody!=null&&poiVideoBody!=0){
if (poiVideoBody != null && poiVideoBody != 0) {
poiEntity.setBodyId(poiVideoBody);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@ -510,9 +500,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal){
poiVideoUpload(poiVideoBody,fileZip);
}else {
if (isLocal) {
poiVideoUpload(poiVideoBody, fileZip);
} else {
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
onBackPressed();
}
@ -520,7 +510,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
});
}
}).start();
}else {
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), "没有获取到具体位置", Toast.LENGTH_SHORT).show();
}
@ -541,7 +532,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
if (requestCode == 0x101 && resultCode == 0x101) {
if (data != null && data.hasExtra(Constant.INTENT_VIDEO_PATH)) {
videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH);
videoFile = new File(videoPath);
File videoFile = new File(videoPath);
if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
ivPoiVideoPicture.setTag(videoFile);
@ -574,13 +565,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
if (roadName != null && !roadName.equals("")) {
poiEntity.setName(roadName);
}
RoadExtend roadExtend = new RoadExtend();
int type = getPictureType();
if (type != -1) {
roadExtend.setType(type);
Gson gson = new Gson();
String roadExtendJson = gson.toJson(roadExtend);
poiEntity.setExtend(roadExtendJson);
int pictureType = getPictureType();
if (pictureType != -1) {
poiEntity.setWork_type(pictureType);
}
String desc = etDesc.getText().toString().trim();
if (desc != null && !desc.equals("")) {
@ -633,17 +620,20 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
break;
}
}
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
new Thread(new Runnable() {
/* new Thread(new Runnable() {
@Override
public void run() {
PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
if (poiDaoPoiEntity!=null&&poiDaoPoiEntity.getName() == null) {
if (poiDaoPoiEntity != null && poiDaoPoiEntity.getName() == null) {
poiDao.deletePoiEntity(poiDaoPoiEntity);
}
}
}).start();
}).start();*/
}
}

View File

@ -84,7 +84,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
private PoiDao poiDao;
private PoiEntity showPoiEntity;
private Button roadUpload;
private File videoFile;
private String videoPath;
private File fileZip;
@ -157,7 +156,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
@Override
public void onClick(View v) {
if (v.getTag() == null) {
Toast.makeText(getContext(), "还没有拍摄视频!", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), "还没有拍摄视频!", Toast.LENGTH_SHORT).show();
return;
}
File videoFile = (File) v.getTag();
@ -181,12 +180,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (name != null && !name.equals("")) {
etRoadName.setText(name + "");
}
String extend = showPoiEntity.getExtend();
if (extend != null && !extend.equals("")) {
RoadExtend roadExtend = new Gson().fromJson(extend, RoadExtend.class);
int type = roadExtend.getType();
showPictureType(type);
}
int work_type = showPoiEntity.getWork_type();
showPictureType(work_type);
String describe = showPoiEntity.getDescribe();//任务描述
if (describe != null && !describe.equals("")) {
etDesc.setText(describe);
@ -265,7 +260,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
break;
case R.id.road_upload:
ArrayList<File> videoFileList = new ArrayList<>();
if (videoFile != null) {
if (ivRoadPicture.getTag() != null) {
File videoFile = (File) ivRoadPicture.getTag();
videoFileList.add(videoFile);
File file = new File(videoFile.getPath() + ".txt");
videoFileList.add(file);
@ -330,16 +326,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
}
});
}
RoadExtend roadExtend = new RoadExtend();
int type = getPictureType();
if (type == -1) {
Toast.makeText(getContext(), "请选择拍照方式", Toast.LENGTH_SHORT).show();
return;
}
roadExtend.setType(type);
Gson gson = new Gson();
String roadExtendJson = gson.toJson(roadExtend);
poiEntity.setExtend(roadExtendJson);
String desc = etDesc.getText().toString().trim();
if (desc != null && !desc.equals("")) {
poiEntity.setDescribe(desc);
@ -351,7 +337,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
}
if (ivRoadPicture.getTag() != null) {
File videoFile = (File) ivRoadPicture.getTag();
poiEntity.setPhoto(videoFile.getAbsolutePath());
String path = videoFile.getPath() + ".txt";
poiEntity.setPhoto(videoFile.getAbsolutePath());
List<String> strings = FileUtils.readFileToList(path, "utf-8");
@ -371,6 +356,13 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
Log.d("TAG", "onGranted: " + lineString);
poiEntity.setGeoWkt(lineString);
}
int pictureType = getPictureType();
if (pictureType == -1) {
Toast.makeText(getContext(), "请选择拍照方式", Toast.LENGTH_SHORT).show();
return;
}else {
poiEntity.setWork_type(pictureType);
}
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
@ -460,16 +452,11 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
private void roadSaveBetWork(PoiEntity poiEntity, boolean isLocal) {
showLoadingDialog();
int pictureType = getPictureType();
if (pictureType == -1) {
Toast.makeText(getContext(), "请选择拍照方式", Toast.LENGTH_SHORT).show();
return;
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", pictureType);
httpParams.put("workType", poiEntity.getWork_type());
httpParams.put("memo", poiEntity.getMemo());
OkGoBuilder.getInstance()
.Builder(getActivity())
@ -495,13 +482,14 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (isLocal) {
poiVideoUpload(poiVideoBody, fileZip);
} else {
Toast.makeText(getContext(), "保存成功", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
onBackPressed();
}
}
});
}
}).start();
}else {
Toast.makeText(getContext(), "没获取到具体的位置", Toast.LENGTH_SHORT).show();
}
@ -524,7 +512,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (requestCode == 0x101 && resultCode == 0x101) {
if (data != null && data.hasExtra(Constant.INTENT_VIDEO_PATH)) {
videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH);
videoFile = new File(videoPath);
File videoFile = new File(videoPath);
if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500);
ivRoadPicture.setTag(videoFile);
@ -557,13 +545,9 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (roadName != null && !roadName.equals("")) {
poiEntity.setName(roadName);
}
RoadExtend roadExtend = new RoadExtend();
int type = getPictureType();
if (type != -1) {
roadExtend.setType(type);
Gson gson = new Gson();
String roadExtendJson = gson.toJson(roadExtend);
poiEntity.setExtend(roadExtendJson);
int pictureType = getPictureType();
if (pictureType != -1) {
poiEntity.setWork_type(pictureType);
}
String desc = etDesc.getText().toString().trim();
if (desc != null && !desc.equals("")) {
@ -623,6 +607,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
// new Thread(new Runnable() {
// @Override

View File

@ -31,8 +31,11 @@ import com.navinfo.outdoor.base.BaseFragment;
import com.navinfo.outdoor.room.PoiDao;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.PoiSaveUtils;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.util.ArrayList;
import java.util.List;
@ -52,6 +55,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
private TextView tvStayResult;
private List<PoiEntity> roadEntities;
private ArrayList<PoiEntity> newEntities;
private ArrayList<PoiEntity> poiEntities;
public static StaySubmitFragment newInstance(Bundle bundle) {
@ -59,6 +63,16 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
fragment.setArguments(bundle);
return fragment;
}
@Override
public void onStart() {
super.onStart();
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this);
}
}
@Override
protected int getLayout() {
@ -68,6 +82,8 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
@Override
protected void initView() {
super.initView();
roadDatabase = PoiDatabase.getInstance(getContext());
roadDao = roadDatabase.getPoiDao();
ConstraintLayout clStayType = findViewById(R.id.cl_stay_type);
clStayType.setOnClickListener(this::onClick);
stayXrv = (RecyclerView) findViewById(R.id.stay_xrv);
@ -77,6 +93,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
tvDelete.setOnClickListener(this::onClick);
tvStayType = findViewById(R.id.tv_stay_type);
btnStaySubmit = (Button) findViewById(R.id.btn_stay_submit);
btnStaySubmit.setOnClickListener(this::onClick);
stayXrv.setLayoutManager(new LinearLayoutManager(getActivity()));
stayXrv.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
staySubmitAdapter = new StaySubmitAdapter(getContext());
@ -85,15 +102,16 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
staySubmitAdapter.setOnClickItem(new StaySubmitAdapter.onClickItem() {
@Override
public void item(int position, PoiEntity poiEntity) {
// Intent subIntent = new Intent(getActivity(), FragmentManagement.class);
// subIntent.putExtra("poiEntity", poiEntity);
// subIntent.putExtra("tag", 4);
// startActivity(subIntent);
Message subObtain = Message.obtain();
subObtain.what = Constant.EVENT_WORK_HOME;
subObtain.obj = true;
EventBus.getDefault().post(subObtain);
// Message obtain = Message.obtain();
// obtain.what = Constant.EVENT_WHAT_COMPLETE_TASK;
// obtain.obj = poiEntity;
// EventBus.getDefault().post(obtain);
Message obtain = Message.obtain();
obtain.what = Constant.EVENT_WHAT_COMPLETE_TASK;
obtain.obj = poiEntity;
EventBus.getDefault().post(obtain);
}
});
cbSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@ -105,11 +123,19 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
});
refreshData();
}
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.EVENT_STAY_REFRESH) {
if ((boolean)data.obj){
Toast.makeText(getContext(), "成功", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(getContext(), "失败", Toast.LENGTH_SHORT).show();
}
refreshData();
}
}
// @Override
// protected void initData() {
// super.initData();
// }
public List<PoiEntity> initRoadWord(int type) {
@ -132,7 +158,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
public void onClick(View v) {
switch (v.getId()) {
case R.id.cl_stay_type://1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
BottomMenu.show((AppCompatActivity) getContext(), new String[]{"全部", "poi", "充电站", "poi录像", "道路录像", "其他", "面状任务"}, new OnMenuItemClickListener() {
BottomMenu.show((AppCompatActivity) getContext(), new String[]{"全部", "poi", "充电站", "poi录像", "道路录像", "其他"}, new OnMenuItemClickListener() {
@Override
public void onClick(String text, int index) {
switch (index) {
@ -160,10 +186,6 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
List<PoiEntity> otherEntities = initRoadWord(5);
staySubmitAdapter.setAllRoad(otherEntities);
break;
case 6:
List<PoiEntity> facetEntities = initRoadWord(6);
staySubmitAdapter.setAllRoad(facetEntities);
break;
}
tvStayType.setText(text);
}
@ -179,19 +201,37 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
return false;
}
});
break;
case R.id.btn_stay_submit://提交
if (poiEntities==null){
poiEntities = new ArrayList<>();
}
poiEntities.clear();
List<PoiEntity> allRoad = staySubmitAdapter.getAllRoad();
for (int i = 0; i < allRoad.size(); i++) {
if (allRoad.get(i).isChecked()){
poiEntities.add(allRoad.get(i));
}
}
if (poiEntities.size()>0){
PoiSaveUtils.getInstance(getActivity()).uploadPoiEntityBatch(poiEntities);
}else {
Toast.makeText(getContext(), "请选择要删除的条目数据", Toast.LENGTH_SHORT).show();
}
break;
}
}
public void refreshData() {
roadDatabase = PoiDatabase.getInstance(getContext());
roadDao = roadDatabase.getPoiDao();
if (roadEntities == null) {
roadEntities = new ArrayList<>();
}
if (newEntities == null) {
newEntities = new ArrayList<>();
}
new Thread(new Runnable() {
@Override
public void run() {
@ -199,9 +239,13 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d("TAG", "run: " + roadEntities.toString());
roadEntities.clear();
roadEntities.addAll(roadAll);
for (int i = 0; i < roadAll.size(); i++) {
if (roadAll.get(i).getType()!=6){
roadEntities.add(roadAll.get(i));
}
}
Log.d("TAG", "run: " + roadEntities.toString());
staySubmitAdapter.setAllRoad(roadEntities);
}
});
@ -209,5 +253,10 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
}).start();
}
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
}
}

View File

@ -116,6 +116,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
*/
private BitmapDescriptor bitmapDescriptor1, bitmapDescriptor2, bitmapDescriptor3, bitmapDescriptor4, bitmapDescriptor5;
private Marker bigMarker;
public static TreasureFragment newInstance(Bundle bundle) {
TreasureFragment fragment = new TreasureFragment();
@ -473,6 +474,20 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
public void initMarker(PoiEntity poiEntity) {
sliding_layout.setPanelHeight(0);
sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
LatLng latLng = new LatLng();
latLng.setLongitude(Double.parseDouble( poiEntity.getX()));
latLng.setLatitude(Double.parseDouble(poiEntity.getY()));
if (bigMarker==null){
BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_bag);
bigMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f)
.flat(true)
.clockwise(false));
}else {
bigMarker.setPosition(latLng);
}
bigMarker.setVisible(true);
bigMarker.setClickable(false);
bigMarker.setZIndex(4);
frameLayout.setVisibility(View.VISIBLE);
setMainButtonVisiable(View.GONE);
fragmentTransaction = supportFragmentManager.beginTransaction();
@ -827,6 +842,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
}
frameLayout.setVisibility(View.GONE);
fragmentTransaction.remove(gatherGetFragment);
fragmentTransaction.commit();
} else if (data.what == Constant.FILTER_LIST) { // 筛选列表所有数据地图显示
List<PoiEntity> poiEntities = (List<PoiEntity>) data.obj;
initFilterMarker(poiEntities);
@ -881,7 +897,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
setMainButtonVisiable(View.VISIBLE);
frameLayout.setVisibility(View.GONE);
fragmentTransaction.remove(gatherGetFragment);
bigMarker.setVisible(false);
}
} else if (data.what == Constant.CHARGING_STATION) {//充电站的充电桩-新增
Bundle bundle = new Bundle();
@ -925,40 +941,41 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
int type = data.arg1;
showPoiMarkerByType(type, latLng);
}
// else if (data.what == Constant.EVENT_WHAT_COMPLETE_TASK){
// // 如果当前fragment是筛选则移除该fragment
// FilterFragment filterFragment = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName());
// if (filterFragment != null) {
// fragmentTransaction.remove(filterFragment);
// //fragmentTransaction.commit();
// }
// PoiEntity poiEntity = (PoiEntity) data.obj;
// Bundle bundle = new Bundle();
// bundle.putSerializable("poiEntity", poiEntity);
// switch (poiEntity.getType()) {
// case 1:
// PoiFragment poiFragment = PoiFragment.newInstance(bundle);
// showSlidingFragment(poiFragment);
// break;
// case 2:
// ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
// showSlidingFragment(chargingStationFragment);
// break;
// case 3:
// PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
// showSlidingFragment(poiVideoFragment);
// break;
// case 4:
// RoadFragment roadFragment = RoadFragment.newInstance(bundle);
// showSlidingFragment(roadFragment);
// break;
// case 5:
// OtherFragment otherFragment = OtherFragment.newInstance(bundle);
// showSlidingFragment(otherFragment);
// break;
// }
// frameLayout.setVisibility(View.VISIBLE);
// }
else if (data.what == Constant.EVENT_WHAT_COMPLETE_TASK){
// 如果当前fragment是筛选则移除该fragment
FilterFragment filterFragment = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName());
if (filterFragment != null) {
fragmentTransaction.remove(filterFragment);
//fragmentTransaction.commit();
}
PoiEntity poiEntity = (PoiEntity) data.obj;
Bundle bundle = new Bundle();
bundle.putBoolean("isSliding", true); // 通知抽屉不收回
bundle.putSerializable("poiEntity", poiEntity);
switch (poiEntity.getType()) {
case 1:
PoiFragment poiFragment = PoiFragment.newInstance(bundle);
showSlidingFragment(poiFragment);
break;
case 2:
ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
showSlidingFragment(chargingStationFragment);
break;
case 3:
PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
showSlidingFragment(poiVideoFragment);
break;
case 4:
RoadFragment roadFragment = RoadFragment.newInstance(bundle);
showSlidingFragment(roadFragment);
break;
case 5:
OtherFragment otherFragment = OtherFragment.newInstance(bundle);
showSlidingFragment(otherFragment);
break;
}
frameLayout.setVisibility(View.GONE);
}
}
@ -1110,8 +1127,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
if (markerPoi != null) {
markerPoi.remove();
}
if (markerPoi != null) {
markerPoi.remove();
if (bigMarker != null) {
bigMarker.remove();
}
EventBus.getDefault().unregister(this);
}

View File

@ -8,6 +8,7 @@ import androidx.room.TypeConverters;
import com.navinfo.outdoor.bean.Info;
import com.navinfo.outdoor.util.PhotoInfoConverter;
import java.io.File;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
@ -31,7 +32,6 @@ public class PoiEntity implements Serializable {
private String memo;//备注
private String precision;//金额
private String photo;//照片信息
private String extend;//添加字段
private boolean checked;
private String geoWkt; // 数据的wkt
//ROOM不支持直接存储集合
@ -73,13 +73,6 @@ public class PoiEntity implements Serializable {
this.checked = checked;
}
public String getExtend() {
return extend;
}
public void setExtend(String extend) {
this.extend = extend;
}
public int getBodyId() {
return bodyId;

View File

@ -2,19 +2,23 @@ package com.navinfo.outdoor.util;
import android.app.Activity;
import android.content.Context;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.github.lazylibrary.util.ZipUtil;
import com.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response;
import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.bean.ChargingPileSaveBean;
import com.navinfo.outdoor.bean.Info;
import com.navinfo.outdoor.bean.OtherUploadPicBean;
import com.navinfo.outdoor.bean.PoiSaveBean;
import com.navinfo.outdoor.bean.PoiUploadBean;
import com.navinfo.outdoor.fragment.ChargingStationFragment;
import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.DialogCallback;
@ -25,19 +29,24 @@ import com.navinfo.outdoor.room.InsertAndUpdateUtils;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity;
import org.greenrobot.eventbus.EventBus;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import okhttp3.Response;
/**
* Poi数据保存公共类
* */
*/
public class PoiSaveUtils {
private Activity mContext;
private Gson gson;
private static PoiSaveUtils instance;
private boolean isBoolean;
public static PoiSaveUtils getInstance(Activity mContext) {
if (instance == null) {
@ -53,28 +62,45 @@ public class PoiSaveUtils {
/**
* 批量上传数据到服务端
* */
*/
public void uploadPoiEntityBatch(List<PoiEntity> poiEntityList) {
if (poiEntityList==null||poiEntityList.isEmpty()) {
if (poiEntityList == null || poiEntityList.isEmpty()) {
return;
}
new Thread(new Runnable() {
@Override
public void run() {
for (PoiEntity poiEntity: poiEntityList) {
for (PoiEntity poiEntity : poiEntityList) {
if (poiEntity.getType() == 2) { // 如果是充电站数据首先检查子充电桩的状态
if (saveChargingPileByChargingStation(poiEntity)) {
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
// 开始上传流程
if (saveChargingPileUploadChargingStation(poiEntity)){
uploadPoiNet(poiEntity);
}
}
}
} else {
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
} else if (poiEntity.getType() == 6) {//面状任务
} else {//其他类型
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
//走上传流程
uploadPoiNet(poiEntity);
}
}
}
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
Message obtain = Message.obtain();
obtain.what = Constant.EVENT_STAY_REFRESH;
obtain.obj = isBoolean;
EventBus.getDefault().post(obtain);
}
});
}
}).start();
}
@ -104,27 +130,62 @@ public class PoiSaveUtils {
/**
* 保存数据到服务
* */
*/
public int savePoiNet(PoiEntity poiEntity) {
if (poiEntity.getTaskStatus() >= 3) {
return 200;
}
String url = null;
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("existence", poiEntity.getExistence());
httpParams.put("geo", poiEntity.getGeoWkt());
httpParams.put("memo", poiEntity.getMemo());
//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
if (poiEntity.getType() == 1) {
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("existence", poiEntity.getExistence());
httpParams.put("geo", poiEntity.getGeoWkt());
httpParams.put("memo", poiEntity.getMemo());
url = HttpInterface.SUBMIT_POI_TASK;
} else if (poiEntity.getType() == 2) {
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("sptype", poiEntity.getStation_type());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("telephone", poiEntity.getTelPhone());
httpParams.put("memo", poiEntity.getMemo());
httpParams.put("geo", poiEntity.getGeoWkt());
url = HttpInterface.SUBMIT_CTASK;
} else if (poiEntity.getType() == 3) {
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", poiEntity.getWork_type());
httpParams.put("memo", poiEntity.getMemo());
url = HttpInterface.INSIDE_API_LIST;
} else if (poiEntity.getType() == 4) {
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", poiEntity.getWork_type());
httpParams.put("memo", poiEntity.getMemo());
url = HttpInterface.ROAD_TASK_SUBMIT;
} else if (poiEntity.getType() == 5) {
httpParams.put("type", poiEntity.getStation_type());
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("existence", poiEntity.getExistence());
httpParams.put("geo", poiEntity.getGeoWkt());
httpParams.put("memo", poiEntity.getMemo());
url = HttpInterface.SUBMIT_OTHER_TASK;
} else {
return -1;
}
try {
okhttp3.Response execute = OkGo.<String>get(HttpInterface.SUBMIT_POI_TASK)
okhttp3.Response execute = OkGo.<String>get(url)
.tag(PoiSaveUtils.this)
.params(httpParams)
.execute();
if (execute.code()!=200) {
if (execute.code() != 200) {
return execute.code();
}
String bodyStr = execute.body().string();
@ -134,10 +195,12 @@ public class PoiSaveUtils {
PoiSaveBean poiSaveBean = gson.fromJson(bodyStr, PoiSaveBean.class);
if (poiSaveBean.getCode() == 200) {
poiEntity.setTaskStatus(3);
poiEntity.setBodyId(poiSaveBean.getBody());
} else {
return poiSaveBean.getCode();
}
InsertAndUpdateUtils.getInstance().insertOrUpdate(mContext, poiEntity);
Log.d("TAGss", "savePoiNet: 保存成功");
} catch (IOException e) {
e.printStackTrace();
}
@ -168,20 +231,78 @@ public class PoiSaveUtils {
/**
* 最终上传POI数据到服务
* */
public void uploadPoiNet(PoiEntity poiEntity, ArrayList<File> poiPicList) {
*/
public void uploadPoiNet(PoiEntity poiEntity) {
if (poiEntity == null) {
Toast.makeText(mContext, "无法获取POI数据", Toast.LENGTH_SHORT).show();
Log.e("TAG", "poiUploadByNetWork: " + poiEntity.toString());
return;
}
int bodyId =poiEntity.getBodyId();
int bodyId = poiEntity.getBodyId();
if (bodyId == 0) {
Toast.makeText(mContext, "该数据未保存到服务,无法上传", Toast.LENGTH_SHORT).show();
Log.e("TAG", "poiUploadByNetWork: " + bodyId + poiPicList);
return;
}
OkGo
ArrayList<File> photoFile = new ArrayList<>();
photoFile.clear();
if (poiEntity.getPhotoInfo()!=null) {
if (poiEntity.getPhotoInfo().size()>0){
for (int i = 0; i < poiEntity.getPhotoInfo().size(); i++) {
String photo = poiEntity.getPhotoInfo().get(i).getPhoto();
photoFile.add(new File(photo));
}
}
}
if (poiEntity.getPhoto() != null && !poiEntity.getPhoto().equals("")) {
ArrayList<File> videoFileList = new ArrayList<>();
videoFileList.add(new File(poiEntity.getPhoto()));
File file = new File(poiEntity.getPhoto() + ".txt");
videoFileList.add(file);
File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
ZipUtil.zipFiles(videoFileList, fileZip, null);
photoFile.add(fileZip);
}
String url = null;
//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
if (poiEntity.getType() == 1) {
url = HttpInterface.POI_TASK_UPLOAD_PIC;
} else if (poiEntity.getType() == 2) {
url = HttpInterface.C_TASK_UP_LOAD_PIC;
} else if (poiEntity.getType() == 3) {
url = HttpInterface.POI_VIDEO_UPLOAD_PIC;
} else if (poiEntity.getType() == 4) {
url = HttpInterface.ROAD_TASK_UPLOAD_PIC;
} else if (poiEntity.getType() == 5) {
url = HttpInterface.OTHER_TASK_UPLOAD_PIC;
}
try {
Response execute = OkGo.post(url)
.params("auditId", bodyId)
.addFileParams("file", photoFile)
.tag(PoiSaveUtils.this)
.execute();
if (execute.code() != 200) {
return;
}
String bodyStr = execute.body().string();
if (bodyStr == null) {
return;
}
Gson gson = new Gson();
OtherUploadPicBean otherUploadPicBean = gson.fromJson(bodyStr, OtherUploadPicBean.class);
if (otherUploadPicBean.getCode() == 200) {
PoiDatabase.getInstance(mContext).getPoiDao().deletePoiEntity(poiEntity);
Log.d("TAGss", "uploadPoiNet: 成功");
isBoolean=true;
} else {
Log.d("TAGss", "uploadPoiNet: 失败");
isBoolean=false;
return;
}
} catch (IOException e) {
e.printStackTrace();
}
/* OkGo
// 请求方式和请求url
.<OtherUploadPicBean>post(HttpInterface.POI_TASK_UPLOAD_PIC)
// 请求的 tag, 主要用于取消对应的请求
@ -192,7 +313,7 @@ public class PoiSaveUtils {
@Override
public void onSuccess(Response<OtherUploadPicBean> otherUploadPicBeanResponse) {
Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show();
PoiDatabase.getInstance(mContext).getPoiDao().deletePoiEntity(poiEntity);
PoiDatabase.getInstance(mContext).getPoiDao().deletePoiEntity(poiEntity);
}
@Override
@ -201,36 +322,37 @@ public class PoiSaveUtils {
Toast.makeText(mContext, response.message() + "", Toast.LENGTH_SHORT).show();
Log.d("TAG", "onError: " + response.message() + "");
}
});
});*/
}
/**
* 根据充电站数据检查充电桩数据如果没有网络保存则批量网络保存
* */
*/
private boolean saveChargingPileByChargingStation(PoiEntity chargingStationPoiEntity) {
boolean result = true;
if (chargingStationPoiEntity != null) {
List<ChargingPileEntity> chargingPileEntityList = PoiDatabase.getInstance(mContext).getChargingPileDao().getChargingPileByStationId(chargingStationPoiEntity.getId());
if (chargingPileEntityList!=null&&!chargingPileEntityList.isEmpty()) {
if (chargingPileEntityList != null && !chargingPileEntityList.isEmpty()) {
// 依次上传充电桩数据如果有一条数据未上传成功则返回false
for (ChargingPileEntity pileEntity: chargingPileEntityList) {
if (pileEntity.getBodyId()==0) {
for (ChargingPileEntity pileEntity : chargingPileEntityList) {
if (pileEntity.getBodyId() == 0) {
int saveResult = saveChargingPile2NetWork(pileEntity);
if (saveResult == 200){
result = result&true;
if (saveResult == 200) {
result = result & true;
} else {
result = result&false;
result = result & false;
}
}
}
}
}
Log.d("TAGss", "saveChargingPileByChargingStation"+result);
return result;
}
/**
* 上传充电桩数据到服务端
* */
* 保存充电桩数据到服务端
*/
private int saveChargingPile2NetWork(ChargingPileEntity chargingPileEntity) {
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", chargingPileEntity.getTaskId());
@ -240,29 +362,30 @@ public class PoiSaveUtils {
httpParams.put("memo", chargingPileEntity.getMemo());
httpParams.put("ffid", chargingPileEntity.getFid());
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("cp_openType",chargingPileEntity.getCp_openType());
hashMap.put("cp_floor",chargingPileEntity.getCp_floor());
hashMap.put("cp_availableState",chargingPileEntity.getCp_availableState());
hashMap.put("sign_exist",chargingPileEntity.getSign_exist());
hashMap.put("cp_openType", chargingPileEntity.getCp_openType());
hashMap.put("cp_floor", chargingPileEntity.getCp_floor());
hashMap.put("cp_availableState", chargingPileEntity.getCp_availableState());
hashMap.put("sign_exist", chargingPileEntity.getSign_exist());
httpParams.put("detail", String.valueOf(hashMap));
try {
okhttp3.Response execute = OkGo.<String>get(HttpInterface.SUBMIT_CSTASK)
.params(httpParams)
.tag(PoiSaveUtils.this)
.execute();
if (execute.code()!=200) {
if (execute.code() != 200) {
return execute.code();
}
String responseBodyStr = execute.body().string();
if (responseBodyStr == null) {
return -1;
}
if (responseBodyStr!=null) {
if (responseBodyStr != null) {
Gson gson = new Gson();
ChargingPileSaveBean chargingPileSaveBean = gson.fromJson(responseBodyStr, ChargingPileSaveBean.class);
if (chargingPileSaveBean.getCode() != 200) {
return chargingPileSaveBean.getCode();
}
Log.d("TAGss", "saveChargingPile2NetWork"+200);
chargingPileEntity.setBodyId(chargingPileSaveBean.getBody());
InsertAndUpdateUtils.getInstance().insertOrUpdateChargingPile(mContext, chargingPileEntity); // 更新当前充电桩的bodyId
}
@ -271,4 +394,107 @@ public class PoiSaveUtils {
}
return 200;
}
/**
* 根据充电站数据检查充电桩数据如果没有网络上传则批量网络上传
*/
private boolean saveChargingPileUploadChargingStation(PoiEntity chargingStationPoiEntity) {
boolean result = true;
if (chargingStationPoiEntity != null) {
// 首先批量上传充电桩数据
List<ChargingPileEntity> chargingPileEntityList = PoiDatabase.getInstance(mContext).getChargingPileDao().getChargingPileByStationId(chargingStationPoiEntity.getId());
if (chargingPileEntityList!=null&&!chargingPileEntityList.isEmpty()) {
for (ChargingPileEntity chargingPileEntity: chargingPileEntityList) {
if (chargingPileEntity.getBodyId()!=0) {
int pileResult = chargingPileUploadNetWork(chargingPileEntity);
if (pileResult == 200) {
result = result & true;
} else {
result = result & false;
}
}
}
}
}
Log.d("TAGss", "saveChargingPileUploadChargingStation"+result);
return result;
}
/**
* 上传充电桩数据到服务器
* */
private int chargingPileUploadNetWork(ChargingPileEntity chargingPileEntity) {
if (chargingPileEntity==null|| chargingPileEntity.getBodyId() == 0) {
Toast.makeText(mContext, "没有保存本地", Toast.LENGTH_SHORT).show();
return -1;
}
List<File> chargingPileFileList = new ArrayList<>();
if (chargingPileEntity.getPhotos()!=null&&!chargingPileEntity.getPhotos().isEmpty()) {
for (String photoPath: chargingPileEntity.getPhotos()) {
chargingPileFileList.add(new File(photoPath));
}
}
try {
okhttp3.Response execute = OkGo
// 请求方式和请求url
.<PoiUploadBean>post(HttpInterface.CS_TASK_UP_LOAD_PIC)
// 请求的 tag, 主要用于取消对应的请求
.params("auditId", chargingPileEntity.getBodyId())
.addFileParams("file", chargingPileFileList)
.tag(this)
.execute();
if (execute.code() != 200) {
return execute.code();
}
String pileUpLoadResultStr = execute.body().string();
if (pileUpLoadResultStr == null) {
return -1;
}
if (pileUpLoadResultStr != null) {
Gson gson = new Gson();
PoiUploadBean uploadBeanResult = gson.fromJson(pileUpLoadResultStr, PoiUploadBean.class);
if (uploadBeanResult.getCode() == 200) {
Log.d("TAGss", "chargingPileUploadNetWork"+200);
PoiDatabase.getInstance(mContext).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return 200;
// OkGo
// // 请求方式和请求url
// .<PoiUploadBean>post(HttpInterface.CS_TASK_UP_LOAD_PIC)
// // 请求的 tag, 主要用于取消对应的请求
// .params("auditId", chargingPileEntity.getBodyId())
// .addFileParams("file", chargingPileFileList)
// .tag(this)
// .execute(new DialogCallback<PoiUploadBean>(PoiUploadBean.class) {
// @Override
// public void onSuccess(Response<PoiUploadBean> poiUploadBeanResponse) {
// dismissLoadingDialog();
// Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show();
// isChargingPoleUploaded = true;
// if (isChargeStationUploaded && isChargingPoleUploaded) {
// getActivity().runOnUiThread(new Runnable() {
// @Override
// public void run() {
// getActivity().onBackPressed();//回退
// }
// });
// }
// }
//
// @Override
// public void onError(Response<PoiUploadBean> poiUploadBeanResponse) {
// super.onError(poiUploadBeanResponse);
// dismissLoadingDialog();
// Toast.makeText(getActivity(), poiUploadBeanResponse.code() + "", Toast.LENGTH_SHORT).show();
// Log.d("TAG", "onError: " + poiUploadBeanResponse.code() + "");
// }
// });
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/article_select" android:state_selected="true" />
<item android:drawable="@mipmap/article_select" android:state_pressed="true" />
<item android:drawable="@mipmap/article_select" android:state_checked="true" />
<item android:drawable="@mipmap/article" />
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/map_select" android:state_selected="true" />
<item android:drawable="@mipmap/map_select" android:state_pressed="true" />
<item android:drawable="@mipmap/map_select" android:state_checked="true" />
<item android:drawable="@mipmap/map" />
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/mine_select" android:state_selected="true" />
<item android:drawable="@mipmap/mine_select" android:state_checked="true" />
<item android:drawable="@mipmap/mine_select" android:state_pressed="true" />
<item android:drawable="@mipmap/mine" />
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/task_select" android:state_selected="true" />
<item android:drawable="@mipmap/task_select" android:state_checked="true" />
<item android:drawable="@mipmap/task_select" android:state_pressed="true" />
<item android:drawable="@mipmap/task"/>
</selector>