|
@@ -1,6 +1,8 @@
|
|
|
package com.uas.uas_mes_standard.util;
|
|
package com.uas.uas_mes_standard.util;
|
|
|
|
|
|
|
|
|
|
+import android.app.Activity;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
|
|
+import android.util.Log;
|
|
|
|
|
|
|
|
import com.android.volley.AuthFailureError;
|
|
import com.android.volley.AuthFailureError;
|
|
|
import com.android.volley.DefaultRetryPolicy;
|
|
import com.android.volley.DefaultRetryPolicy;
|
|
@@ -10,6 +12,8 @@ import com.android.volley.VolleyError;
|
|
|
import com.android.volley.toolbox.StringRequest;
|
|
import com.android.volley.toolbox.StringRequest;
|
|
|
import com.uas.uas_mes_standard.R;
|
|
import com.uas.uas_mes_standard.R;
|
|
|
import com.uas.uas_mes_standard.application.PdaApplication;
|
|
import com.uas.uas_mes_standard.application.PdaApplication;
|
|
|
|
|
+import com.uas.uas_mes_standard.global.GloableParams;
|
|
|
|
|
+import com.uas.uas_mes_standard.tools.SharedPreUtil;
|
|
|
import com.uas.uas_mes_standard.tools.VolleyUtil;
|
|
import com.uas.uas_mes_standard.tools.VolleyUtil;
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
@@ -54,7 +58,12 @@ public class VolleyRequest {
|
|
|
throw new IllegalArgumentException("httpParams can not be NULL");
|
|
throw new IllegalArgumentException("httpParams can not be NULL");
|
|
|
}
|
|
}
|
|
|
if (httpCallback == null) {
|
|
if (httpCallback == null) {
|
|
|
- throw new IllegalArgumentException("callback can not be NULL");
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ throw new IllegalArgumentException("callback can not be NULL");
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
if (httpParams.getUrl() == null) {
|
|
if (httpParams.getUrl() == null) {
|
|
|
throw new IllegalArgumentException("requestUrl can not be NULL");
|
|
throw new IllegalArgumentException("requestUrl can not be NULL");
|
|
@@ -73,14 +82,14 @@ public class VolleyRequest {
|
|
|
if (!TextUtils.isEmpty(url) && httpParams.getMethod() == Request.Method.GET && httpParams.getParams().size() > 0) {
|
|
if (!TextUtils.isEmpty(url) && httpParams.getMethod() == Request.Method.GET && httpParams.getParams().size() > 0) {
|
|
|
Set<Map.Entry<String, String>> entries = httpParams.getParams().entrySet();
|
|
Set<Map.Entry<String, String>> entries = httpParams.getParams().entrySet();
|
|
|
|
|
|
|
|
- int index = 1;
|
|
|
|
|
|
|
+ int index = 0;
|
|
|
for (Map.Entry<String, String> paramEntry : entries) {
|
|
for (Map.Entry<String, String> paramEntry : entries) {
|
|
|
String value = paramEntry.getValue();
|
|
String value = paramEntry.getValue();
|
|
|
if (!TextUtils.isEmpty(value)
|
|
if (!TextUtils.isEmpty(value)
|
|
|
&& value.charAt(0) == 65279) {
|
|
&& value.charAt(0) == 65279) {
|
|
|
value = value.substring(1);
|
|
value = value.substring(1);
|
|
|
}
|
|
}
|
|
|
- if (index == 1) {
|
|
|
|
|
|
|
+ if (index == 0) {
|
|
|
try {
|
|
try {
|
|
|
url += "?" + paramEntry.getKey() + "=" + (TextUtils.isEmpty(value) ? "" : URLEncoder.encode(value, "UTF-8"));
|
|
url += "?" + paramEntry.getKey() + "=" + (TextUtils.isEmpty(value) ? "" : URLEncoder.encode(value, "UTF-8"));
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
} catch (UnsupportedEncodingException e) {
|
|
@@ -94,6 +103,7 @@ public class VolleyRequest {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
index++;
|
|
index++;
|
|
|
|
|
+ Log.e("index",index+"");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -118,7 +128,15 @@ public class VolleyRequest {
|
|
|
try {
|
|
try {
|
|
|
LogUtil.e("responErr", errorToast);
|
|
LogUtil.e("responErr", errorToast);
|
|
|
if (errorToast.length() >= 500) {
|
|
if (errorToast.length() >= 500) {
|
|
|
- httpCallback.onFail(httpParams.getFlag(), "请求异常");
|
|
|
|
|
|
|
+ Log.e("重新登录1","重新登录");
|
|
|
|
|
+ //Volley请求服务器重新登录
|
|
|
|
|
+ Activity activity=new Activity();
|
|
|
|
|
+ String maName = SharedPreUtil.getString(activity, Constants.FLAG.ACCOUNT_NAME_CACHE, null);
|
|
|
|
|
+ String userName = SharedPreUtil.getString(activity, "userNames", null);
|
|
|
|
|
+ String password = SharedPreUtil.getString(activity, "passwords", null);
|
|
|
|
|
+ VolleyUtil.requestUserLogin(activity, GloableParams.ADDRESS_LOGIN_APPLY, VolleyUtil.METHOD_POST,
|
|
|
|
|
+ VolleyUtil.FRAGMENT_LOGIN, maName, userName, password);
|
|
|
|
|
+ httpCallback.onFail(httpParams.getFlag(), "已重新登录,请再次操作");
|
|
|
} else {
|
|
} else {
|
|
|
httpCallback.onFail(httpParams.getFlag(), errorToast);
|
|
httpCallback.onFail(httpParams.getFlag(), errorToast);
|
|
|
}
|
|
}
|