修改‘其他页面’的保存本地和上传
This commit is contained in:
parent
e3201d6e1f
commit
c37471f55c
@ -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"
|
||||
|
@ -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<File> 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<OtherUploadPicBean> 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<Info> arrayList = new ArrayList<>();
|
||||
String name = editTaskName.getText().toString().trim();//名称
|
||||
if (name != null && !name.equals("")) {
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user