修改纪录中的以提交的界面刷新

This commit is contained in:
wds
2021-08-15 15:55:59 +08:00
parent 201e381d1f
commit 2420544147
11 changed files with 125 additions and 163 deletions

View File

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

View File

@@ -44,12 +44,13 @@ public abstract class BaseActivity extends AppCompatActivity {
initData(); initData();
initListener(); initListener();
} }
private static void setCustomDensity(Application application, Activity activity) { private static void setCustomDensity(Application application, Activity activity) {
final DisplayMetrics appDisplayMetrics = application.getResources().getDisplayMetrics(); final DisplayMetrics appDisplayMetrics = application.getResources().getDisplayMetrics();
// 以设计DP为360为例获得目标Density // 以设计DP为360为例获得目标Density
final float targetDensity = (float) (appDisplayMetrics.widthPixels / 360.0); final float targetDensity = (float) (appDisplayMetrics.widthPixels / 360.0);
final float targetScaledDensity = targetDensity * (appDisplayMetrics.scaledDensity / appDisplayMetrics.density); final float targetScaledDensity = targetDensity * (appDisplayMetrics.scaledDensity / appDisplayMetrics.density);
final int targetDensityDpi = (int)(targetDensity * 160); final int targetDensityDpi = (int) (targetDensity * 160);
//设置application的Density //设置application的Density
appDisplayMetrics.density = targetDensity; appDisplayMetrics.density = targetDensity;
appDisplayMetrics.scaledDensity = targetScaledDensity; appDisplayMetrics.scaledDensity = targetScaledDensity;
@@ -61,14 +62,14 @@ public abstract class BaseActivity extends AppCompatActivity {
activityDisplayMetrics.densityDpi = targetDensityDpi; activityDisplayMetrics.densityDpi = targetDensityDpi;
} }
protected void toast(String mag){ protected void toast(String mag) {
Toast.makeText(UserApplication.getUserApplication(), mag, Toast.LENGTH_SHORT).show(); Toast.makeText(UserApplication.getUserApplication(), mag, Toast.LENGTH_SHORT).show();
} }
protected void initMVP() { protected void initMVP() {
} }
public void showLoadingDialog() { public void showLoadingDialog() {
if (NetWorkUtils.iConnected(this)) { // 当前网络可用
alertDialog = new AlertDialog.Builder(this).create(); alertDialog = new AlertDialog.Builder(this).create();
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable()); alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable());
alertDialog.setCancelable(false); alertDialog.setCancelable(false);
@@ -83,50 +84,8 @@ public abstract class BaseActivity extends AppCompatActivity {
alertDialog.setView(view); alertDialog.setView(view);
alertDialog.setCanceledOnTouchOutside(false); alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show(); alertDialog.show();
// initTimer();
} else {
Toast.makeText(this, "网络不可用", Toast.LENGTH_SHORT).show();
}
}
public void showFileLoadingDialog() {
if (NetWorkUtils.iConnected(this)) { // 当前网络可用
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable());
alertDialog.setCancelable(false);
alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK)
return true;
return false;
});
//loading样式
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
alertDialog.setView(view);
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show();
} else {
Toast.makeText(this, "网络不可用", Toast.LENGTH_SHORT).show();
}
} }
private void initTimer() {
Timer timer = new Timer(true);
TimerTask timerTask = new TimerTask() {
int countTime = 20;
@Override
public void run() {
if (countTime > 0) {
countTime--;
}
if (countTime == 1) {
dismissLoadingDialog();
}
}
};
timer.schedule(timerTask, 1000, 1000);
}
public void setLoadingDialogText(String s) { public void setLoadingDialogText(String s) {
//给loading 添加文字 //给loading 添加文字
@@ -139,6 +98,7 @@ public abstract class BaseActivity extends AppCompatActivity {
alertDialog.dismiss(); alertDialog.dismiss();
} }
} }
protected void initListener() { protected void initListener() {
} }
@@ -158,8 +118,10 @@ public abstract class BaseActivity extends AppCompatActivity {
super.onDestroy(); super.onDestroy();
Collector.removeActivity(this); Collector.removeActivity(this);
} }
/** /**
* 设置屏幕横竖屏切换 * 设置屏幕横竖屏切换
*
* @param screenRoate true 竖屏 false 横屏 * @param screenRoate true 竖屏 false 横屏
*/ */
private void setScreenRoate(Boolean screenRoate) { private void setScreenRoate(Boolean screenRoate) {

View File

@@ -95,7 +95,7 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
protected abstract int getLayout(); protected abstract int getLayout();
public void showLoadingDialog() { public void showLoadingDialog() {
if (NetWorkUtils.iConnected(getContext())) { // 当前网络可用
alertDialog = new AlertDialog.Builder(getActivity()).create(); alertDialog = new AlertDialog.Builder(getActivity()).create();
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable()); alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable());
alertDialog.setCancelable(false); alertDialog.setCancelable(false);
@@ -111,49 +111,6 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
alertDialog.setCanceledOnTouchOutside(false); alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show(); alertDialog.show();
//initTimer(); //initTimer();
} else {
Toast.makeText(getActivity(), "网络不可用", Toast.LENGTH_SHORT).show();
}
}
public void showFileLoadingDialog() {
if (NetWorkUtils.iConnected(getContext())) { // 当前网络可用
alertDialog = new AlertDialog.Builder(getActivity()).create();
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable());
alertDialog.setCancelable(false);
alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK)
return true;
return false;
});
//loading样式
View view = LayoutInflater.from(getContext()).inflate(R.layout.loading, null);
alertDialog.setView(view);
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show();
} else {
Toast.makeText(getActivity(), "网络不可用", Toast.LENGTH_SHORT).show();
}
}
private void initTimer() {
Timer timer = new Timer(true);
TimerTask timerTask = new TimerTask() {
int countTime = 20;
@Override
public void run() {
if (countTime > 0) {
countTime--;
}
if (countTime == 1) {
dismissLoadingDialog();
}
}
};
timer.schedule(timerTask, 1000, 1000);
} }

