From c5bf501d8b507d1e3e79541e7ac9b45910860b4d Mon Sep 17 00:00:00 2001
From: 陈奇 <1650699704@qq.com>
Date: Wed, 29 May 2019 16:17:07 +0800
Subject: [PATCH] 添加新功能
---
app/src/main/java/com/moral/yunfushao/httputils/HttpUtils.java | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/app/src/main/java/com/moral/yunfushao/httputils/HttpUtils.java b/app/src/main/java/com/moral/yunfushao/httputils/HttpUtils.java
index 60ab35a..a3caa31 100644
--- a/app/src/main/java/com/moral/yunfushao/httputils/HttpUtils.java
+++ b/app/src/main/java/com/moral/yunfushao/httputils/HttpUtils.java
@@ -26,6 +26,7 @@
public class HttpUtils {
/**
* Get������
+ *
* @param url
* @param params
* @param cacheMode
@@ -53,14 +54,14 @@
public void onSuccess(String s, Call call, Response response) {
XLog.e("result:" + s);
try {
- JSONObject resJosn= new JSONObject(s);
+ JSONObject resJosn = new JSONObject(s);
JSONObject jsonObject = resJosn.getJSONObject("data");
int errno = jsonObject.optInt("code");
String message = jsonObject.optString("msg");
- if(errno == 0){
- httpCallBack.onSuccess(jsonObject.optString("info"),message);
- }else{
- httpCallBack.onFail(errno,message);
+ if (errno == 0) {
+ httpCallBack.onSuccess(jsonObject.optString("info"), message);
+ } else {
+ httpCallBack.onFail(errno, message);
}
} catch (JSONException e) {
e.printStackTrace();
@@ -109,6 +110,7 @@
/**
* Post������
+ *
* @param url
* @param params
* @param cacheMode
@@ -136,18 +138,22 @@
public void onSuccess(String s, Call call, Response response) {
XLog.e("result:" + s);
try {
- JSONObject resJosn= new JSONObject(s);
- if(resJosn.has("data")) {
+ JSONObject resJosn = new JSONObject(s);
+ if (resJosn.has("data")) {
JSONObject jsonObject = resJosn.getJSONObject("data");
int errno = jsonObject.optInt("code");
String message = jsonObject.optString("msg");
- if(errno == 0){
- httpCallBack.onSuccess(jsonObject.optString("info"),message);
- }else{
- httpCallBack.onFail(errno,message);
+ if (jsonObject.length() == 0 || errno == 0) {
+ httpCallBack.onSuccess(jsonObject.optString("info"), message);
+ } else {
+ httpCallBack.onFail(errno, message);
}
+ } else {
+ XLog.e("result jsonObject:");
}
} catch (JSONException e) {
+ httpCallBack.onFail(503, e.getMessage());
+ XLog.e("result jsonObject:" + e);
e.printStackTrace();
}
@@ -190,6 +196,7 @@
/**
* ������������
+ *
* @param url
* @param params
* @param uploadCallBack
@@ -213,13 +220,13 @@
public void onSuccess(String s, Call call, Response response) {
XLog.e("result:" + s);
try {
- JSONObject resJosn= new JSONObject(s);
+ JSONObject resJosn = new JSONObject(s);
JSONObject jsonObject = resJosn.getJSONObject("data");
int errno = jsonObject.optInt("code");
String message = jsonObject.optString("msg");
- if(errno == 0){
- uploadCallBack.onSuccess(jsonObject.optString("info"),message);
- }else{
+ if (errno == 0) {
+ uploadCallBack.onSuccess(jsonObject.optString("info"), message);
+ } else {
uploadCallBack.onFail(message);
}
} catch (JSONException e) {
@@ -270,6 +277,7 @@
/**
* ������������
+ *
* @param url
* @param params
* @param uploadCallBack
@@ -295,13 +303,13 @@
public void onSuccess(String s, Call call, Response response) {
XLog.e("result:" + s);
try {
- JSONObject resJosn= new JSONObject(s);
+ JSONObject resJosn = new JSONObject(s);
JSONObject jsonObject = resJosn.getJSONObject("data");
int errno = jsonObject.optInt("code");
String message = jsonObject.optString("msg");
- if(errno == 0){
- uploadCallBack.onSuccess(jsonObject.optString("info"),message);
- }else{
+ if (errno == 0) {
+ uploadCallBack.onSuccess(jsonObject.optString("info"), message);
+ } else {
uploadCallBack.onFail(message);
}
} catch (JSONException e) {
--
Gitblit v1.8.0