|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.bjzc.zjyxdxj.BuildConfig;
|
|
|
|
import com.bjzc.zjyxdxj.R;
|
|
|
|
import com.bjzc.zjyxdxj.R;
|
|
|
|
import com.bjzc.zjyxdxj.activity.LoginActivity;
|
|
|
|
import com.bjzc.zjyxdxj.activity.LoginActivity;
|
|
|
|
import com.bjzc.zjyxdxj.contans.Contans;
|
|
|
|
import com.bjzc.zjyxdxj.contans.Contans;
|
|
|
|
@ -78,28 +79,40 @@ public class NohttpUtils {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public <T> void add(Activity mActivity, int what, Request<T> request, HttpListener<T> callback, boolean canCanel, boolean isLoading, String msg) {
|
|
|
|
public <T> void add(Activity mActivity, int what, Request<T> request, HttpListener<T> callback, boolean canCanel, boolean isLoading, String msg) {
|
|
|
|
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
|
|
|
|
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
|
|
|
|
Log.i("app", request.url());
|
|
|
|
//Log.i("app", request.url());
|
|
|
|
if(!TextUtils.isEmpty(tokenTemp)){
|
|
|
|
if(!TextUtils.isEmpty(tokenTemp)){
|
|
|
|
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
|
|
|
|
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
|
|
|
|
String credential = "Bearer " + token;
|
|
|
|
String credential = "Bearer " + token;
|
|
|
|
request.addHeader("Authorization", credential);
|
|
|
|
request.addHeader("Authorization", credential);
|
|
|
|
// Log.i("app", request.url());
|
|
|
|
showLog(request.url());
|
|
|
|
Log.i("app", credential);
|
|
|
|
//Log.i("app", request.url());
|
|
|
|
|
|
|
|
// Log.i("app", credential);
|
|
|
|
// Log.i("app",new Gson().toJson(request.headers()));
|
|
|
|
// Log.i("app",new Gson().toJson(request.headers()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mQueue.add(what, request, new HttpResponseListener<T>(mActivity, request, callback, canCanel, isLoading, msg));
|
|
|
|
mQueue.add(what, request, new HttpResponseListener<T>(mActivity, request, callback, canCanel, isLoading, msg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void showLog(String logText) {
|
|
|
|
|
|
|
|
if (BuildConfig.LOG_ERROR) {
|
|
|
|
|
|
|
|
if(TextUtils.isEmpty(logText)){
|
|
|
|
|
|
|
|
Log.i("app", "logText is null");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
Log.i("app", logText);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public <T> void add(Activity mActivity, int what, Request<T> request, HttpListener<T> callback) {
|
|
|
|
public <T> void add(Activity mActivity, int what, Request<T> request, HttpListener<T> callback) {
|
|
|
|
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
|
|
|
|
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
|
|
|
|
Log.i("app", request.url());
|
|
|
|
//Log.i("app", request.url());
|
|
|
|
if(!TextUtils.isEmpty(tokenTemp)){
|
|
|
|
if(!TextUtils.isEmpty(tokenTemp)){
|
|
|
|
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
|
|
|
|
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
|
|
|
|
String credential = "Bearer " + token;
|
|
|
|
String credential = "Bearer " + token;
|
|
|
|
request.addHeader("Authorization", credential);
|
|
|
|
request.addHeader("Authorization", credential);
|
|
|
|
|
|
|
|
showLog(request.url());
|
|
|
|
//Log.i("app", request.url());
|
|
|
|
//Log.i("app", request.url());
|
|
|
|
Log.i("app", credential);
|
|
|
|
//Log.i("app", credential);
|
|
|
|
// Log.i("app",new Gson().toJson(request.headers()));
|
|
|
|
// Log.i("app",new Gson().toJson(request.headers()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mQueue.add(what, request, new HttpResponseListener<T>(mActivity, request, callback, true, true, "加载中..."));
|
|
|
|
mQueue.add(what, request, new HttpResponseListener<T>(mActivity, request, callback, true, true, "加载中..."));
|
|
|
|
|