|
|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
package com.rehome.zhdcoa.ui.activity;
|
|
|
|
|
|
|
|
|
|
import static com.rehome.zhdcoa.utils.GsonUtils.GsonToBean;
|
|
|
|
|
|
|
|
|
|
import android.Manifest;
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
import android.content.ContentValues;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
|
@ -19,8 +23,15 @@ import androidx.activity.result.contract.ActivityResultContracts;
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.App;
|
|
|
|
|
import com.rehome.zhdcoa.Contans;
|
|
|
|
|
import com.rehome.zhdcoa.DBModel.Ajhjh;
|
|
|
|
|
import com.rehome.zhdcoa.DBModel.AjhjhList;
|
|
|
|
|
import com.rehome.zhdcoa.DBModel.AjhjhxzrwList;
|
|
|
|
|
import com.rehome.zhdcoa.DBModel.XwaqgcJh;
|
|
|
|
|
import com.rehome.zhdcoa.DBModel.XwaqgcJhList;
|
|
|
|
|
import com.rehome.zhdcoa.DBModel.XwaqgcJs;
|
|
|
|
|
import com.rehome.zhdcoa.DBModel.XwaqgcSc;
|
|
|
|
|
import com.rehome.zhdcoa.R;
|
|
|
|
|
@ -31,13 +42,16 @@ import com.rehome.zhdcoa.entity.SbdjInfo;
|
|
|
|
|
import com.rehome.zhdcoa.entity.StatusInfo;
|
|
|
|
|
import com.rehome.zhdcoa.utils.GsonUtils;
|
|
|
|
|
import com.rehome.zhdcoa.utils.HttpListener;
|
|
|
|
|
import com.rehome.zhdcoa.utils.HttpResponseListener;
|
|
|
|
|
import com.rehome.zhdcoa.utils.NohttpUtils;
|
|
|
|
|
import com.rehome.zhdcoa.utils.SPUtils;
|
|
|
|
|
import com.rehome.zhdcoa.utils.UiUtlis;
|
|
|
|
|
import com.rehome.zhdcoa.weiget.WaitDialog;
|
|
|
|
|
import com.yolanda.nohttp.FileBinary;
|
|
|
|
|
import com.yolanda.nohttp.NoHttp;
|
|
|
|
|
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;
|
|
|
|
|
@ -45,6 +59,10 @@ import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import javax.net.ssl.HostnameVerifier;
|
|
|
|
|
import javax.net.ssl.SSLSession;
|
|
|
|
|
import javax.net.ssl.SSLSocketFactory;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by ruihong on 2017/10/28.
|
|
|
|
|
*/
|
|
|
|
|
@ -60,7 +78,7 @@ public class AxwaqgcglActivity extends BaseActivity2 {
|
|
|
|
|
private View headview;
|
|
|
|
|
private List<SbdjInfo> list;
|
|
|
|
|
private CommonAdapter<XwaqgcJh> adapter;
|
|
|
|
|
private List<XwaqgcJh> jhs;
|
|
|
|
|
private List<XwaqgcJh> jhs = new ArrayList<>();;
|
|
|
|
|
private CheckBox cb;
|
|
|
|
|
private int requestCount = 0;//请求数量
|
|
|
|
|
private int successCount = 0;//成功数量
|
|
|
|
|
@ -69,12 +87,15 @@ public class AxwaqgcglActivity extends BaseActivity2 {
|
|
|
|
|
private static final int CAMERA_REQUEST_CAMERA_SCAN = 7;//请求码
|
|
|
|
|
private ActivityResultLauncher<Intent> launcherResultQRCode;
|
|
|
|
|
|
|
|
|
|
private RequestQueue queue;
|
|
|
|
|
|
|
|
|
|
private void findView() {
|
|
|
|
|
lv = findViewById(R.id.lv);
|
|
|
|
|
btnSys = findViewById(R.id.btn_sys);
|
|
|
|
|
btnSc = findViewById(R.id.btn_sc);
|
|
|
|
|
btnXg = findViewById(R.id.btn_xg);
|
|
|
|
|
tvNodata = findViewById(R.id.tv_nodata);
|
|
|
|
|
queue = NoHttp.newRequestQueue(1);
|
|
|
|
|
btnSys.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
@ -123,12 +144,6 @@ public class AxwaqgcglActivity extends BaseActivity2 {
|
|
|
|
|
protected void initView() {
|
|
|
|
|
findView();
|
|
|
|
|
launcherResultQRCode = createQRCodeActivityResultLauncher();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void initData() {
|
|
|
|
|
|
|
|
|
|
jhs = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
initNFC();
|
|
|
|
|
setTitle("行为安全观察");
|
|
|
|
|
@ -159,10 +174,6 @@ public class AxwaqgcglActivity extends BaseActivity2 {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jhs.addAll(DataSupport.findAll(XwaqgcJh.class));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adapter = new CommonAdapter<XwaqgcJh>(context, R.layout.xzjh_item, jhs) {
|
|
|
|
|
@Override
|
|
|
|
|
protected void convert(ViewHolder viewHolder, XwaqgcJh item, final int position) {
|
|
|
|
|
@ -200,6 +211,100 @@ public class AxwaqgcglActivity extends BaseActivity2 {
|
|
|
|
|
lv.setAdapter(adapter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void initData() {
|
|
|
|
|
//如果数据库中有数据
|
|
|
|
|
if (DataSupport.count("XwaqgcJh") != 0) {
|
|
|
|
|
getDataInSQL();
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
}else{
|
|
|
|
|
requestData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void getDataInSQL() {
|
|
|
|
|
jhs.clear();
|
|
|
|
|
jhs.addAll(DataSupport.findAll(XwaqgcJh.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void requestData() {
|
|
|
|
|
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.XWAQGC);
|
|
|
|
|
request.add("gh", App.getInstance().getUserInfo().getManid());
|
|
|
|
|
if(App.getInstance().getUserInfo()!=null&&App.getInstance().getUserInfo().getToken()!=null){
|
|
|
|
|
String token = App.getInstance().getUserInfo().getToken();
|
|
|
|
|
String credential = "Bearer " + token;
|
|
|
|
|
request.addHeader("Authorization", credential);
|
|
|
|
|
showLog(request.url());
|
|
|
|
|
}
|
|
|
|
|
if(!TextUtils.isEmpty(request.url())){
|
|
|
|
|
String url =request.url();
|
|
|
|
|
if(url.startsWith("https://219.131.195.3:7100")||url.startsWith("https://219.131.195.3:7011")||url.startsWith("https://219.131.195.3:7081")||url.startsWith("https://219.131.195.3:7082")){
|
|
|
|
|
SSLSocketFactory socketFactory = NohttpUtils.getSSLSocketFactory(AxwaqgcglActivity.this);
|
|
|
|
|
if (socketFactory != null) {
|
|
|
|
|
request.setSSLSocketFactory(socketFactory);
|
|
|
|
|
request.setHostnameVerifier(new HostnameVerifier() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean verify(String s, SSLSession sslSession) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
queue.add(0, request, new HttpResponseListener<>(AxwaqgcglActivity.this, request, new HttpListener<String>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSucceed(int what, Response<String> response) {
|
|
|
|
|
|
|
|
|
|
if (what == 0) {
|
|
|
|
|
showLog("------行为安全观察------");
|
|
|
|
|
String resutl = response.get();
|
|
|
|
|
showLog("------result------");
|
|
|
|
|
//行为安全观察
|
|
|
|
|
XwaqgcJhList xwaq = GsonToBean(resutl, XwaqgcJhList.class);
|
|
|
|
|
showLog(GsonUtils.GsonString(xwaq));
|
|
|
|
|
if (xwaq != null) {
|
|
|
|
|
if (xwaq.getTotal() != 0) {
|
|
|
|
|
List<XwaqgcJh> jhs = new ArrayList<>();
|
|
|
|
|
jhs.addAll(xwaq.getRows());
|
|
|
|
|
DataSupport.deleteAll(XwaqgcJh.class);
|
|
|
|
|
int dbcount = -1;//数据库中是否有数据
|
|
|
|
|
for (XwaqgcJh jh : jhs) {
|
|
|
|
|
List<XwaqgcJh> dbdjjh = DataSupport.where("jhid=?", jh.getJHID()).find(XwaqgcJh.class);
|
|
|
|
|
//如果数据库中没有这要数据,就添加
|
|
|
|
|
if (dbdjjh.size() == 0) {
|
|
|
|
|
dbcount = 1;
|
|
|
|
|
jh.save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbcount == 1) {
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
|
intent.putExtra("isTask", true);
|
|
|
|
|
intent.setAction("com.rehome.zhdcoa.RECEIVER");
|
|
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
DataSupport.deleteAll(XwaqgcJh.class);
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
|
intent.putExtra("isTask", false);
|
|
|
|
|
intent.setAction("com.rehome.zhdcoa.RECEIVER");
|
|
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
|
|
|
|
|
}
|
|
|
|
|
getDataInSQL();
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailed(int what, Response<String> response) {
|
|
|
|
|
if (dialog != null && dialog.isShowing()) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, true, true, "加载中..."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//上传数据
|
|
|
|
|
private void uploadData() {
|
|
|
|
|
|
|
|
|
|
|