网络请求调整

master
hwf453 2 years ago
parent 1e231c8cad
commit 5ca5f88b20

@ -143,8 +143,22 @@ public class LoginActivity extends BaseActivity {
if (BuildConfig.LOG_ERROR) {
et_use.setText("FGTL01");
et_pwd.setText("123");
// et_use.setText("BA01");
// et_pwd.setText("123");
// et_use.setText("990001");
// et_pwd.setText("000000");
//
// et_use.setText("990002");
// et_pwd.setText("000000");
et_use.setText("310258");
et_pwd.setText("Shi&7791");
// et_use.setText("FGTL01");
// et_pwd.setText("123");
// et_use.setText("310673");
// et_pwd.setText("Abcd@1234");

@ -713,6 +713,7 @@ public class MainActivity extends BaseActivity {
try {
String result = response.get();
showLog(result);
ApkUpdateBean appUploadInfo = GsonUtils.GsonToBean(result, ApkUpdateBean.class);
if (appUploadInfo != null) {
@ -723,10 +724,10 @@ public class MainActivity extends BaseActivity {
String versioncode = appUploadInfo.getRows().get(0).getVersioncode();
String appdesc = appUploadInfo.getRows().get(0).getAppdesc();
// showLog(getVersionName());
// showLog(appversionname);
// showLog(versioncode);
// showLog(getVersionName());
if(Contans.IP == Contans.IP_INTRANET){
appURL = appUploadInfo.getRows().get(0).getApkurl2();
}
if (!appversionname.equals(getVersionName())) {

@ -3,6 +3,8 @@ package com.example.administrator.zhapp.fragment.ajhxcgl;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
@ -25,6 +27,7 @@ import com.example.administrator.zhapp.fragment.BaseFragment;
import com.example.administrator.zhapp.utils.GsonUtils;
import com.example.administrator.zhapp.utils.HttpListener;
import com.example.administrator.zhapp.utils.HttpResponseListener;
import com.example.administrator.zhapp.utils.RSAUtils;
import com.example.administrator.zhapp.utils.SPUtils;
import com.example.administrator.zhapp.utils.UiUtlis;
import com.example.administrator.zhapp.weight.WaitDialog;
@ -311,6 +314,17 @@ public class AscFragment extends BaseFragment {
selectCount++;
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.AJHSC, RequestMethod.POST);
request.setDefineRequestBodyForJson(UiUtlis.encoder(json));
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(0, request, new HttpResponseListener<>(getActivity(), request, callback, false, false, ""));
//NohttpUtils.getInstance().add(getActivity(), 0, request, callback, false, false, "上传中...");
@ -324,6 +338,17 @@ public class AscFragment extends BaseFragment {
"&areacode=" + UiUtlis.encoder(ajhxcjs.getAreacode()) +
"&jsr=" + UiUtlis.encoder((String) SPUtils.get(context, Contans.USERNAME, "")), RequestMethod.POST);
request1.add(Contans.FILEPS, new FileBinary(new File(ajhxcjs.getFile())));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request1.addHeader("Authorization", credential);
showLog(request1.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(1, request1, new HttpResponseListener<>(getActivity(), request1, callback, false, false, ""));
//NohttpUtils.getInstance().add(getActivity(), 1, request1, callback, false, false, "");
}
@ -337,6 +362,17 @@ public class AscFragment extends BaseFragment {
Logger.json(json1);
json1 = new String(json1.getBytes(), StandardCharsets.UTF_8);
request2.setDefineRequestBodyForJson(UiUtlis.encoder(json1));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request2.addHeader("Authorization", credential);
showLog(request2.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(2, request2, new HttpResponseListener<>(getActivity(), request2, callback, false, false, ""));
//NohttpUtils.getInstance().add(getActivity(), 2, request2, callback, false, false, "上传中...");
}
@ -347,6 +383,17 @@ public class AscFragment extends BaseFragment {
selectCount++;
Request<String> yhpctp = NoHttp.createStringRequest(Contans.IP + Contans.YHPCTP + "?guid=" + tp.getGuid(), RequestMethod.POST);
yhpctp.add(Contans.FILEPS, new FileBinary(new File(tp.getPath())));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
yhpctp.addHeader("Authorization", credential);
showLog(yhpctp.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(3, yhpctp, new HttpResponseListener<>(getActivity(), yhpctp, callback, false, false, ""));
}
}

@ -2,6 +2,7 @@ package com.example.administrator.zhapp.fragment.ajhxcgl;
import android.content.ContentValues;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
@ -20,6 +21,7 @@ import com.example.administrator.zhapp.fragment.BaseFragment;
import com.example.administrator.zhapp.utils.GsonUtils;
import com.example.administrator.zhapp.utils.HttpListener;
import com.example.administrator.zhapp.utils.HttpResponseListener;
import com.example.administrator.zhapp.utils.RSAUtils;
import com.example.administrator.zhapp.utils.SPUtils;
import com.example.administrator.zhapp.utils.UiUtlis;
import com.example.administrator.zhapp.weight.WaitDialog;
@ -180,6 +182,17 @@ public class AxzFragment extends BaseFragment {
private void requestData() {
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.AJHJHLIST);
request.add("BZMC", UiUtlis.encoder((String) SPUtils.get(context, Contans.BZBH, "")));
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(0, request, new HttpResponseListener<>(getActivity(), request, callback, true, true, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 0, request, callback, true, true, "加载中...");
}
@ -188,6 +201,17 @@ public class AxzFragment extends BaseFragment {
requestCount++;
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.AJHXZRW);
request.add("jhid", UiUtlis.encoder(jhid));
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(1, request, new HttpResponseListener<String>(getActivity(), request, callback, false, false, ""));
//NohttpUtils.getInstance().add(getActivity(), 1, request, callback, false, false, "下载计划中...");

@ -2,13 +2,17 @@ package com.example.administrator.zhapp.fragment.xfbwxcgl;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.TextView;
import com.example.administrator.zhapp.DBModel.LyXcjsInfo;
import com.example.administrator.zhapp.DBModel.LyYhpcInfo;
import com.example.administrator.zhapp.DBModel.LyxcXm;
@ -30,6 +34,7 @@ import com.example.administrator.zhapp.fragment.BaseFragment;
import com.example.administrator.zhapp.utils.GsonUtils;
import com.example.administrator.zhapp.utils.HttpListener;
import com.example.administrator.zhapp.utils.HttpResponseListener;
import com.example.administrator.zhapp.utils.RSAUtils;
import com.example.administrator.zhapp.utils.SPUtils;
import com.example.administrator.zhapp.utils.UiUtlis;
import com.example.administrator.zhapp.weight.WaitDialog;
@ -40,7 +45,9 @@ import com.yolanda.nohttp.RequestMethod;
import com.yolanda.nohttp.rest.Request;
import com.yolanda.nohttp.rest.RequestQueue;
import com.yolanda.nohttp.rest.Response;
import org.litepal.crud.DataSupport;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@ -113,7 +120,7 @@ public class XscFragment extends BaseFragment {
@Override
protected void initView() {
lv = (ListView) headView.findViewById(R.id.lv);
lv = view.findViewById(R.id.lv);
btnSc = view.findViewById(R.id.btn_sc);
btnHf = view.findViewById(R.id.btn_hf);
btnDel = view.findViewById(R.id.btn_delete);
@ -375,7 +382,7 @@ public class XscFragment extends BaseFragment {
LyYhpcInfo yhpcInfo = new LyYhpcInfo();
yhpcInfo.setAREACODE(qy.getQYID());
yhpcInfo.setFXSJ(qy.getCJSJ());
yhpcInfo.setFXR((String) SPUtils.get(context, Contans.USERNAME,""));
yhpcInfo.setFXR((String) SPUtils.get(context, Contans.USERNAME, ""));
yhpcInfo.setWT(qy.getXMNAME() + xm.get(0).getTypename());
yhpcInfo.setNR(qy.getCJJG());
}
@ -484,7 +491,7 @@ public class XscFragment extends BaseFragment {
for (XfDjjhRwqy rwqy : djjhRwqies) {
if (!rwqy.isChecked()) {
rwqy.setCJSJ("");
rwqy.setCJR((String) SPUtils.get(context,Contans.NAME,""));
rwqy.setCJR((String) SPUtils.get(context, Contans.NAME, ""));
rwqy.setSMFX("");
rwqy.setCJJG("");
rwqy.setIszc("0");
@ -509,7 +516,7 @@ public class XscFragment extends BaseFragment {
if (xfBaxcRwqies != null) {
for (XfBaxcRwqy qys : xfBaxcRwqies) {
if (!qys.isChecked()) {
qys.setCjr((String) SPUtils.get(context,Contans.NAME,""));
qys.setCjr((String) SPUtils.get(context, Contans.NAME, ""));
qys.setCjsj("");
}
}
@ -527,7 +534,7 @@ public class XscFragment extends BaseFragment {
if (lyxcrwqies1 != null) {
for (Lyxcrwqy lyxcrwqy : lyxcrwqies1) {
if (!lyxcrwqy.isChecked()) {
lyxcrwqy.setCJR((String) SPUtils.get(context,Contans.NAME,""));
lyxcrwqy.setCJR((String) SPUtils.get(context, Contans.NAME, ""));
lyxcrwqy.setCJSJ("");
lyxcrwqy.setISZC("0");
lyxcrwqy.setSMFX("");
@ -582,11 +589,22 @@ public class XscFragment extends BaseFragment {
private void sCData(String xf, String ba, String ly) {
dialog.show();
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
if (!xf.isEmpty()) {
requestCount++;
Logger.v(xf);
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.XFDJJHSC + "?cjscr=" + UiUtlis.encoder((String) SPUtils.get(context, Contans.NAME, "测试")), RequestMethod.POST);
request.setDefineRequestBodyForJson(UiUtlis.encoder(xf));
if (!TextUtils.isEmpty(tokenTemp)) {
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(0, request, new HttpResponseListener<>(getActivity(), request, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 0, request, callback, false, false, "上传中...");
List<XfXcjsInfo> xcjss = DataSupport.findAll(XfXcjsInfo.class);
@ -600,6 +618,16 @@ public class XscFragment extends BaseFragment {
"&djr=" + UiUtlis.encoder(info.getDjr()) + "&xfid=" + UiUtlis.encoder(info.getXfid()), RequestMethod.POST);
xcjs.add(Contans.FILEPS, new FileBinary(new File(info.getPath())));
if (!TextUtils.isEmpty(tokenTemp)) {
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);
String credential = "Bearer " + token;
xcjs.addHeader("Authorization", credential);
showLog(xcjs.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(1, xcjs, new HttpResponseListener<>(getActivity(), xcjs, callback, false, false, "加载中..."));
}
//NohttpUtils.getInstance().add(getActivity(), 1, xcjs, callback, false, false, "上传中...");
@ -610,6 +638,16 @@ public class XscFragment extends BaseFragment {
Logger.v(ba);
Request<String> baxc = NoHttp.createStringRequest(Contans.IP + Contans.BAXCJHSC + "?cjscr=" + UiUtlis.encoder((String) SPUtils.get(context, Contans.NAME, "测试")), RequestMethod.POST);
baxc.setDefineRequestBodyForJson(UiUtlis.encoder(ba));
if (!TextUtils.isEmpty(tokenTemp)) {
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);
String credential = "Bearer " + token;
baxc.addHeader("Authorization", credential);
showLog(baxc.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(2, baxc, new HttpResponseListener<>(getActivity(), baxc, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 2, baxc, callback, false, false, "上传中...");
@ -623,6 +661,16 @@ public class XscFragment extends BaseFragment {
Request<String> yhpc = NoHttp.createStringRequest(Contans.IP + Contans.YHPC + "?cjscr=" + UiUtlis.encoder((String) SPUtils.get(context, Contans.NAME, "测试")), RequestMethod.POST);
String json1 = "{\"Rows\":" + GsonUtils.GsonString(info) + ",\"Total\": " + info.size() + "}";
yhpc.setDefineRequestBodyForJson(json1);
if (!TextUtils.isEmpty(tokenTemp)) {
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);
String credential = "Bearer " + token;
yhpc.addHeader("Authorization", credential);
showLog(yhpc.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(3, yhpc, new HttpResponseListener<>(getActivity(), yhpc, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 3, yhpc, callback, false, false, "");
}
@ -630,6 +678,16 @@ public class XscFragment extends BaseFragment {
requestCount++;
Request<String> lyxc = NoHttp.createStringRequest(Contans.IP + Contans.LYXCSC + "?cjscr=" + UiUtlis.encoder((String) SPUtils.get(context, Contans.NAME, "测试")), RequestMethod.POST);
lyxc.setDefineRequestBodyForJson(UiUtlis.encoder(ly));
if (!TextUtils.isEmpty(tokenTemp)) {
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);
String credential = "Bearer " + token;
lyxc.addHeader("Authorization", credential);
showLog(lyxc.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(4, lyxc, new HttpResponseListener<>(getActivity(), lyxc, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 4, lyxc, callback, false, false, "上传中...");
@ -641,6 +699,16 @@ public class XscFragment extends BaseFragment {
"&jhid=" + UiUtlis.encoder(lyinfo.getJhid()) + "&filename=" + UiUtlis.encoder(lyinfo.getFilename()) +
"&djr=" + UiUtlis.encoder(lyinfo.getDjr()) + "&xfid=" + UiUtlis.encoder(lyinfo.getXfid()), RequestMethod.POST);
xcjs.add(Contans.FILEPS, new FileBinary(new File(lyinfo.getPath())));
if (!TextUtils.isEmpty(tokenTemp)) {
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);
String credential = "Bearer " + token;
xcjs.addHeader("Authorization", credential);
showLog(xcjs.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(5, xcjs, new HttpResponseListener<>(getActivity(), xcjs, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 5, xcjs, callback, false, false, "上传中...");
}
@ -650,8 +718,9 @@ public class XscFragment extends BaseFragment {
private HttpListener<String> callback = new HttpListener<String>() {
@Override
public void onSucceed(int what, Response<String> response) {
Logger.v(response.get());
System.out.println("消防" + response.get());
showLog("消防");
String result = response.get();
showLog(result);
StatusInfo info = GsonUtils.GsonToBean(response.get(), StatusInfo.class);
if (info != null && info.getTotal() != 0) {
try {

@ -2,6 +2,7 @@ package com.example.administrator.zhapp.fragment.xfbwxcgl;
import android.content.ContentValues;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
@ -30,9 +31,11 @@ import com.example.administrator.zhapp.fragment.BaseFragment;
import com.example.administrator.zhapp.utils.GsonUtils;
import com.example.administrator.zhapp.utils.HttpListener;
import com.example.administrator.zhapp.utils.HttpResponseListener;
import com.example.administrator.zhapp.utils.RSAUtils;
import com.example.administrator.zhapp.utils.SPUtils;
import com.example.administrator.zhapp.utils.UiUtlis;
import com.example.administrator.zhapp.weight.WaitDialog;
import com.google.gson.Gson;
import com.orhanobut.logger.Logger;
import com.yolanda.nohttp.NoHttp;
import com.yolanda.nohttp.rest.Request;
@ -99,10 +102,20 @@ public class XxzjhFragment extends BaseFragment {
@Override
protected void initView() {
lv = (ListView) headView.findViewById(R.id.lv);
btnXz = (Button) headView.findViewById(R.id.btn_xz);
btnDel = (Button) headView.findViewById(R.id.btn_delete);
tvNodata = (TextView) headView.findViewById(R.id.tv_nodata);
lv = (ListView) view.findViewById(R.id.lv);
btnXz = (Button) view.findViewById(R.id.btn_xz);
btnDel = (Button) view.findViewById(R.id.btn_delete);
tvNodata = (TextView) view.findViewById(R.id.tv_nodata);
mActivity = (XxzActivity) getActivity();
headView = View.inflate(context, R.layout.xzjh_item, null);
head = headView.findViewById(R.id.head);
head.setVisibility(View.VISIBLE);
TextView textView = (TextView) headView.findViewById(R.id.tv_jhlx);
textView.setText("到期时间");
cb = (CheckBox) headView.findViewById(R.id.cb);
btnXz.setOnClickListener(new View.OnClickListener() {
@Override
@ -146,13 +159,6 @@ public class XxzjhFragment extends BaseFragment {
lv.setEmptyView(tvNodata);
mActivity = (XxzActivity) getActivity();
headView = View.inflate(context, R.layout.xzjh_item, null);
head = headView.findViewById(R.id.head);
head.setVisibility(View.VISIBLE);
TextView textView = (TextView) headView.findViewById(R.id.tv_jhlx);
textView.setText("到期时间");
cb = (CheckBox) headView.findViewById(R.id.cb);
cb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -201,16 +207,38 @@ public class XxzjhFragment extends BaseFragment {
private void requestData() {
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.XFDJJHALL);
request.add("bzbh", UiUtlis.encoder((String) SPUtils.get(context, Contans.BZBH, "")));
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(0, request, new HttpResponseListener<>(getActivity(), request, callback, true, true, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 0, request, callback, true, true, "加载中...");
}
private void downData(String jhid, String xctypes) {
String tokenTemp = (String) SPUtils.get(mActivity, Contans.LOGIN_TOKEN, "");
if (xctypes.equals("1")) {
requestCount++;
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.XFDJJHXZ);
request.add("jhid", UiUtlis.encoder(jhid));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(1, request, new HttpResponseListener<>(getActivity(), request, callback, false, false, ""));
//NohttpUtils.getInstance().add(getActivity(), 1, request, callback, false, false, "下载计划中...");
@ -218,29 +246,80 @@ public class XxzjhFragment extends BaseFragment {
Request<String> request1 = NoHttp.createStringRequest(Contans.IP + Contans.XFXCMHQC);
request1.add("jhid", UiUtlis.encoder(jhid));
request1.add("xftype", 1);
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request1.addHeader("Authorization", credential);
showLog(request1.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(2, request1, new HttpResponseListener<>(getActivity(), request1, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 2, request1, callback, false, false, "下载计划中...");
requestCount++;
Request<String> request2 = NoHttp.createStringRequest(Contans.IP + Contans.XFXCXM);
request2.add("jhid", UiUtlis.encoder(jhid));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request2.addHeader("Authorization", credential);
showLog(request2.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(3, request2, new HttpResponseListener<>(getActivity(), request2, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 3, request2, callback, false, false, "下载计划中");
} else if (xctypes.equals("2")) {
requestCount++;
Request<String> xfba = NoHttp.createStringRequest(Contans.IP + Contans.BAXCJHXZ);
xfba.add("jhid", UiUtlis.encoder(jhid));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
xfba.addHeader("Authorization", credential);
showLog(xfba.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(4, xfba, new HttpResponseListener<>(getActivity(), xfba, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 4, xfba, callback, false, false, "下载计划中");
} else if (xctypes.equals("3")) {
requestCount++;
Request<String> lyxc = NoHttp.createStringRequest(Contans.IP + Contans.LYXCXM);
lyxc.add("jhid", UiUtlis.encoder(jhid));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
lyxc.addHeader("Authorization", credential);
showLog(lyxc.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(5, lyxc, new HttpResponseListener<>(getActivity(), lyxc, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 5, lyxc, callback, false, false, "下载计划中");
requestCount++;
Request<String> lyxcqy = NoHttp.createStringRequest(Contans.IP + Contans.LYXCQY);
lyxcqy.add("jhid", UiUtlis.encoder(jhid));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
lyxcqy.addHeader("Authorization", credential);
showLog(lyxcqy.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(6, lyxcqy, new HttpResponseListener<>(getActivity(), lyxcqy, callback, false, false, "加载中..."));
//NohttpUtils.getInstance().add(getActivity(), 6, lyxcqy, callback, false, false, "下载计划中");
}
@ -249,12 +328,12 @@ public class XxzjhFragment extends BaseFragment {
private HttpListener<String> callback = new HttpListener<String>() {
@Override
public void onSucceed(int what, Response<String> response) {
String josn = "";
josn = new String(response.get().getBytes(), StandardCharsets.UTF_8);
String result = response.get();
showLog(result);
switch (what) {
case 0:
list = GsonUtils.GsonToBean(response.get(), XfDjjhList.class);
list = GsonUtils.GsonToBean(result, XfDjjhList.class);
if (list != null) {
if (Integer.parseInt(list.getTotal()) != 0) {
@ -270,7 +349,7 @@ public class XxzjhFragment extends BaseFragment {
}
break;
case 1:
rwlist = GsonUtils.GsonToBean(response.get(), XfDjjhRwList.class);
rwlist = GsonUtils.GsonToBean(result, XfDjjhRwList.class);
//开启一个线程保存数据
if (rwlist != null) {
successCount++;
@ -287,7 +366,7 @@ public class XxzjhFragment extends BaseFragment {
}
break;
case 2:
XfXcmhqcList list = GsonUtils.GsonToBean(response.get(), XfXcmhqcList.class);
XfXcmhqcList list = GsonUtils.GsonToBean(result, XfXcmhqcList.class);
if (list != null) {
successCount++;
if (!list.getTotal().equals("0")) {
@ -300,7 +379,7 @@ public class XxzjhFragment extends BaseFragment {
}
break;
case 3:
XfXcxmList list1 = GsonUtils.GsonToBean(response.get(), XfXcxmList.class);
XfXcxmList list1 = GsonUtils.GsonToBean(result, XfXcxmList.class);
if (list1 != null) {
successCount++;
xcxms = list1.getRows();
@ -313,7 +392,7 @@ public class XxzjhFragment extends BaseFragment {
case 4:
Logger.v(response.get());
XfBaxcRwqyList xfbas = GsonUtils.GsonToBean(response.get(), XfBaxcRwqyList.class);
XfBaxcRwqyList xfbas = GsonUtils.GsonToBean(result, XfBaxcRwqyList.class);
if (xfbas != null) {
successCount++;
xfBaxcRwqies = xfbas.getRows();
@ -328,7 +407,7 @@ public class XxzjhFragment extends BaseFragment {
break;
case 5:
//楼宇巡查
LyxcXmList lyxcXmList = GsonUtils.GsonToBean(response.get(), LyxcXmList.class);
LyxcXmList lyxcXmList = GsonUtils.GsonToBean(result, LyxcXmList.class);
if (lyxcXmList != null) {
successCount++;
if (!lyxcXmList.getTotal().equals("0")) {
@ -340,7 +419,7 @@ public class XxzjhFragment extends BaseFragment {
break;
case 6:
LyxcqyList lyxcqyList = GsonUtils.GsonToBean(response.get(), LyxcqyList.class);
LyxcqyList lyxcqyList = GsonUtils.GsonToBean(result, LyxcqyList.class);
if (lyxcqyList != null) {
successCount++;
if (lyxcqyList.getTotal() != 0) {

@ -64,7 +64,7 @@ public class XxzlbaFragment extends BaseFragment {
@Override
protected void initView() {
lv = (ListView) headView.findViewById(R.id.lv);
lv = view.findViewById(R.id.lv);
}
public void initData() {

@ -58,7 +58,7 @@ public class XzaxlFragment extends BaseFragment {
@Override
protected void initView() {
context = getContext();
lv = (ListView) headView.findViewById(R.id.lv);
lv = view.findViewById(R.id.lv);
}
public void initData() {

@ -36,6 +36,7 @@ import com.example.administrator.zhapp.utils.HttpListener;
import com.example.administrator.zhapp.utils.HttpResponseListener;
import com.example.administrator.zhapp.utils.NetworkAvailableUtils;
import com.example.administrator.zhapp.utils.NohttpUtils;
import com.example.administrator.zhapp.utils.RSAUtils;
import com.example.administrator.zhapp.utils.SPUtils;
import com.example.administrator.zhapp.utils.UiUtlis;
import com.orhanobut.logger.Logger;
@ -382,11 +383,22 @@ public class UploadDataService extends IntentService {
xfjson = new String(xf.toString().getBytes(), StandardCharsets.UTF_8);
lyjson = new String(ly.toString().getBytes(), StandardCharsets.UTF_8);
String tokenTemp = (String) SPUtils.get(getApplicationContext(), Contans.LOGIN_TOKEN, "");
if (!xf.toString().isEmpty()) {
requestCount++;
Logger.v(xf.toString());
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.XFDJJHSC + "?cjscr=" + UiUtlis.encoder((String) SPUtils.get(getApplicationContext(), Contans.NAME, "测试")), RequestMethod.POST);
request.setDefineRequestBodyForJson(UiUtlis.encoder(xfjson));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(0, request, new HttpResponseListener<>(null, request, callback, false, false, ""));
//NohttpUtils.getInstance().add(null, 0, request, callback, false, false, "");
List<XfXcjsInfo> xcjss = DataSupport.findAll(XfXcjsInfo.class);
@ -396,6 +408,16 @@ public class UploadDataService extends IntentService {
"&jhid=" + UiUtlis.encoder(info.getJhid()) + "&filename=" + UiUtlis.encoder(info.getFilename()) +
"&djr=" + UiUtlis.encoder(info.getDjr()) + "&xfid=" + UiUtlis.encoder(info.getXfid()), RequestMethod.POST);
xcjs.add(Contans.FILEPS, new FileBinary(new File(info.getPath())));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
xcjs.addHeader("Authorization", credential);
showLog(xcjs.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(1, xcjs, new HttpResponseListener<>(null, xcjs, callback, false, false, ""));
//NohttpUtils.getInstance().add(null, 1, xcjs, callback, false, false, "上传中...");
}
@ -405,6 +427,16 @@ public class UploadDataService extends IntentService {
Logger.v(ba.toString());
Request<String> baxc = NoHttp.createStringRequest(Contans.IP + Contans.BAXCJHSC + "?cjscr=" + UiUtlis.encoder((String) SPUtils.get(getApplicationContext(), Contans.NAME, "测试")), RequestMethod.POST);
baxc.setDefineRequestBodyForJson(UiUtlis.encoder(bajson));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
baxc.addHeader("Authorization", credential);
showLog(baxc.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(2, baxc, new HttpResponseListener<>(null, baxc, callback, false, false, ""));
//NohttpUtils.getInstance().add(null, 2, baxc, callback, false, false, "");
@ -418,6 +450,16 @@ public class UploadDataService extends IntentService {
Request<String> yhpc = NoHttp.createStringRequest(Contans.IP + Contans.YHPC + "?cjscr=" + UiUtlis.encoder((String) SPUtils.get(getApplicationContext(), Contans.NAME, "测试")), RequestMethod.POST);
String json1 = "{\"Rows\":" + GsonUtils.GsonString(info) + ",\"Total\": " + info.size() + "}";
yhpc.setDefineRequestBodyForJson(json1);
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
yhpc.addHeader("Authorization", credential);
showLog(yhpc.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(3, yhpc, new HttpResponseListener<>(null, yhpc, callback, false, false, ""));
//NohttpUtils.getInstance().add(null, 3, yhpc, callback, false, false, "");
}
@ -425,6 +467,16 @@ public class UploadDataService extends IntentService {
requestCount++;
Request<String> lyxc = NoHttp.createStringRequest(Contans.IP + Contans.LYXCSC + "?cjscr=" + UiUtlis.encoder((String) SPUtils.get(getApplicationContext(), Contans.NAME, "测试")), RequestMethod.POST);
lyxc.setDefineRequestBodyForJson(UiUtlis.encoder(lyjson));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
lyxc.addHeader("Authorization", credential);
showLog(lyxc.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(4, lyxc, new HttpResponseListener<>(null, lyxc, callback, false, false, ""));
//NohttpUtils.getInstance().add(null, 4, lyxc, callback, false, false, "");
@ -436,6 +488,16 @@ public class UploadDataService extends IntentService {
"&jhid=" + UiUtlis.encoder(lyinfo.getJhid()) + "&filename=" + UiUtlis.encoder(lyinfo.getFilename()) +
"&djr=" + UiUtlis.encoder(lyinfo.getDjr()) + "&xfid=" + UiUtlis.encoder(lyinfo.getXfid()), RequestMethod.POST);
xcjs.add(Contans.FILEPS, new FileBinary(new File(lyinfo.getPath())));
if(!TextUtils.isEmpty(tokenTemp)){
String token = RSAUtils.decryptBASE64StrLocal(tokenTemp);;
String credential = "Bearer " + token;
xcjs.addHeader("Authorization", credential);
showLog(xcjs.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
}
queue.add(5, xcjs, new HttpResponseListener<>(null, xcjs, callback, false, false, ""));
//NohttpUtils.getInstance().add(null, 5, xcjs, callback, false, false, "");
}

@ -7,6 +7,7 @@ import android.util.Log;
import com.example.administrator.zhapp.BuildConfig;
import com.example.administrator.zhapp.contans.Contans;
import com.google.gson.Gson;
import com.yolanda.nohttp.NoHttp;
import com.yolanda.nohttp.download.DownloadQueue;
import com.yolanda.nohttp.rest.Request;
@ -73,10 +74,10 @@ public class NohttpUtils {
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
if(!TextUtils.isEmpty(token)){
showLog(credential);
showLog(new Gson().toJson(request.headers()));
}
}
mQueue.add(what, request, new HttpResponseListener<T>(mActivity, request, callback, canCanel, isLoading, msg));
}
@ -89,10 +90,10 @@ public class NohttpUtils {
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
if(!TextUtils.isEmpty(token)){
showLog(credential);
showLog(new Gson().toJson(request.headers()));
}
}
mQueue.add(what, request, new HttpResponseListener<T>(mActivity, request, callback, true, true, "加载中..."));
}
@ -104,10 +105,10 @@ public class NohttpUtils {
String credential = "Bearer " + token;
request.addHeader("Authorization", credential);
showLog(request.url());
// if(!TextUtils.isEmpty(token)){
// showLog(credential);
// showLog(new Gson().toJson(request.headers()));
// }
if(!TextUtils.isEmpty(token)){
showLog(credential);
showLog(new Gson().toJson(request.headers()));
}
}
mQueue.add(what, request, new HttpResponseListenerNoProgress<T>(request, callback));
}

Loading…
Cancel
Save