修改‘其他页面’的保存本地和上传
This commit is contained in:
parent
e3201d6e1f
commit
c37471f55c
@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
|
|||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion 29
|
||||||
buildToolsVersion '29.0.2'
|
buildToolsVersion '29.0.2'
|
||||||
//ndkVersion '23.0.7123448'
|
ndkVersion '23.0.7123448'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.navinfo.outdoor"
|
applicationId "com.navinfo.outdoor"
|
||||||
|
@ -184,12 +184,12 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
|||||||
checkPot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
checkPot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (isChecked){
|
if (isChecked) {
|
||||||
Message obtain = Message.obtain();
|
Message obtain = Message.obtain();
|
||||||
obtain.what = Constant.MAIN_OTHER;
|
obtain.what = Constant.MAIN_OTHER;
|
||||||
obtain.obj = latLng;
|
obtain.obj = latLng;
|
||||||
EventBus.getDefault().post(obtain);
|
EventBus.getDefault().post(obtain);
|
||||||
}else {
|
} else {
|
||||||
Message obtain = Message.obtain();
|
Message obtain = Message.obtain();
|
||||||
obtain.what = Constant.MAIN_CHECKED_OTHER;
|
obtain.what = Constant.MAIN_CHECKED_OTHER;
|
||||||
obtain.obj = true;
|
obtain.obj = true;
|
||||||
@ -269,6 +269,8 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
|||||||
editOtherDescribe.setText(describe);
|
editOtherDescribe.setText(describe);
|
||||||
}
|
}
|
||||||
linearExist.setVisibility(View.VISIBLE);
|
linearExist.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
body = showPoiEntity.getBodyId();
|
||||||
int station_type = showPoiEntity.getStation_type();
|
int station_type = showPoiEntity.getStation_type();
|
||||||
spinnerOther.setSelection(station_type, true);
|
spinnerOther.setSelection(station_type, true);
|
||||||
if (showPoiEntity.getPhotoInfo() != null) {
|
if (showPoiEntity.getPhotoInfo() != null) {
|
||||||
@ -323,7 +325,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
|||||||
Toast.makeText(getActivity(), "请确定点位", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), "请确定点位", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
String encode = Geohash.getInstance().encode(latLng.latitude,latLng.longitude);
|
String encode = Geohash.getInstance().encode(latLng.latitude, latLng.longitude);
|
||||||
poiEntity.setGeoWkt(encode);
|
poiEntity.setGeoWkt(encode);
|
||||||
poiEntity.setX(String.valueOf(latLng.longitude));
|
poiEntity.setX(String.valueOf(latLng.longitude));
|
||||||
poiEntity.setY(String.valueOf(latLng.latitude));
|
poiEntity.setY(String.valueOf(latLng.latitude));
|
||||||
@ -362,12 +364,21 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
|||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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();
|
}).start();
|
||||||
otherSaveByNetWork(poiEntity);
|
|
||||||
// onBackPressed();
|
// onBackPressed();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getActivity(), "没有申请权限,请手动申请", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), "没有申请权限,请手动申请", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -394,18 +405,29 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
|||||||
if (tagPictures != null) {
|
if (tagPictures != null) {
|
||||||
otherUploadList.add(new File(tagPictures));
|
otherUploadList.add(new File(tagPictures));
|
||||||
}
|
}
|
||||||
if (body!=0){
|
new Thread(new Runnable() {
|
||||||
otherUploadByNet(body,otherUploadList);
|
@Override
|
||||||
}else {
|
public void run() {
|
||||||
Toast.makeText(getActivity(), "请保存本地", Toast.LENGTH_SHORT).show();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void otherUploadByNet(int body, List<File> otherUploadList) {
|
private void otherUploadByNet(int body, List<File> otherUploadList) {
|
||||||
if (body == 0 ){
|
if (body == 0) {
|
||||||
Toast.makeText(getActivity(), "没有保存不能上传", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), "没有保存不能上传", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -429,7 +451,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
|||||||
public void onError(Response<OtherUploadPicBean> response) {
|
public void onError(Response<OtherUploadPicBean> response) {
|
||||||
super.onError(response);
|
super.onError(response);
|
||||||
dismissLoadingDialog();
|
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());
|
Log.d("TAG", "onError: " + response.code());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -458,7 +480,15 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
|||||||
dismissLoadingDialog();
|
dismissLoadingDialog();
|
||||||
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
|
||||||
body = poiSaveBean.getBody();
|
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
|
@Override
|
||||||
@ -482,7 +512,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
|||||||
//获取Editor对象
|
//获取Editor对象
|
||||||
SharedPreferences.Editor edit = poi.edit();
|
SharedPreferences.Editor edit = poi.edit();
|
||||||
//根据要保存的数据的类型,调用对应的put方法,
|
//根据要保存的数据的类型,调用对应的put方法,
|
||||||
PoiEntity poiEntity =showPoiEntity;
|
PoiEntity poiEntity = showPoiEntity;
|
||||||
ArrayList<Info> arrayList = new ArrayList<>();
|
ArrayList<Info> arrayList = new ArrayList<>();
|
||||||
String name = editTaskName.getText().toString().trim();//名称
|
String name = editTaskName.getText().toString().trim();//名称
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
|
@ -31,6 +31,15 @@ public class PoiEntity implements Serializable {
|
|||||||
private String extend;//添加字段
|
private String extend;//添加字段
|
||||||
private boolean checked;
|
private boolean checked;
|
||||||
private String geoWkt; // 数据的wkt
|
private String geoWkt; // 数据的wkt
|
||||||
|
private int bodyId;//保存本地的bodyId
|
||||||
|
|
||||||
|
public int getBodyId() {
|
||||||
|
return bodyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyId(int bodyId) {
|
||||||
|
this.bodyId = bodyId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getGeoWkt() {
|
public String getGeoWkt() {
|
||||||
return geoWkt;
|
return geoWkt;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user