From c37471f55c89aead9be10e29c2138a953a18033f Mon Sep 17 00:00:00 2001 From: md Date: Mon, 12 Jul 2021 14:04:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E2=80=98=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E2=80=99=E7=9A=84=E4=BF=9D=E5=AD=98=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=92=8C=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../outdoor/fragment/OtherFragment.java | 64 ++++++++++++++----- .../com/navinfo/outdoor/room/PoiEntity.java | 9 +++ 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index da1dba2..6d77245 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion '29.0.2' - //ndkVersion '23.0.7123448' + ndkVersion '23.0.7123448' defaultConfig { applicationId "com.navinfo.outdoor" diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java index 4473693..d67233c 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java @@ -184,12 +184,12 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis checkPot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (isChecked){ + if (isChecked) { Message obtain = Message.obtain(); obtain.what = Constant.MAIN_OTHER; obtain.obj = latLng; EventBus.getDefault().post(obtain); - }else { + } else { Message obtain = Message.obtain(); obtain.what = Constant.MAIN_CHECKED_OTHER; obtain.obj = true; @@ -269,6 +269,8 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis editOtherDescribe.setText(describe); } linearExist.setVisibility(View.VISIBLE); + + body = showPoiEntity.getBodyId(); int station_type = showPoiEntity.getStation_type(); spinnerOther.setSelection(station_type, true); if (showPoiEntity.getPhotoInfo() != null) { @@ -323,7 +325,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis Toast.makeText(getActivity(), "请确定点位", Toast.LENGTH_SHORT).show(); return; } else { - String encode = Geohash.getInstance().encode(latLng.latitude,latLng.longitude); + String encode = Geohash.getInstance().encode(latLng.latitude, latLng.longitude); poiEntity.setGeoWkt(encode); poiEntity.setX(String.valueOf(latLng.longitude)); poiEntity.setY(String.valueOf(latLng.latitude)); @@ -362,12 +364,21 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis new Thread(new Runnable() { @Override public void run() { - poiDao.insertPoiEntity(poiEntity); - + if (poiEntity.getTaskId() == 0) { + poiDao.insertPoiEntity(poiEntity); + } else { + poiDao.updatePoiEntity(poiEntity); + } + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + otherSaveByNetWork(poiEntity); + } + }); } }).start(); - otherSaveByNetWork(poiEntity); - // onBackPressed(); + + // onBackPressed(); } else { Toast.makeText(getActivity(), "没有申请权限,请手动申请", Toast.LENGTH_SHORT).show(); } @@ -394,18 +405,29 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis if (tagPictures != null) { otherUploadList.add(new File(tagPictures)); } - if (body!=0){ - otherUploadByNet(body,otherUploadList); - }else { - Toast.makeText(getActivity(), "请保存本地", Toast.LENGTH_SHORT).show(); - } - + new Thread(new Runnable() { + @Override + public void run() { + PoiEntity poiEntity = poiDao.getPoiEntity(showPoiEntity.getTaskId()); + int taskStatus = poiEntity.getTaskStatus(); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (taskStatus == 2) {//保存本地未提交 + Toast.makeText(getActivity(), "请保存本地", Toast.LENGTH_SHORT).show(); + } else if (taskStatus == 3) {//保存本地已提交 + otherUploadByNet(body, otherUploadList); + } + } + }); + } + }).start(); break; } } private void otherUploadByNet(int body, List otherUploadList) { - if (body == 0 ){ + if (body == 0) { Toast.makeText(getActivity(), "没有保存不能上传", Toast.LENGTH_SHORT).show(); return; } @@ -429,7 +451,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis public void onError(Response response) { super.onError(response); dismissLoadingDialog(); - Toast.makeText(getActivity(), response.code()+"", Toast.LENGTH_SHORT).show(); + Toast.makeText(getActivity(), response.code() + "", Toast.LENGTH_SHORT).show(); Log.d("TAG", "onError: " + response.code()); } }); @@ -458,7 +480,15 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis dismissLoadingDialog(); Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show(); body = poiSaveBean.getBody(); - Log.d("TAG", " 其他其他其他其他"+poiSaveBean.getBody()); + poiEntity.setTaskStatus(3); + poiEntity.setBodyId(body); + new Thread(new Runnable() { + @Override + public void run() { + poiDao.updatePoiEntity(poiEntity); + } + }).start(); + // Log.d("TAG", " 其他其他其他其他" + poiSaveBean.getBody()); } @Override @@ -482,7 +512,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis //获取Editor对象 SharedPreferences.Editor edit = poi.edit(); //根据要保存的数据的类型,调用对应的put方法, - PoiEntity poiEntity =showPoiEntity; + PoiEntity poiEntity = showPoiEntity; ArrayList arrayList = new ArrayList<>(); String name = editTaskName.getText().toString().trim();//名称 if (name != null && !name.equals("")) { diff --git a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java index b5eeb81..a531e23 100644 --- a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java +++ b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java @@ -31,6 +31,15 @@ public class PoiEntity implements Serializable { private String extend;//添加字段 private boolean checked; private String geoWkt; // 数据的wkt + private int bodyId;//保存本地的bodyId + + public int getBodyId() { + return bodyId; + } + + public void setBodyId(int bodyId) { + this.bodyId = bodyId; + } public String getGeoWkt() { return geoWkt;