修改纪录中的以提交的界面刷新
This commit is contained in:
@@ -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"
|
||||||
|
|||||||
@@ -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,72 +62,30 @@ 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);
|
alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
|
||||||
alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
|
if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK)
|
||||||
if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK)
|
return true;
|
||||||
return true;
|
return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
});
|
});
|
||||||
//loading样式
|
//loading样式
|
||||||
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
|
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
|
||||||
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) {
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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,11 +940,13 @@ 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();
|
||||||
String pileUpLoadResultStr = execute.body().string();
|
if(execute!=null){
|
||||||
PoiUploadBean uploadBeanResult = new Gson().fromJson(pileUpLoadResultStr, PoiUploadBean.class);
|
String pileUpLoadResultStr = execute.body().string();
|
||||||
if (uploadBeanResult != null) {
|
PoiUploadBean uploadBeanResult = new Gson().fromJson(pileUpLoadResultStr, PoiUploadBean.class);
|
||||||
if (uploadBeanResult.getCode() == 200) {
|
if (uploadBeanResult != null) {
|
||||||
PoiDatabase.getInstance(getActivity()).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
|
if (uploadBeanResult.getCode() == 200) {
|
||||||
|
PoiDatabase.getInstance(getActivity()).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -1454,16 +1455,19 @@ 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();
|
||||||
String responseBodyStr = execute.body().string();
|
if(execute!=null){
|
||||||
if (responseBodyStr != null) {
|
String responseBodyStr = execute.body().string();
|
||||||
Gson gson = new Gson();
|
if (responseBodyStr != null) {
|
||||||
ChargingPileSaveBean chargingPileSaveBean = gson.fromJson(responseBodyStr, ChargingPileSaveBean.class);
|
Gson gson = new Gson();
|
||||||
if (chargingPileSaveBean.getCode() != 200) {
|
ChargingPileSaveBean chargingPileSaveBean = gson.fromJson(responseBodyStr, ChargingPileSaveBean.class);
|
||||||
return;
|
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) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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,46 +127,49 @@ public class OkGoBuilder<T> {
|
|||||||
* post异步请求
|
* post异步请求
|
||||||
*/
|
*/
|
||||||
public void postRequest(Callback<T> callback) {
|
public void postRequest(Callback<T> callback) {
|
||||||
OkGo
|
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
|
||||||
// 请求方式和请求url
|
callback.onError(new Throwable("网络不可用"),2);
|
||||||
.<T>post(url)
|
return;
|
||||||
.isMultipart(true)
|
}
|
||||||
.headers(getHeader())
|
OkGo
|
||||||
.params(params)
|
// 请求方式和请求url
|
||||||
|
.<T>post(url)
|
||||||
|
.isMultipart(true)
|
||||||
|
.headers(getHeader())
|
||||||
|
.params(params)
|
||||||
// .upJson(json)
|
// .upJson(json)
|
||||||
// 请求的 tag, 主要用于取消对应的请求
|
// 请求的 tag, 主要用于取消对应的请求
|
||||||
.tag(this)
|
.tag(this)
|
||||||
|
|
||||||
// 设置当前请求的缓存key,建议每个不同功能的请求设置一个
|
// 设置当前请求的缓存key,建议每个不同功能的请求设置一个
|
||||||
// .cacheKey("cacheKey")
|
// .cacheKey("cacheKey")
|
||||||
// 缓存模式,详细请看缓存介绍
|
// 缓存模式,详细请看缓存介绍
|
||||||
// .cacheMode(CacheMode.DEFAULT)
|
// .cacheMode(CacheMode.DEFAULT)
|
||||||
.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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Response<T> response) {
|
public void onError(Response<T> response) {
|
||||||
super.onError(response);
|
super.onError(response);
|
||||||
Throwable throwable = response.getException();
|
Throwable throwable = response.getException();
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
callback.onError(throwable, 2);
|
callback.onError(throwable, 2);
|
||||||
/**
|
/**
|
||||||
* 友盟+
|
* 友盟+
|
||||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||||
*/
|
*/
|
||||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user