View File

@@ -514,11 +514,11 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
} }
String telPhone = showPoiEntity.getTelPhone(); String telPhone = showPoiEntity.getTelPhone();
if (telPhone != null && !telPhone.equals("")) { if (telPhone != null && !telPhone.equals("")&&!telPhone.equals("null")) {
String[] phones = telPhone.split("\\|"); String[] phones = telPhone.split("\\|");
for (int i = 0; i < phones.length; i++) { for (int i = 0; i < phones.length; i++) {
if (i == 0) { if (i == 0) {
if (!StringUtils.isEmpty(phones[i])) if (!StringUtils.isEmpty(phones[i])) { if (!StringUtils.isEmpty(phones[i])) {
if (phones[i].contains("-")) { // 包含区号数据的电话 if (phones[i].contains("-")) { // 包含区号数据的电话
String[] split = phones[i].split("-"); String[] split = phones[i].split("-");
if (split != null && split.length > 1) { if (split != null && split.length > 1) {
@@ -644,7 +644,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
.url(HttpInterface.GET_PHONES) .url(HttpInterface.GET_PHONES)
.params(new HttpParams("geo", encode)) .params(new HttpParams("geo", encode))
.cls(GetPhoneBean.class) .cls(GetPhoneBean.class)
.params(new HttpParams())
.token(Constant.ACCESS_TOKEN) .token(Constant.ACCESS_TOKEN)
.getRequest(new Callback<GetPhoneBean>() { .getRequest(new Callback<GetPhoneBean>() {
@Override @Override
@@ -941,6 +940,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
.params(httpParams) .params(httpParams)
.token(Constant.ACCESS_TOKEN) .token(Constant.ACCESS_TOKEN)
.fileList(chargingPileFileList).postFileSynchronization(); .fileList(chargingPileFileList).postFileSynchronization();
if(execute!=null){
String pileUpLoadResultStr = execute.body().string(); String pileUpLoadResultStr = execute.body().string();
PoiUploadBean uploadBeanResult = new Gson().fromJson(pileUpLoadResultStr, PoiUploadBean.class); PoiUploadBean uploadBeanResult = new Gson().fromJson(pileUpLoadResultStr, PoiUploadBean.class);
if (uploadBeanResult != null) { if (uploadBeanResult != null) {
@@ -948,6 +948,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
PoiDatabase.getInstance(getActivity()).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity); PoiDatabase.getInstance(getActivity()).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
} }
} }
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -1454,6 +1455,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
Response execute = OkGoBuilder.getInstance().url(HttpInterface.SUBMIT_CSTASK) Response execute = OkGoBuilder.getInstance().url(HttpInterface.SUBMIT_CSTASK)
.token(Constant.ACCESS_TOKEN) .token(Constant.ACCESS_TOKEN)
.params(httpParams).getSynchronization(); .params(httpParams).getSynchronization();
if(execute!=null){
String responseBodyStr = execute.body().string(); String responseBodyStr = execute.body().string();
if (responseBodyStr != null) { if (responseBodyStr != null) {
Gson gson = new Gson(); Gson gson = new Gson();
@@ -1464,6 +1466,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
chargingPileEntity.setBodyId(chargingPileSaveBean.getBody()); chargingPileEntity.setBodyId(chargingPileSaveBean.getBody());
InsertAndUpdateUtils.getInstance().insertOrUpdateChargingPile(getActivity(), chargingPileEntity); // 更新当前充电桩的bodyId InsertAndUpdateUtils.getInstance().insertOrUpdateChargingPile(getActivity(), chargingPileEntity); // 更新当前充电桩的bodyId
} }
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -326,7 +326,11 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
chargingStationEntity.setCreateTime(stationBean.getEndDate()); chargingStationEntity.setCreateTime(stationBean.getEndDate());
chargingStationEntity.setPrecision(stationBean.getPrice() + ""); chargingStationEntity.setPrecision(stationBean.getPrice() + "");
chargingStationEntity.setAddress(stationBean.getAddress()); chargingStationEntity.setAddress(stationBean.getAddress());
chargingStationEntity.setTelPhone(stationBean.getTelephone() + ""); if(stationBean.getTelephone()==null||stationBean.getTelephone().equals("")||stationBean.getTelephone().equals("null")){
chargingStationEntity.setTelPhone(null);
}else {
chargingStationEntity.setTelPhone(stationBean.getTelephone());
}
chargingStationEntity.setType(Integer.valueOf(stationBean.getType())); chargingStationEntity.setType(Integer.valueOf(stationBean.getType()));
chargingStationEntity.setTaskStatus(statusId); chargingStationEntity.setTaskStatus(statusId);
chargingStationEntity.setIsLocalData(1); chargingStationEntity.setIsLocalData(1);

View File

@@ -93,12 +93,15 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
poiVideoAuditProcess = (TextView) findViewById(R.id.poiVideo_audit_process); poiVideoAuditProcess = (TextView) findViewById(R.id.poiVideo_audit_process);
poiVideoAuditThrough = (TextView) findViewById(R.id.poiVideo_audit_through); poiVideoAuditThrough = (TextView) findViewById(R.id.poiVideo_audit_through);
poiVideoAuditProcessauditNotThrough = (TextView) findViewById(R.id.poiVideo_audit_processaudit_not_through); poiVideoAuditProcessauditNotThrough = (TextView) findViewById(R.id.poiVideo_audit_processaudit_not_through);
initRequest();
}
public void initRequest() {
initPoiSubMitWork();//poi initPoiSubMitWork();//poi
initPoiVideoSubMitWork();//poi录像 initPoiVideoSubMitWork();//poi录像
initRoadSubMitWork();//道路录像 initRoadSubMitWork();//道路录像
initChaningSubMitWork();//充电站录像 initChaningSubMitWork();//充电站录像
initOtherSubMitWork();//其他录像 initOtherSubMitWork();//其他录像
} }
private void initOtherSubMitWork() { private void initOtherSubMitWork() {

View File

@@ -389,7 +389,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
editDescribe.setText(memo + ""); editDescribe.setText(memo + "");
} }
String telPhone = showPoiEntity.getTelPhone(); String telPhone = showPoiEntity.getTelPhone();
if (telPhone != null && !telPhone.equals("")) { if (telPhone != null && !telPhone.equals("")&&!telPhone.equals("null")) {
String[] phones = telPhone.split("\\|"); String[] phones = telPhone.split("\\|");
for (int i = 0; i < phones.length; i++) { for (int i = 0; i < phones.length; i++) {
if (i == 0) { if (i == 0) {

View File

@@ -92,8 +92,8 @@ public class RecordFragment extends BaseFragment implements View.OnClickListener
if (staySubmitFragment!=null) { if (staySubmitFragment!=null) {
staySubmitFragment.refreshData(); staySubmitFragment.refreshData();
} }
// if (hasSubmitFragment!=null) { if (hasSubmitFragment!=null) {
// hasSubmitFragment.refreshData(); hasSubmitFragment.initRequest();
// } }
} }
} }

View File

@@ -12,8 +12,10 @@ import com.lzy.okgo.model.HttpHeaders;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response; import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.PostRequest; import com.lzy.okgo.request.PostRequest;
import com.navinfo.outdoor.api.UserApplication;
import com.navinfo.outdoor.bean.PoiUploadBean; import com.navinfo.outdoor.bean.PoiUploadBean;
import com.navinfo.outdoor.util.Md5Util; import com.navinfo.outdoor.util.Md5Util;
import com.navinfo.outdoor.util.NetWorkUtils;
import com.umeng.umcrash.UMCrash; import com.umeng.umcrash.UMCrash;
import java.io.File; import java.io.File;
@@ -125,6 +127,10 @@ public class OkGoBuilder<T> {
* post异步请求 * post异步请求
*/ */
public void postRequest(Callback<T> callback) { public void postRequest(Callback<T> callback) {
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
callback.onError(new Throwable("网络不可用"),2);
return;
}
OkGo OkGo
// 请求方式和请求url // 请求方式和请求url
.<T>post(url) .<T>post(url)
@@ -142,9 +148,9 @@ public class OkGoBuilder<T> {
.execute(new DialogCallback<T>(clazz) { .execute(new DialogCallback<T>(clazz) {
@Override @Override
public void onSuccess(Response<T> response) { public void onSuccess(Response<T> response) {
if (response.code()==200){ if (response.code() == 200) {
callback.onSuccess(response.body(), 1); callback.onSuccess(response.body(), 1);
}else { } else {
Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show(); Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show();
} }
} }
@@ -164,7 +170,6 @@ public class OkGoBuilder<T> {
} }
} }
}); });
} }
public HttpHeaders getHeader() { public HttpHeaders getHeader() {
@@ -201,6 +206,9 @@ public class OkGoBuilder<T> {
* @return * @return
*/ */
public okhttp3.Response postFileSynchronization() { public okhttp3.Response postFileSynchronization() {
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
return null;
}
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
params.put("datetime", time); params.put("datetime", time);
try { try {
@@ -230,6 +238,10 @@ public class OkGoBuilder<T> {
* @return * @return
*/ */
public void postFileAsynchronous(Callback callback) { public void postFileAsynchronous(Callback callback) {
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
callback.onError(new Throwable("网络不可用"),2);
return;
}
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
params.put("datetime", time); params.put("datetime", time);
OkGo OkGo
@@ -248,9 +260,9 @@ public class OkGoBuilder<T> {
.execute(new DialogCallback<T>(clazz) { .execute(new DialogCallback<T>(clazz) {
@Override @Override
public void onSuccess(Response<T> response) { public void onSuccess(Response<T> response) {
if (response.code()==200){ if (response.code() == 200) {
callback.onSuccess(response.body(), 1); callback.onSuccess(response.body(), 1);
}else { } else {
Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show(); Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show();
} }
} }
@@ -277,6 +289,10 @@ public class OkGoBuilder<T> {
* get异步请求 * get异步请求
*/ */
public void getRequest(Callback<T> callback) { public void getRequest(Callback<T> callback) {
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
callback.onError(new Throwable("网络不可用"),2);
return;
}
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
params.put("datetime", time); params.put("datetime", time);
OkGo OkGo
@@ -293,9 +309,9 @@ public class OkGoBuilder<T> {
.execute(new DialogCallback<T>(clazz) { .execute(new DialogCallback<T>(clazz) {
@Override @Override
public void onSuccess(Response<T> response) { public void onSuccess(Response<T> response) {
if (response.code()==200){ if (response.code() == 200) {
callback.onSuccess(response.body(), 1); callback.onSuccess(response.body(), 1);
}else { } else {
Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show(); Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show();
} }
@@ -320,6 +336,10 @@ public class OkGoBuilder<T> {
* @return * @return
*/ */
public okhttp3.Response getSynchronization() { public okhttp3.Response getSynchronization() {
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
Toast.makeText(activity, "网络不可用,请检查网络", Toast.LENGTH_SHORT).show();
return null;
}
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
params.put("datetime", time); params.put("datetime", time);
try { try {

View File

@@ -178,6 +178,9 @@ public class PoiSaveUtils {
Response execute = OkGoBuilder.getInstance().url(url) Response execute = OkGoBuilder.getInstance().url(url)
.Builder(mContext) .Builder(mContext)
.token(Constant.ACCESS_TOKEN).params(httpParams).getSynchronization(); .token(Constant.ACCESS_TOKEN).params(httpParams).getSynchronization();
if (execute==null){
return -1;
}
if (execute.code() != 200) { if (execute.code() != 200) {
return execute.code(); return execute.code();
} }
@@ -292,6 +295,9 @@ public class PoiSaveUtils {
.params(httpParams) .params(httpParams)
.token(Constant.ACCESS_TOKEN) .token(Constant.ACCESS_TOKEN)
.fileList(photoFile).postFileSynchronization(); .fileList(photoFile).postFileSynchronization();
if(execute==null){
return;
}
if (execute.code() != 200) { if (execute.code() != 200) {
return; return;
} }
@@ -384,6 +390,9 @@ public class PoiSaveUtils {
.url(HttpInterface.SUBMIT_CSTASK) .url(HttpInterface.SUBMIT_CSTASK)
.token(Constant.ACCESS_TOKEN) .token(Constant.ACCESS_TOKEN)
.params(httpParams).getSynchronization(); .params(httpParams).getSynchronization();
if (execute==null){
return -1;
}
if (execute.code() != 200) { if (execute.code() != 200) {
return execute.code(); return execute.code();
} }
@@ -463,6 +472,9 @@ public class PoiSaveUtils {
.token(Constant.ACCESS_TOKEN) .token(Constant.ACCESS_TOKEN)
.params(httpParams) .params(httpParams)
.fileList(chargingPileFileList).postFileSynchronization(); .fileList(chargingPileFileList).postFileSynchronization();
if (execute==null){
return -1;
}
if (execute.code() != 200) { if (execute.code() != 200) {
return execute.code(); return execute.code();
} }

View File

@@ -1,5 +1,5 @@
<resources> <resources>
<string name="app_name">地图寻宝</string> <string name="app_name">地图寻宝3.0</string>
<string name="title_activity_home">HomeActivity</string> <string name="title_activity_home">HomeActivity</string>
<!-- Strings used for fragments for navigation --> <!-- Strings used for fragments for navigation -->
<string name="first_fragment_label">First Fragment</string> <string name="first_fragment_label">First Fragment</string>