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

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 {
compileSdkVersion 29
buildToolsVersion '29.0.2'
ndkVersion '23.0.7123448'
// ndkVersion '23.0.7123448'
defaultConfig {
applicationId "com.navinfo.outdoor"

View File

@@ -44,12 +44,13 @@ public abstract class BaseActivity extends AppCompatActivity {
initData();
initListener();
}
private static void setCustomDensity(Application application, Activity activity) {
final DisplayMetrics appDisplayMetrics = application.getResources().getDisplayMetrics();
// 以设计DP为360为例获得目标Density
final float targetDensity = (float) (appDisplayMetrics.widthPixels / 360.0);
final float targetScaledDensity = targetDensity * (appDisplayMetrics.scaledDensity / appDisplayMetrics.density);
final int targetDensityDpi = (int)(targetDensity * 160);
final int targetDensityDpi = (int) (targetDensity * 160);
//设置application的Density
appDisplayMetrics.density = targetDensity;
appDisplayMetrics.scaledDensity = targetScaledDensity;
@@ -61,72 +62,30 @@ public abstract class BaseActivity extends AppCompatActivity {
activityDisplayMetrics.densityDpi = targetDensityDpi;
}
protected void toast(String mag){
protected void toast(String mag) {
Toast.makeText(UserApplication.getUserApplication(), mag, Toast.LENGTH_SHORT).show();
}
protected void initMVP() {
}
public void showLoadingDialog() {
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;
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();
// 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();
}
});
//loading样式
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
alertDialog.setView(view);
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.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) {
//给loading 添加文字
@@ -139,6 +98,7 @@ public abstract class BaseActivity extends AppCompatActivity {
alertDialog.dismiss();
}
}
protected void initListener() {
}
@@ -158,8 +118,10 @@ public abstract class BaseActivity extends AppCompatActivity {
super.onDestroy();
Collector.removeActivity(this);
}
/**
* 设置屏幕横竖屏切换
*
* @param screenRoate true 竖屏 false 横屏
*/
private void setScreenRoate(Boolean screenRoate) {

View File

@@ -95,7 +95,7 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
protected abstract int getLayout();
public void showLoadingDialog() {
if (NetWorkUtils.iConnected(getContext())) { // 当前网络可用
alertDialog = new AlertDialog.Builder(getActivity()).create();
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable());
alertDialog.setCancelable(false);
@@ -111,49 +111,6 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show();
//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();
if (telPhone != null && !telPhone.equals("")) {
if (telPhone != null && !telPhone.equals("")&&!telPhone.equals("null")) {
String[] phones = telPhone.split("\\|");
for (int i = 0; i < phones.length; i++) {
if (i == 0) {
if (!StringUtils.isEmpty(phones[i])) if (!StringUtils.isEmpty(phones[i])) {
if (!StringUtils.isEmpty(phones[i])) {
if (phones[i].contains("-")) { // 包含区号数据的电话
String[] split = phones[i].split("-");
if (split != null && split.length > 1) {
@@ -644,7 +644,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
.url(HttpInterface.GET_PHONES)
.params(new HttpParams("geo", encode))
.cls(GetPhoneBean.class)
.params(new HttpParams())
.token(Constant.ACCESS_TOKEN)
.getRequest(new Callback<GetPhoneBean>() {
@Override
@@ -941,11 +940,13 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
.params(httpParams)
.token(Constant.ACCESS_TOKEN)
.fileList(chargingPileFileList).postFileSynchronization();
String pileUpLoadResultStr = execute.body().string();
PoiUploadBean uploadBeanResult = new Gson().fromJson(pileUpLoadResultStr, PoiUploadBean.class);
if (uploadBeanResult != null) {
if (uploadBeanResult.getCode() == 200) {
PoiDatabase.getInstance(getActivity()).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
if(execute!=null){
String pileUpLoadResultStr = execute.body().string();
PoiUploadBean uploadBeanResult = new Gson().fromJson(pileUpLoadResultStr, PoiUploadBean.class);
if (uploadBeanResult != null) {
if (uploadBeanResult.getCode() == 200) {
PoiDatabase.getInstance(getActivity()).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
}
}
}
} catch (IOException e) {
@@ -1454,16 +1455,19 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
Response execute = OkGoBuilder.getInstance().url(HttpInterface.SUBMIT_CSTASK)
.token(Constant.ACCESS_TOKEN)
.params(httpParams).getSynchronization();
String responseBodyStr = execute.body().string();
if (responseBodyStr != null) {
Gson gson = new Gson();
ChargingPileSaveBean chargingPileSaveBean = gson.fromJson(responseBodyStr, ChargingPileSaveBean.class);
if (chargingPileSaveBean.getCode() != 200) {
return;
if(execute!=null){
String responseBodyStr = execute.body().string();
if (responseBodyStr != null) {
Gson gson = new Gson();
ChargingPileSaveBean chargingPileSaveBean = gson.fromJson(responseBodyStr, ChargingPileSaveBean.class);
if (chargingPileSaveBean.getCode() != 200) {
return;
}
chargingPileEntity.setBodyId(chargingPileSaveBean.getBody());
InsertAndUpdateUtils.getInstance().insertOrUpdateChargingPile(getActivity(), chargingPileEntity); // 更新当前充电桩的bodyId
}
chargingPileEntity.setBodyId(chargingPileSaveBean.getBody());
InsertAndUpdateUtils.getInstance().insertOrUpdateChargingPile(getActivity(), chargingPileEntity); // 更新当前充电桩的bodyId
}
} catch (IOException e) {
e.printStackTrace();
}

View File

@@ -326,7 +326,11 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
chargingStationEntity.setCreateTime(stationBean.getEndDate());
chargingStationEntity.setPrecision(stationBean.getPrice() + "");
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.setTaskStatus(statusId);
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);
poiVideoAuditThrough = (TextView) findViewById(R.id.poiVideo_audit_through);
poiVideoAuditProcessauditNotThrough = (TextView) findViewById(R.id.poiVideo_audit_processaudit_not_through);
initRequest();
}
public void initRequest() {
initPoiSubMitWork();//poi
initPoiVideoSubMitWork();//poi录像
initRoadSubMitWork();//道路录像
initChaningSubMitWork();//充电站录像
initOtherSubMitWork();//其他录像
}
private void initOtherSubMitWork() {

View File

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

View File

@@ -92,8 +92,8 @@ public class RecordFragment extends BaseFragment implements View.OnClickListener
if (staySubmitFragment!=null) {
staySubmitFragment.refreshData();
}
// if (hasSubmitFragment!=null) {
// hasSubmitFragment.refreshData();
// }
if (hasSubmitFragment!=null) {
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.Response;
import com.lzy.okgo.request.PostRequest;
import com.navinfo.outdoor.api.UserApplication;
import com.navinfo.outdoor.bean.PoiUploadBean;
import com.navinfo.outdoor.util.Md5Util;
import com.navinfo.outdoor.util.NetWorkUtils;
import com.umeng.umcrash.UMCrash;
import java.io.File;
@@ -125,46 +127,49 @@ public class OkGoBuilder<T> {
* post异步请求
*/
public void postRequest(Callback<T> callback) {
OkGo
// 请求方式和请求url
.<T>post(url)
.isMultipart(true)
.headers(getHeader())
.params(params)
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
callback.onError(new Throwable("网络不可用"),2);
return;
}
OkGo
// 请求方式和请求url
.<T>post(url)
.isMultipart(true)
.headers(getHeader())
.params(params)
// .upJson(json)
// 请求的 tag, 主要用于取消对应的请求
.tag(this)
// 请求的 tag, 主要用于取消对应的请求
.tag(this)
// 设置当前请求的缓存key,建议每个不同功能的请求设置一个
// 设置当前请求的缓存key,建议每个不同功能的请求设置一个
// .cacheKey("cacheKey")
// 缓存模式,详细请看缓存介绍
// 缓存模式,详细请看缓存介绍
// .cacheMode(CacheMode.DEFAULT)
.execute(new DialogCallback<T>(clazz) {
@Override
public void onSuccess(Response<T> response) {
if (response.code()==200){
callback.onSuccess(response.body(), 1);
}else {
Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show();
.execute(new DialogCallback<T>(clazz) {
@Override
public void onSuccess(Response<T> response) {
if (response.code() == 200) {
callback.onSuccess(response.body(), 1);
} else {
Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show();
}
}
}
@Override
public void onError(Response<T> response) {
super.onError(response);
Throwable throwable = response.getException();
if (throwable != null) {
throwable.printStackTrace();
callback.onError(throwable, 2);
/**
* 友盟+
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
*/
UMCrash.generateCustomLog("网络请求报错-位置OKGOBuilder" + throwable, "UmengException");
@Override
public void onError(Response<T> response) {
super.onError(response);
Throwable throwable = response.getException();
if (throwable != null) {
throwable.printStackTrace();
callback.onError(throwable, 2);
/**
* 友盟+
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
*/
UMCrash.generateCustomLog("网络请求报错-位置OKGOBuilder" + throwable, "UmengException");
}
}
}
});
});
}
public HttpHeaders getHeader() {
@@ -201,6 +206,9 @@ public class OkGoBuilder<T> {
* @return
*/
public okhttp3.Response postFileSynchronization() {
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
return null;
}
long time = System.currentTimeMillis();
params.put("datetime", time);
try {
@@ -230,6 +238,10 @@ public class OkGoBuilder<T> {
* @return
*/
public void postFileAsynchronous(Callback callback) {
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
callback.onError(new Throwable("网络不可用"),2);
return;
}
long time = System.currentTimeMillis();
params.put("datetime", time);
OkGo
@@ -248,9 +260,9 @@ public class OkGoBuilder<T> {
.execute(new DialogCallback<T>(clazz) {
@Override
public void onSuccess(Response<T> response) {
if (response.code()==200){
if (response.code() == 200) {
callback.onSuccess(response.body(), 1);
}else {
} else {
Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show();
}
}
@@ -277,6 +289,10 @@ public class OkGoBuilder<T> {
* get异步请求
*/
public void getRequest(Callback<T> callback) {
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
callback.onError(new Throwable("网络不可用"),2);
return;
}
long time = System.currentTimeMillis();
params.put("datetime", time);
OkGo
@@ -293,9 +309,9 @@ public class OkGoBuilder<T> {
.execute(new DialogCallback<T>(clazz) {
@Override
public void onSuccess(Response<T> response) {
if (response.code()==200){
if (response.code() == 200) {
callback.onSuccess(response.body(), 1);
}else {
} else {
Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show();
}
@@ -320,6 +336,10 @@ public class OkGoBuilder<T> {
* @return
*/
public okhttp3.Response getSynchronization() {
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
Toast.makeText(activity, "网络不可用,请检查网络", Toast.LENGTH_SHORT).show();
return null;
}
long time = System.currentTimeMillis();
params.put("datetime", time);
try {

View File

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

View File

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