Commit 8e25ba8f authored by chenyuling's avatar chenyuling

"将比对id改成转化为名字"

parent 9931be08
Pipeline #1848 canceled with stages
package com.srthinker.statinfo.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.srthinker.statinfo.bean.StatusInfoBean;
import com.srthinker.statinfo.constant.InOutType;
import com.srthinker.statinfo.databinding.ItemPortStatusBinding;
import java.util.List;
public class DePortStatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final Context context;
private final List<StatusInfoBean> statusInfoBeans;
private String deviceType;
public DePortStatusAdapter(Context context, List<StatusInfoBean> statusInfoBeans){
this.context = context;
this.statusInfoBeans = statusInfoBeans;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ItemPortStatusBinding binding = ItemPortStatusBinding.inflate(LayoutInflater.from(context), parent, false);
return new ItemHolder(binding);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
ItemHolder itemHolder = (ItemHolder) holder;
StatusInfoBean statusInfoBean = statusInfoBeans.get(position);
if (statusInfoBean != null) {
if (statusInfoBean.getDevice_type()== InOutType.ENTER_TYPE){
deviceType = "进入的设备--";
}else if (statusInfoBean.getDevice_type() == InOutType.LEAVE_TYPE){
deviceType = "出去的设备--";
}
String desc = statusInfoBean.getTime()+" "+deviceType+statusInfoBean.getInfo();
itemHolder.mBinding.tvStatusInfo.setText(desc);
}
}
@Override
public int getItemCount() {
return statusInfoBeans!=null&&statusInfoBeans.size()>0?statusInfoBeans.size():0;
}
private static class ItemHolder extends RecyclerView.ViewHolder {
private final com.srthinker.statinfo.databinding.ItemPortStatusBinding mBinding;
public ItemHolder(ItemPortStatusBinding binding) {
super(binding.getRoot());
mBinding = binding;
}
}
}
package com.srthinker.statinfo.bean;
import java.util.Objects;
public class StatusInfoBean {
private String id;
private String info;
private String time;
private int device_type;
public StatusInfoBean( String time, String info,int device_type) {
this.info = info;
this.time = time;
this.device_type = device_type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public int getDevice_type() {
return device_type;
}
public void setDevice_type(int device_type) {
this.device_type = device_type;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StatusInfoBean that = (StatusInfoBean) o;
return device_type == that.device_type && Objects.equals(id, that.id) && Objects.equals(info, that.info) && Objects.equals(time, that.time);
}
@Override
public int hashCode() {
return Objects.hash(id, info, time, device_type);
}
@Override
public String toString() {
return "StatusInfoBean{" +
"id='" + id + '\'' +
", info='" + info + '\'' +
", time='" + time + '\'' +
", device_type=" + device_type +
'}';
}
}
...@@ -51,25 +51,37 @@ public class PersonMgr { ...@@ -51,25 +51,37 @@ public class PersonMgr {
//如果都有 //如果都有
//给从接口获取新的数据之前有分过组的数据写分组的信息,已经被删除的人员也要删除掉 //给从接口获取新的数据之前有分过组的数据写分组的信息,已经被删除的人员也要删除掉
ArrayList<PersonEntity> needDelPersons = new ArrayList<>(); ArrayList<PersonEntity> needDelPersons = new ArrayList<>();
int equal_name = 0;
for (PersonEntity queryPerson : queryPersons) { for (PersonEntity queryPerson : queryPersons) {
String queryId = queryPerson.getId(); String queryId = queryPerson.getId();
String query_name = queryPerson.getPerson_name();
boolean isFound = false; boolean isFound = false;
for (PersonEntity newPersonEntity : personEntities) { for (PersonEntity newPersonEntity : personEntities) {
String newId = newPersonEntity.getId(); String newId = newPersonEntity.getId();
if (TextUtils.equals(queryId,newId)){ String newPersonName = newPersonEntity.getPerson_name();
/*if (TextUtils.equals(queryId,newId)){
newPersonEntity.setGroup(queryPerson.getGroup());
isFound = true;
break;
}*/
//根据名字进行分组
if (TextUtils.equals(query_name,newPersonName)){
query_name +=1;
newPersonEntity.setGroup(queryPerson.getGroup()); newPersonEntity.setGroup(queryPerson.getGroup());
isFound = true; isFound = true;
break; break;
} }
} }
if (!isFound){ /*if (!isFound){
needDelPersons.add(queryPerson); needDelPersons.add(queryPerson);
}*/
} }
} Log.i(TAG, "updatePerson: 和已分配的相同名字的总数="+equal_name);
if (personHelper != null) { if (personHelper != null) {
personHelper.delete(queryPersons);
personHelper.save(personEntities); personHelper.save(personEntities);
Log.i(TAG, "updatePerson: needDelPersons.size()="+needDelPersons.size()); /*Log.i(TAG, "updatePerson: needDelPersons.size()="+needDelPersons.size());
personHelper.delete(needDelPersons); personHelper.delete(needDelPersons);*/
} }
} }
...@@ -111,9 +123,17 @@ public class PersonMgr { ...@@ -111,9 +123,17 @@ public class PersonMgr {
List<PersonEntity> needUpdate = new ArrayList<>(); List<PersonEntity> needUpdate = new ArrayList<>();
for (PersonEntity personEntity : personEntities) { for (PersonEntity personEntity : personEntities) {
String personId = personEntity.getId(); String personId = personEntity.getId();
String person_name = personEntity.getPerson_name();
for (PersonEntity queryPerson : queryPersons) { for (PersonEntity queryPerson : queryPersons) {
String queryId = queryPerson.getId(); String queryId = queryPerson.getId();
if (TextUtils.equals(personId,queryId)){ String queryName = queryPerson.getPerson_name();
/*if (TextUtils.equals(personId,queryId)){
queryPerson.setGroup(personEntity.getGroup());
needUpdate.add(queryPerson);
break;
}*/
//根据名字进行分组
if (TextUtils.equals(person_name,queryName)){
queryPerson.setGroup(personEntity.getGroup()); queryPerson.setGroup(personEntity.getGroup());
needUpdate.add(queryPerson); needUpdate.add(queryPerson);
break; break;
......
package com.srthinker.statinfo.listener;
public interface DevicePortCallback {
void getDevicePortStatus(String time,String info);
}
package com.srthinker.statinfo.listener.upper;
import com.srthinker.statinfo.bean.StatusInfoBean;
public interface UpperDevicesPortCallback {
void onDevicesPort(StatusInfoBean statusInfoBean);
}
...@@ -16,6 +16,7 @@ import com.srthinker.statinfo.api.kuangshi.client.ApiClientException; ...@@ -16,6 +16,7 @@ import com.srthinker.statinfo.api.kuangshi.client.ApiClientException;
import com.srthinker.statinfo.api.kuangshi.client.DefaultApiClient; import com.srthinker.statinfo.api.kuangshi.client.DefaultApiClient;
import com.srthinker.statinfo.database.entity.PersonEntity; import com.srthinker.statinfo.database.entity.PersonEntity;
import com.srthinker.statinfo.listener.DeviceCallback; import com.srthinker.statinfo.listener.DeviceCallback;
import com.srthinker.statinfo.listener.DevicePortCallback;
import com.srthinker.statinfo.listener.QueryPersonCallback; import com.srthinker.statinfo.listener.QueryPersonCallback;
import com.srthinker.statinfo.util.common.DateUtil; import com.srthinker.statinfo.util.common.DateUtil;
import com.srthinker.statinfo.util.common.ThreadPool; import com.srthinker.statinfo.util.common.ThreadPool;
...@@ -48,6 +49,7 @@ public class ApiManager { ...@@ -48,6 +49,7 @@ public class ApiManager {
private PersonApiImpl personApi; private PersonApiImpl personApi;
private boolean lastConnect = false; private boolean lastConnect = false;
private QueryPersonCallback queryPersonsCallback; private QueryPersonCallback queryPersonsCallback;
private DevicePortCallback devicePortCallback;
public ApiManager(String username, String password, String serverIp,int type){ public ApiManager(String username, String password, String serverIp,int type){
...@@ -74,6 +76,10 @@ public class ApiManager { ...@@ -74,6 +76,10 @@ public class ApiManager {
this.queryPersonsCallback = queryPersonsCallback; this.queryPersonsCallback = queryPersonsCallback;
} }
public void setOnDevicePortCallback(DevicePortCallback devicePortCallback){
this.devicePortCallback = devicePortCallback;
}
public void start(){ public void start(){
isRunning = true; isRunning = true;
isFirstStatus = true; isFirstStatus = true;
...@@ -100,6 +106,9 @@ public class ApiManager { ...@@ -100,6 +106,9 @@ public class ApiManager {
//登录出错,打印错误信息 //登录出错,打印错误信息
System.out.println(JSONObject.toJSONString(loginResp)); System.out.println(JSONObject.toJSONString(loginResp));
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),JSONObject.toJSONString(loginResp));
}
return; return;
} }
sessionId = loginResp.getSessionId(); sessionId = loginResp.getSessionId();
...@@ -114,13 +123,18 @@ public class ApiManager { ...@@ -114,13 +123,18 @@ public class ApiManager {
} }
}catch (ApiClientException e2){ }catch (ApiClientException e2){
updateLastConnect(false); updateLastConnect(false);
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),"authRunnable:"+serverIp+"--e2-->"+e2.getMessage());
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
updateLastConnect(false); updateLastConnect(false);
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),"authRunnable:"+serverIp+"--e-->"+e.getMessage());
}
Log.i(TAG, "run: authRunnable抛异常:ip="+serverIp); Log.i(TAG, "run: authRunnable抛异常:ip="+serverIp);
if (isRunning){ if (isRunning){
handler.postDelayed(authThreadRunnable,2000); handler.postDelayed(authThreadRunnable,10000);
} }
} }
} }
...@@ -229,6 +243,7 @@ public class ApiManager { ...@@ -229,6 +243,7 @@ public class ApiManager {
PersonEntity passBean = new PersonEntity(); PersonEntity passBean = new PersonEntity();
passBean.setId(dataBean.getPerson_id()); passBean.setId(dataBean.getPerson_id());
passBean.setPerson_name(dataBean.getPerson_name()); passBean.setPerson_name(dataBean.getPerson_name());
//String id_number = dataBean.getId_number();
String timestamp = dataBean.getTimestamp(); String timestamp = dataBean.getTimestamp();
String timeString = DateUtil.zoneToDateString(timestamp, "HH:mm"); String timeString = DateUtil.zoneToDateString(timestamp, "HH:mm");
passBean.setTimestamp(timeString); passBean.setTimestamp(timeString);
...@@ -250,9 +265,15 @@ public class ApiManager { ...@@ -250,9 +265,15 @@ public class ApiManager {
} }
} catch (ApiClientException e2){ } catch (ApiClientException e2){
updateLastConnect(false); updateLastConnect(false);
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),"passRecordRunnable:"+serverIp+"--e2-->"+e2.getMessage());
}
} catch (Exception e) { } catch (Exception e) {
Log.i(TAG, "run: passRecordRunnable抛异常"); Log.i(TAG, "run: passRecordRunnable抛异常");
updateLastConnect(false); updateLastConnect(false);
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),"passRecordRunnable:"+serverIp+"--e-->"+e.getMessage());
}
e.printStackTrace(); e.printStackTrace();
} }
...@@ -301,6 +322,9 @@ public class ApiManager { ...@@ -301,6 +322,9 @@ public class ApiManager {
PersonEntity personEntity = new PersonEntity(); PersonEntity personEntity = new PersonEntity();
personEntity.setId(personData.getId()); personEntity.setId(personData.getId());
personEntity.setPerson_name(personData.getPerson_name()); personEntity.setPerson_name(personData.getPerson_name());
//String id_number = DigestUtils.aesDecrypt(personData.getId_number(), sessionId);
//Log.i(TAG, "queryPerson: id_number="+id_number);
//personEntity.setId_number(id_number);
personEntities.add(personEntity); personEntities.add(personEntity);
} }
totalPersonLists.addAll(personEntities); totalPersonLists.addAll(personEntities);
......
...@@ -5,12 +5,14 @@ import static com.srthinker.statinfo.constant.InOutType.LEAVE_TYPE; ...@@ -5,12 +5,14 @@ import static com.srthinker.statinfo.constant.InOutType.LEAVE_TYPE;
import android.util.Log; import android.util.Log;
import com.srthinker.statinfo.bean.StatusInfoBean;
import com.srthinker.statinfo.database.entity.ConfigEntity; import com.srthinker.statinfo.database.entity.ConfigEntity;
import com.srthinker.statinfo.database.entity.PersonEntity; import com.srthinker.statinfo.database.entity.PersonEntity;
import com.srthinker.statinfo.database.helper.ConfigHelper; import com.srthinker.statinfo.database.helper.ConfigHelper;
import com.srthinker.statinfo.listener.DeviceCallback; import com.srthinker.statinfo.listener.DeviceCallback;
import com.srthinker.statinfo.listener.QueryPersonCallback; import com.srthinker.statinfo.listener.QueryPersonCallback;
import com.srthinker.statinfo.listener.upper.UpperDevicesCallback; import com.srthinker.statinfo.listener.upper.UpperDevicesCallback;
import com.srthinker.statinfo.listener.upper.UpperDevicesPortCallback;
import com.srthinker.statinfo.util.common.ThreadPool; import com.srthinker.statinfo.util.common.ThreadPool;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -34,6 +36,7 @@ public class ApiQuest { ...@@ -34,6 +36,7 @@ public class ApiQuest {
private static LinkedHashMap<String,ApiManager> enterMgrHashMap = new LinkedHashMap<>(); private static LinkedHashMap<String,ApiManager> enterMgrHashMap = new LinkedHashMap<>();
private static LinkedHashMap<String,ApiManager> leaveMgrHashMap = new LinkedHashMap<>(); private static LinkedHashMap<String,ApiManager> leaveMgrHashMap = new LinkedHashMap<>();
private String oneEnterIp; private String oneEnterIp;
private UpperDevicesPortCallback upperDevicesPortCallback;
public static ApiQuest getInstance(){ public static ApiQuest getInstance(){
if (apiQuest == null) { if (apiQuest == null) {
...@@ -48,6 +51,10 @@ public class ApiQuest { ...@@ -48,6 +51,10 @@ public class ApiQuest {
this.upperDevicesCallback = upperDevicesCallback; this.upperDevicesCallback = upperDevicesCallback;
} }
public void setOnUpperDevicesPortCallback(UpperDevicesPortCallback upperDevicesPortCallback){
this.upperDevicesPortCallback = upperDevicesPortCallback;
}
private void initData(int type){ private void initData(int type){
if (type==ENTER_TYPE){ if (type==ENTER_TYPE){
isEnterAllConnect = false; isEnterAllConnect = false;
...@@ -96,6 +103,12 @@ public class ApiQuest { ...@@ -96,6 +103,12 @@ public class ApiQuest {
ApiManager enterMgr = new ApiManager(username, password, ip, ENTER_TYPE); ApiManager enterMgr = new ApiManager(username, password, ip, ENTER_TYPE);
enterMgrHashMap.put(ip,enterMgr); enterMgrHashMap.put(ip,enterMgr);
enterMgr.start(); enterMgr.start();
enterMgr.setOnDevicePortCallback((time, info) -> {
StatusInfoBean statusInfoBean = new StatusInfoBean(time, info,ENTER_TYPE);
if (upperDevicesPortCallback != null) {
upperDevicesPortCallback.onDevicesPort(statusInfoBean);
}
});
enterMgr.setOnDeviceCallback(new DeviceCallback() { enterMgr.setOnDeviceCallback(new DeviceCallback() {
@Override @Override
public void getPassInfo(List<PersonEntity> passEntities, int type) { public void getPassInfo(List<PersonEntity> passEntities, int type) {
...@@ -137,13 +150,14 @@ public class ApiQuest { ...@@ -137,13 +150,14 @@ public class ApiQuest {
isEnterAllConnect = true; isEnterAllConnect = true;
synchronized (enterList){ synchronized (enterList){
for (ConfigEntity config : enterList) { for (ConfigEntity config : enterList) {
//Log.i(TAG, "onConnectStatus: 数据库里面的数据:ip="+config.getServerIp()+",isConnect="+config.isConnect()); //Log.i(TAG, "onConnectStatus: 数据库里面的数据:ip="+config.getServerIp()+",isConnect="+config.isConnect()+",id="+config.getId()+",type="+config.getType());
boolean connect = config.isConnect(); boolean connect = config.isConnect();
if (!connect){ if (!connect){
isEnterAllConnect = false; isEnterAllConnect = false;
break; break;
} }
} }
//Log.i(TAG, "onConnectStatus: isEnterAllConnect="+isEnterAllConnect);
if (upperDevicesCallback != null) { if (upperDevicesCallback != null) {
upperDevicesCallback.onAllConnectStatus(isEnterAllConnect,type); upperDevicesCallback.onAllConnectStatus(isEnterAllConnect,type);
} }
...@@ -165,6 +179,12 @@ public class ApiQuest { ...@@ -165,6 +179,12 @@ public class ApiQuest {
ApiManager leaveMgr = new ApiManager(username, password, ip, LEAVE_TYPE); ApiManager leaveMgr = new ApiManager(username, password, ip, LEAVE_TYPE);
leaveMgrHashMap.put(ip,leaveMgr); leaveMgrHashMap.put(ip,leaveMgr);
leaveMgr.start(); leaveMgr.start();
leaveMgr.setOnDevicePortCallback((time, info) -> {
StatusInfoBean statusInfoBean = new StatusInfoBean(time, info,LEAVE_TYPE);
if (upperDevicesPortCallback != null) {
upperDevicesPortCallback.onDevicesPort(statusInfoBean);
}
});
leaveMgr.setOnDeviceCallback(new DeviceCallback() { leaveMgr.setOnDeviceCallback(new DeviceCallback() {
@Override @Override
public void getPassInfo(List<PersonEntity> passEntities, int type) { public void getPassInfo(List<PersonEntity> passEntities, int type) {
...@@ -236,6 +256,7 @@ public class ApiQuest { ...@@ -236,6 +256,7 @@ public class ApiQuest {
} }
public boolean queryPersons(QueryPersonCallback callback){ public boolean queryPersons(QueryPersonCallback callback){
Log.i(TAG, "queryPersons: enterMgrHashMap.size="+enterMgrHashMap.size());
if (enterMgrHashMap.size()>0){ if (enterMgrHashMap.size()>0){
ApiManager oneEnterMgr = enterMgrHashMap.get(oneEnterIp); ApiManager oneEnterMgr = enterMgrHashMap.get(oneEnterIp);
if (oneEnterMgr != null) { if (oneEnterMgr != null) {
......
...@@ -6,14 +6,14 @@ import java.util.ArrayList; ...@@ -6,14 +6,14 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class StatSize { public class StatSize {
//id和时间相同的进行去重过滤 //名字和时间相同的进行去重过滤
public static List<PersonEntity> filterList(List<PersonEntity> personEntityList){ public static List<PersonEntity> filterList(List<PersonEntity> personEntityList){
List<PersonEntity> filterPersonList = new ArrayList<>(); List<PersonEntity> filterPersonList = new ArrayList<>();
if (personEntityList != null) { if (personEntityList != null) {
for (PersonEntity personEntity : personEntityList) { for (PersonEntity personEntity : personEntityList) {
boolean shouldAdd = true; boolean shouldAdd = true;
for (PersonEntity entity : filterPersonList) { for (PersonEntity entity : filterPersonList) {
if (equals(personEntity.getId(),entity.getId())&&equals(personEntity.getTimestamp(),entity.getTimestamp())){ if (equals(personEntity.getPerson_name(),entity.getPerson_name())&&equals(personEntity.getTimestamp(),entity.getTimestamp())){
shouldAdd = false; shouldAdd = false;
break; break;
} }
......
...@@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.srthinker.statinfo.adapter.GroupShowAdapter; import com.srthinker.statinfo.adapter.GroupShowAdapter;
import com.srthinker.statinfo.bean.Group2Bean; import com.srthinker.statinfo.bean.Group2Bean;
import com.srthinker.statinfo.bean.StatusInfoBean;
import com.srthinker.statinfo.constant.GroupConst; import com.srthinker.statinfo.constant.GroupConst;
import com.srthinker.statinfo.database.entity.ConfigEntity; import com.srthinker.statinfo.database.entity.ConfigEntity;
import com.srthinker.statinfo.database.entity.PersonEntity; import com.srthinker.statinfo.database.entity.PersonEntity;
...@@ -31,6 +32,7 @@ import com.srthinker.statinfo.databinding.ActivityNewMainBinding; ...@@ -31,6 +32,7 @@ import com.srthinker.statinfo.databinding.ActivityNewMainBinding;
import com.srthinker.statinfo.download.upper.DownloadViewModel; import com.srthinker.statinfo.download.upper.DownloadViewModel;
import com.srthinker.statinfo.download.upper.UpperDownloadCallback; import com.srthinker.statinfo.download.upper.UpperDownloadCallback;
import com.srthinker.statinfo.listener.upper.UpperDevicesCallback; import com.srthinker.statinfo.listener.upper.UpperDevicesCallback;
import com.srthinker.statinfo.listener.upper.UpperDevicesPortCallback;
import com.srthinker.statinfo.presenter.ApiQuest; import com.srthinker.statinfo.presenter.ApiQuest;
import com.srthinker.statinfo.presenter.StatSize; import com.srthinker.statinfo.presenter.StatSize;
import com.srthinker.statinfo.uis.news.SettingActivity; import com.srthinker.statinfo.uis.news.SettingActivity;
...@@ -52,7 +54,7 @@ import java.util.HashMap; ...@@ -52,7 +54,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPChangeCallback, UpperDevicesCallback, MDownloadCallBack, UpperDownloadCallback { public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPChangeCallback, UpperDevicesCallback, MDownloadCallBack, UpperDownloadCallback, UpperDevicesPortCallback {
private static final String TAG = "NewMainActivity"; private static final String TAG = "NewMainActivity";
private com.srthinker.statinfo.databinding.ActivityNewMainBinding mBinding; private com.srthinker.statinfo.databinding.ActivityNewMainBinding mBinding;
...@@ -104,6 +106,7 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC ...@@ -104,6 +106,7 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
Intent intent = new Intent(this, SettingActivity.class); Intent intent = new Intent(this, SettingActivity.class);
startActivity(intent); startActivity(intent);
}); });
mLoadDialog = new LoadDialog(this); //1.0.2版本把这个漏了
} }
/*private void initGroup() { /*private void initGroup() {
...@@ -186,6 +189,7 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC ...@@ -186,6 +189,7 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
Log.i(TAG, "onDestroy: Main--destroy"); Log.i(TAG, "onDestroy: Main--destroy");
networkIPMonitor.stopMonitoring(); networkIPMonitor.stopMonitoring();
ApiQuest.getInstance().stopApi(); ApiQuest.getInstance().stopApi();
clearStatusInfoBeans();
super.onDestroy(); super.onDestroy();
} }
...@@ -199,15 +203,22 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC ...@@ -199,15 +203,22 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
private void questApi() { private void questApi() {
List<ConfigEntity> enterConfigList = ConfigHelper.getInstance().queryByType(ENTER_TYPE); List<ConfigEntity> enterConfigList = ConfigHelper.getInstance().queryByType(ENTER_TYPE);
ApiQuest.getInstance().startApi(enterConfigList,ENTER_TYPE); ApiQuest.getInstance().startApi(enterConfigList,ENTER_TYPE);
ApiQuest.getInstance().setOnUpperDevicesCallback(this);
List<ConfigEntity> leaveConfigList = ConfigHelper.getInstance().queryByType(LEAVE_TYPE); List<ConfigEntity> leaveConfigList = ConfigHelper.getInstance().queryByType(LEAVE_TYPE);
ApiQuest.getInstance().startApi(leaveConfigList,LEAVE_TYPE); ApiQuest.getInstance().startApi(leaveConfigList,LEAVE_TYPE);
ApiQuest.getInstance().setOnUpperDevicesCallback(this); ApiQuest.getInstance().setOnUpperDevicesCallback(this);
ApiQuest.getInstance().setOnUpperDevicesPortCallback(this);
} }
@Override @Override
public void OnIPLost(String error) { public void OnIPLost(String error) {
ApiQuest.getInstance().stopApi(); ApiQuest.getInstance().stopApi();
//修改状态
List<ConfigEntity> configEntities = ConfigHelper.getInstance().queryAll();
for (ConfigEntity configEntity : configEntities) {
configEntity.setConnect(false);
//更新ip接口状态
ConfigHelper.getInstance().update(configEntity);
}
} }
@Override @Override
...@@ -219,21 +230,22 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC ...@@ -219,21 +230,22 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
@Override @Override
public void onAllConnectStatus(boolean hasConnect, int type) { public void onAllConnectStatus(boolean hasConnect, int type) {
HashMap<String, Boolean> devicesConnect = MyApplication.getInstance().devicesConnect; /*HashMap<String, Boolean> devicesConnect = MyApplication.getInstance().devicesConnect;
if (type==ENTER_TYPE){ if (type==ENTER_TYPE){
devicesConnect.put("enter_connect",hasConnect); devicesConnect.put("enter_connect",hasConnect);
// SharedUtil.getInstance(this).writeShared("enter_connect",hasConnect); // SharedUtil.getInstance(this).writeShared("enter_connect",hasConnect);
}else if (type==LEAVE_TYPE){ }else if (type==LEAVE_TYPE){
// SharedUtil.getInstance(this).writeShared("leave_connect",hasConnect); // SharedUtil.getInstance(this).writeShared("leave_connect",hasConnect);
devicesConnect.put("leave_connect",hasConnect); devicesConnect.put("leave_connect",hasConnect);
} }*/
} }
private void updatePassInfo(List<PersonEntity> passEntities, int type) { private void updatePassInfo(List<PersonEntity> passEntities, int type) {
Log.i(TAG, "updatePassInfo: 获取的总数="+passEntities.size()); Log.i(TAG, "updatePassInfo: 获取的总数="+passEntities.size());
/*for (PersonEntity passEntity : passEntities) { Log.i(TAG, "updatePassInfo: 进还是出="+type);
for (PersonEntity passEntity : passEntities) {
Log.i(TAG, "updatePassInfo: 获取到的name="+passEntity.getPerson_name()); Log.i(TAG, "updatePassInfo: 获取到的name="+passEntity.getPerson_name());
}*/ }
if (type ==ENTER_TYPE){ if (type ==ENTER_TYPE){
if (passEntities != null) { if (passEntities != null) {
int size = passEntities.size(); int size = passEntities.size();
...@@ -312,10 +324,13 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC ...@@ -312,10 +324,13 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
} }
for (PersonEntity personEntity : personEntityList) { for (PersonEntity personEntity : personEntityList) {
String personId = personEntity.getId(); String personId = personEntity.getId();
String personName = personEntity.getPerson_name();
for (PersonEntity queryPerson : mQueryPersonList) { for (PersonEntity queryPerson : mQueryPersonList) {
String queryId = queryPerson.getId(); String queryId = queryPerson.getId();
String queryName = queryPerson.getPerson_name();
int group = queryPerson.getGroup(); int group = queryPerson.getGroup();
if (TextUtils.equals(personId,queryId)&& groupSizeHashMap.containsKey(group)){ //改成对比名字
if (TextUtils.equals(personName,queryName)&& groupSizeHashMap.containsKey(group)){
int totalSize = groupSizeHashMap.get(group); int totalSize = groupSizeHashMap.get(group);
groupSizeHashMap.put(group,totalSize+1); groupSizeHashMap.put(group,totalSize+1);
} }
...@@ -467,4 +482,17 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC ...@@ -467,4 +482,17 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
} }
}); });
} }
public List<StatusInfoBean> statusInfoBeans = new ArrayList<>();
@Override
public void onDevicesPort(StatusInfoBean statusInfoBean) {
//Log.i(TAG, "onDevicesPort: statusInfoBean="+statusInfoBean.toString());
statusInfoBeans.add(0,statusInfoBean);
SharedUtil.getInstance(this).writeShared("statusInfoBeans",statusInfoBeans);
}
private void clearStatusInfoBeans(){
statusInfoBeans.clear();
SharedUtil.getInstance(this).writeShared("statusInfoBeans",statusInfoBeans);
}
} }
\ No newline at end of file
...@@ -10,7 +10,6 @@ public class MyApplication extends Application { ...@@ -10,7 +10,6 @@ public class MyApplication extends Application {
private static MyApplication application; private static MyApplication application;
//声明一个公共的变量,存储网络状态 //声明一个公共的变量,存储网络状态
public HashMap<String,Boolean> devicesConnect = new HashMap<>(); public HashMap<String,Boolean> devicesConnect = new HashMap<>();
// 1秒钟后重启应用 // 1秒钟后重启应用
private int time = 1000; private int time = 1000;
......
...@@ -291,7 +291,7 @@ public class ConfigDlgFragment extends DialogFragment { ...@@ -291,7 +291,7 @@ public class ConfigDlgFragment extends DialogFragment {
Window window = getDialog().getWindow(); Window window = getDialog().getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//window.setLayout(Utils.dip2px(context,280),ViewGroup.LayoutParams.WRAP_CONTENT); //window.setLayout(Utils.dip2px(context,280),ViewGroup.LayoutParams.WRAP_CONTENT);
window.setLayout(Utils.dip2px(context,280), (int) (Utils.getScreenHeight(context)*0.6)); window.setLayout(Utils.dip2px(context,320), (int) (Utils.getScreenHeight(context)*0.6));
window.setGravity(Gravity.CENTER); window.setGravity(Gravity.CENTER);
KeyBoardUtil.initSoftInputListener(getDialog()); KeyBoardUtil.initSoftInputListener(getDialog());
} }
......
package com.srthinker.statinfo.uis.news;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.srthinker.statinfo.adapter.DePortStatusAdapter;
import com.srthinker.statinfo.bean.StatusInfoBean;
import com.srthinker.statinfo.databinding.DialogPortStatusBinding;
import com.srthinker.statinfo.util.common.KeyBoardUtil;
import com.srthinker.statinfo.util.common.SharedUtil;
import com.srthinker.statinfo.util.common.Utils;
import java.util.List;
public class DePortStatusDlgFragment extends DialogFragment {
private Context context;
private com.srthinker.statinfo.databinding.DialogPortStatusBinding mBinding;
private FragmentActivity activity;
private DePortStatusAdapter adapter;
private static final String TAG = "dpsDlaFragment";
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
context = getContext();
activity = getActivity();
mBinding = DialogPortStatusBinding.inflate(inflater, container, false);
initData();
initView();
return mBinding.getRoot();
}
private void initData() {
deHandler.post(DePortStatusRunnable);
}
private void initView() {
mBinding.ivClose.setOnClickListener(v->{
dismiss();
});
LinearLayoutManager layoutManager = new LinearLayoutManager(context);
mBinding.rvPortStatus.setLayoutManager(layoutManager);
adapter = new DePortStatusAdapter(context, statusInfoBeans);
mBinding.rvPortStatus.setAdapter(adapter);
}
@Override
public void onResume() {
super.onResume();
initWindow();
}
private void initWindow() {
Window window = getDialog().getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//window.setLayout(Utils.dip2px(context,280),ViewGroup.LayoutParams.WRAP_CONTENT);
window.setLayout((int) (Utils.getScreenWidth(context)*0.7), (int) (Utils.getScreenHeight(context)*0.6));
window.setGravity(Gravity.CENTER);
KeyBoardUtil.initSoftInputListener(getDialog());
}
private Handler deHandler = new Handler();
private List<StatusInfoBean> statusInfoBeans;
private Runnable DePortStatusRunnable = new Runnable(){
@Override
public void run() {
statusInfoBeans = SharedUtil.getInstance(context).readSharedList("statusInfoBeans", StatusInfoBean.class, null);
for (StatusInfoBean statusInfoBean : statusInfoBeans) {
Log.i(TAG, "run: statusInfoBean="+statusInfoBean.toString());
}
updateStatus();
deHandler.postDelayed(this,1000);
}
};
private void updateStatus() {
activity.runOnUiThread(() -> {
if (adapter != null) {
adapter.notifyDataSetChanged();
}
});
}
@Override
public void onDestroyView() {
deHandler.removeCallbacks(DePortStatusRunnable);
super.onDestroyView();
}
}
...@@ -2,25 +2,12 @@ package com.srthinker.statinfo.uis.news; ...@@ -2,25 +2,12 @@ package com.srthinker.statinfo.uis.news;
import static com.srthinker.statinfo.constant.Const.DEVICE_SN; import static com.srthinker.statinfo.constant.Const.DEVICE_SN;
import static com.srthinker.statinfo.constant.Const.DEVICE_TYPE; import static com.srthinker.statinfo.constant.Const.DEVICE_TYPE;
import static com.srthinker.statinfo.constant.GroupConst.BUILD;
import static com.srthinker.statinfo.constant.GroupConst.BUILD_ID;
import static com.srthinker.statinfo.constant.GroupConst.OUTRIGGER;
import static com.srthinker.statinfo.constant.GroupConst.OUTRIGGER_ID;
import static com.srthinker.statinfo.constant.GroupConst.SUPERVISOR;
import static com.srthinker.statinfo.constant.GroupConst.SUPERVISOR_ID;
import static com.srthinker.statinfo.constant.GroupConst.WATERPROOF;
import static com.srthinker.statinfo.constant.GroupConst.WATERPROOF_ID;
import static com.srthinker.statinfo.constant.InOutType.ENTER_TYPE; import static com.srthinker.statinfo.constant.InOutType.ENTER_TYPE;
import static com.srthinker.statinfo.constant.InOutType.LEAVE_TYPE; import static com.srthinker.statinfo.constant.InOutType.LEAVE_TYPE;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
import com.srthinker.statinfo.database.PersonMgr; import com.srthinker.statinfo.database.PersonMgr;
import com.srthinker.statinfo.database.entity.ConfigEntity; import com.srthinker.statinfo.database.entity.ConfigEntity;
...@@ -30,33 +17,23 @@ import com.srthinker.statinfo.listener.ConfigCallback; ...@@ -30,33 +17,23 @@ import com.srthinker.statinfo.listener.ConfigCallback;
import com.srthinker.statinfo.listener.QueryPersonCallback; import com.srthinker.statinfo.listener.QueryPersonCallback;
import com.srthinker.statinfo.listener.upper.UpperDevicesCallback; import com.srthinker.statinfo.listener.upper.UpperDevicesCallback;
import com.srthinker.statinfo.presenter.ApiQuest; import com.srthinker.statinfo.presenter.ApiQuest;
import com.srthinker.statinfo.presenter.StatSize;
import com.srthinker.statinfo.uis.BaseActivity; import com.srthinker.statinfo.uis.BaseActivity;
import com.srthinker.statinfo.uis.GroupActivity; import com.srthinker.statinfo.uis.GroupActivity;
import com.srthinker.statinfo.uis.MyApplication;
import com.srthinker.statinfo.uis.fragment.ConfigDlgFragment; import com.srthinker.statinfo.uis.fragment.ConfigDlgFragment;
import com.srthinker.statinfo.util.common.ClickUtil; import com.srthinker.statinfo.util.common.ClickUtil;
import com.srthinker.statinfo.util.common.SharedUtil; import com.srthinker.statinfo.util.common.SharedUtil;
import com.srthinker.statinfo.util.common.Utils; import com.srthinker.statinfo.util.common.Utils;
import com.srthinker.statinfo.util.other.NetworkIPMonitor; import com.srthinker.statinfo.util.other.NetworkIPMonitor;
import com.srthinker.statinfo.wedget.LoadDialog;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class SettingActivity extends BaseActivity implements ConfigCallback, QueryPersonCallback, UpperDevicesCallback { public class SettingActivity extends BaseActivity implements ConfigCallback, QueryPersonCallback, UpperDevicesCallback, NetworkIPMonitor.OnIPChangeCallback {
private static final String TAG = "SettingActivity"; private static final String TAG = "SettingActivity";
private com.srthinker.statinfo.databinding.ActivitySettingBinding mBinding; private com.srthinker.statinfo.databinding.ActivitySettingBinding mBinding;
private List<PersonEntity> enterBeans; private List<PersonEntity> enterBeans;
private List<PersonEntity> leaveBeans; private List<PersonEntity> leaveBeans;
private NetworkIPMonitor networkIPMonitor;
private String installPath = "";
private LoadDialog mLoadDialog;
//private String savePath = "/sdcard/update/StatInfo.apk";
//getFilesDir() + "/update", "StatInfo.apk"
private String savePath = Environment.getExternalStorageDirectory().getPath() + "/update";
private int lastEnterSize = 0; private int lastEnterSize = 0;
private int lastLeaveSize = 0; private int lastLeaveSize = 0;
private int lastPresentSize = 0; private int lastPresentSize = 0;
...@@ -68,6 +45,9 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -68,6 +45,9 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
private boolean leave_connect; private boolean leave_connect;
private boolean enter_connect; private boolean enter_connect;
private boolean isModified = false; // 设置标志位表示有进行了修改 private boolean isModified = false; // 设置标志位表示有进行了修改
private String deviceDesc;
private NetworkIPMonitor networkIPMonitor;
private String networkChange;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -83,21 +63,18 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -83,21 +63,18 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
protected void initData() { protected void initData() {
Log.i(TAG, "initData: Setting-init"); Log.i(TAG, "initData: Setting-init");
SharedUtil.getInstance(this).writeShared("isModified",isModified); SharedUtil.getInstance(this).writeShared("isModified",isModified);
/*networkIPMonitor = new NetworkIPMonitor(this); networkIPMonitor = new NetworkIPMonitor(this);
enterBeans = new ArrayList<>();
leaveBeans = new ArrayList<>();
networkIPMonitor.startMonitoring(); networkIPMonitor.startMonitoring();
networkIPMonitor.setOnIPChangeCallback(this);*/ networkIPMonitor.setOnIPChangeCallback(this);
} }
@Override @Override
protected void initView() { protected void initView() {
//mLoadDialog = LoadDialog.getInstance(this);
mLoadDialog = new LoadDialog(this);
//Log.i(TAG, "initView: deviceSn="+deviceSn+"V"+ Utils.getVersionName(this)); //Log.i(TAG, "initView: deviceSn="+deviceSn+"V"+ Utils.getVersionName(this));
mBinding.tvDeviceDesc.setText(DEVICE_TYPE+" "+DEVICE_SN+" V"+ Utils.getVersionName(this)); deviceDesc = "设备型号: "+DEVICE_TYPE+"\n\n"+"设备SN: "+DEVICE_SN+"\n\n设备版本: V"+ Utils.getVersionName(this)+"\n\n";
mBinding.tvDeviceDesc.setText(deviceDesc+"网络未连接");
//getResp(); //getResp();
mBinding.tvEnterText.setOnClickListener(v->{ mBinding.tvEnterText.setOnClickListener(v->{
showConfigDialog(ENTER_TYPE); showConfigDialog(ENTER_TYPE);
...@@ -109,7 +86,7 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -109,7 +86,7 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
boolean isQueryPersons = ApiQuest.getInstance().queryPersons(this); boolean isQueryPersons = ApiQuest.getInstance().queryPersons(this);
//Log.i(TAG, "initView: isQueryPersons="+isQueryPersons); //Log.i(TAG, "initView: isQueryPersons="+isQueryPersons);
if (!isQueryPersons) { if (!isQueryPersons) {
showTips("请先配置设备信息"); showTips("请检查配置信息和检查网络");
}else{ }else{
ClickUtil.disableClick(mBinding.btnGroupDetail); ClickUtil.disableClick(mBinding.btnGroupDetail);
} }
...@@ -117,6 +94,9 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -117,6 +94,9 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
mBinding.ivBack.setOnClickListener(v->{ mBinding.ivBack.setOnClickListener(v->{
onBackPressed(); onBackPressed();
}); });
/* mBinding.tvDeviceConfig.setOnClickListener(v->{
showPortDialog();
});*/
} }
private void showConfigDialog(int type) { private void showConfigDialog(int type) {
...@@ -130,12 +110,19 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -130,12 +110,19 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
configDlgFragment.setCancelable(false); configDlgFragment.setCancelable(false);
} }
private void showPortDialog(){
DePortStatusDlgFragment dePortStatusDlgFragment = new DePortStatusDlgFragment();
if (dePortStatusDlgFragment.isResumed()){
return;
}
dePortStatusDlgFragment.showNow(getSupportFragmentManager(),dePortStatusDlgFragment.getClass().getSimpleName());
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
updateDeviceConnect(); //updateDeviceConnect();
/*//获取最新的人员信息列表 /*//获取最新的人员信息列表
mQueryPersonList = PersonHelper.getInstance().queryAll(); mQueryPersonList = PersonHelper.getInstance().queryAll();
//更新分组情况 //更新分组情况
...@@ -145,12 +132,12 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -145,12 +132,12 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
// detectUpgrade(); //检测版本升级 // detectUpgrade(); //检测版本升级
} }
private void updateDeviceConnect() { /*private void updateDeviceConnect() {
HashMap<String, Boolean> devicesConnect = MyApplication.getInstance().devicesConnect; HashMap<String, Boolean> devicesConnect = MyApplication.getInstance().devicesConnect;
enter_connect = devicesConnect.getOrDefault("enter_connect",false); enter_connect = devicesConnect.getOrDefault("enter_connect",false);
leave_connect = devicesConnect.getOrDefault("leave_connect",false); leave_connect = devicesConnect.getOrDefault("leave_connect",false);
/*enter_connect = SharedUtil.getInstance(this).readShared("enter_connect", false); *//*enter_connect = SharedUtil.getInstance(this).readShared("enter_connect", false);
leave_connect = SharedUtil.getInstance(this).readShared("leave_connect", false);*/ leave_connect = SharedUtil.getInstance(this).readShared("leave_connect", false);*//*
if (enter_connect){ if (enter_connect){
mBinding.tvEnterError.setVisibility(View.GONE); mBinding.tvEnterError.setVisibility(View.GONE);
}else{ }else{
...@@ -161,251 +148,17 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -161,251 +148,17 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
}else{ }else{
mBinding.tvLeaveError.setVisibility(View.VISIBLE); mBinding.tvLeaveError.setVisibility(View.VISIBLE);
} }
} }*/
@Override @Override
protected void onDestroy() { protected void onDestroy() {
networkIPMonitor.stopMonitoring();
super.onDestroy(); super.onDestroy();
} }
/* @Override
public void checkResult(boolean needUpdate, boolean canInstall, UpdateInfo onlineInfo) {
if (needUpdate){
if (onlineInfo!=null){
Log.i(TAG, "checkResult: onlineInfo="+ GsonUtil.toJsonString(onlineInfo));
//Environment.getExternalStorageDirectory().getPath()=/storage/emulated/0
//getFilesDir()=installPath=/data/user/0/com.srthinker.statinfo/files
//String installPath = getFilesDir() + "/" + "StatInfo.apk";
//boolean isCreate = FileUtil.createFile(getFilesDir() + "/update", "StatInfo.apk");
FileUtil.deleteFile(savePath+ File.separator+"StatInfo.apk");
boolean isCreate = FileUtil.createFile( savePath+File.separator, "StatInfo.apk");
if (isCreate){
//installPath = getFilesDir()+"/update/StatInfo.apk";
installPath = savePath+File.separator+"StatInfo.apk";
DownloadViewModel downloadViewModel = new DownloadViewModel(this);
downloadViewModel.initData();
downloadViewModel.startDownload(onlineInfo.getDownloadUrl(),installPath);
downloadViewModel.setOnUpperDownloadCallback(this);
}
}
}
}
@Override
public void onProgress(String progress, String filePath) {
runOnUiThread(()->{
//Log.i(TAG, "onProgress: progress="+progress);
String desc = "下载更新中..."+progress;
if (mLoadDialog != null) {
mLoadDialog.setContent(desc);
mLoadDialog.showDialog();
}
});
}
@Override
public void onResult(int downStatus, String filePath) {
runOnUiThread(()->{
if (downStatus == DOWN_START){
String desc = "准备下载更新";
if (mLoadDialog != null) {
mLoadDialog.setContent(desc);
mLoadDialog.showDialog();
}
} else if (downStatus== DOWN_FINISH){
//安装更新
//Log.i(TAG, "onResult:进来多少次");
//showTips("更新版本,将进行安装");
String desc = "进行安装,请稍等";
if (mLoadDialog != null) {
mLoadDialog.setContent(desc);
mLoadDialog.showDialog();
}
//Utils.installApp(getApplicationContext(),new File(installPath));
//有静默安装的话需要开新线程,不然前面的弹框不进行显示
ThreadPool.getInstance().getThreadPoolExecutor().execute(() -> {
boolean restricted = Utils.isRootPermissionRestricted();
if (!restricted){
Utils.clientInstall(installPath, SettingActivity.this,".uis.MainActivity");
}else{
Utils.installApp(getApplicationContext(),new File(installPath));
}
runOnUiThread(()->{
if (mLoadDialog != null) {
mLoadDialog.dismissDialog();
mLoadDialog=null;
}
});
});
}else if (downStatus==DOWN_ERROR){
showTips("下载更新失败");
FileUtil.deleteFile(installPath);
}
});
}*/
private void updatePassInfo(List<PersonEntity> passEntities, int type) {
Log.i(TAG, "updatePassInfo: 获取的总数="+passEntities.size());
/*for (PersonEntity passEntity : passEntities) {
Log.i(TAG, "updatePassInfo: 获取到的name="+passEntity.getPerson_name());
}*/
if (type ==ENTER_TYPE){
if (passEntities != null) {
int size = passEntities.size();
if (size!=lastEnterSize){
/*//更新进出情况
//enterBeans = passEntities; 全局变量直接赋值会出现问题
enterBeans.clear();
enterBeans.addAll(passEntities);
enterAdapter.setDataList(passEntities);
//更新人员情况(是否要根据id去重)
if (NEED_NO_REPET) {
List<PersonEntity> enterListNo = StatSize.filterList(passEntities);
lastEnterSize = enterListNo.size();
}else{
lastEnterSize = size;
}
lastPresentSize = lastEnterSize-lastLeaveSize;
mBinding.nvEnter.setNumber(lastEnterSize);
mBinding.nvLeave.setNumber(lastLeaveSize);
mBinding.nvPresent.setNumber(lastPresentSize);*/
enterBeans.clear();
enterBeans.addAll(passEntities);
lastEnterSize = size;
//更新分组情况(是否要根据id去重)
groupEnterHashMap = getGroupSizeHashMap(passEntities);
updatePresentSize(groupEnterHashMap,groupLeaveHashMap);
}
}
}else if (type == LEAVE_TYPE){
//leaveBeans = passEntities;
if (passEntities != null) {
int size = passEntities.size();
//进出有变化时才更新
if (size!=lastLeaveSize){
/*leaveBeans.clear();
leaveBeans.addAll(passEntities);
//更新进出情况
leaveAdapter.setDataList(passEntities);
//更新人员情况(是否要根据id去重)
if (NEED_NO_REPET) {
List<PersonEntity> leaveListNo = StatSize.filterList(passEntities);
lastLeaveSize = leaveListNo.size();
}else{
lastLeaveSize = size;
}
lastPresentSize = lastEnterSize-lastLeaveSize;
mBinding.nvEnter.setNumber(lastEnterSize);
mBinding.nvLeave.setNumber(lastLeaveSize);
mBinding.nvPresent.setNumber(lastPresentSize);*/
leaveBeans.clear();
leaveBeans.addAll(passEntities);
lastLeaveSize = size;
//更新分组情况(是否要根据id去重)
groupLeaveHashMap = getGroupSizeHashMap(passEntities);
updatePresentSize(groupEnterHashMap,groupLeaveHashMap);
}
}
}
}
@NonNull
private HashMap<Integer, Integer> getGroupSizeHashMap(List<PersonEntity> personEntityList) {
HashMap<Integer, Integer> groupSizeHashMap = new HashMap<>();
if (NEED_NO_REPET) {
personEntityList = StatSize.filterList(personEntityList);
}
if (mQueryPersonList != null) {
for (PersonEntity entity : mQueryPersonList) {
int group = entity.getGroup();
if (!groupSizeHashMap.containsKey(group)){
groupSizeHashMap.put(group,0);
}
}
for (PersonEntity personEntity : personEntityList) {
String personId = personEntity.getId();
for (PersonEntity queryPerson : mQueryPersonList) {
String queryId = queryPerson.getId();
int group = queryPerson.getGroup();
if (TextUtils.equals(personId,queryId)&& groupSizeHashMap.containsKey(group)){
int totalSize = groupSizeHashMap.get(group);
groupSizeHashMap.put(group,totalSize+1);
}
}
}
}
return groupSizeHashMap;
}
private void updatePresentSize(HashMap<Integer,Integer> groupEnterHashMap,HashMap<Integer,Integer> groupLeaveHashMap){
groupPresentHashMap = new HashMap<>();
if (mQueryPersonList != null) {
for (PersonEntity entity : mQueryPersonList) {
int group = entity.getGroup();
if (!groupPresentHashMap.containsKey(group)) {
groupPresentHashMap.put(group, 0);
}
}
}
//更新分组情况
if (groupEnterHashMap != null) {
for (Map.Entry<Integer, Integer> enterEntry : groupEnterHashMap.entrySet()) {
int group = enterEntry.getKey();
int enterSize = enterEntry.getValue();
groupPresentHashMap.put(group,enterSize);
}
}
if (groupLeaveHashMap != null) {
for (Map.Entry<Integer, Integer> leaveEntry : groupLeaveHashMap.entrySet()) {
int group = leaveEntry.getKey();
int leaveSize = leaveEntry.getValue();
groupPresentHashMap.put(group,groupPresentHashMap.get(group)-leaveSize);
}
}
//如果只有一个人,从一个组换到另一个组,之前的数据没有清空,需要先进行清空,置空为0
SharedUtil.getInstance(this).writeShared(WATERPROOF,0);
SharedUtil.getInstance(this).writeShared(OUTRIGGER,0);
SharedUtil.getInstance(this).writeShared(BUILD,0);
SharedUtil.getInstance(this).writeShared(SUPERVISOR,0);
for (Map.Entry<Integer, Integer> presentEntry : groupPresentHashMap.entrySet()) {
int group = presentEntry.getKey();
int presentSize = presentEntry.getValue();
Log.i(TAG, "updatePresentSize: group="+group+",presentSize="+presentSize);
switch (group){
case WATERPROOF_ID:
SharedUtil.getInstance(this).writeShared(WATERPROOF,presentSize);
break;
case OUTRIGGER_ID:
SharedUtil.getInstance(this).writeShared(OUTRIGGER,presentSize);
break;
case BUILD_ID:
SharedUtil.getInstance(this).writeShared(BUILD,presentSize);
break;
case SUPERVISOR_ID:
SharedUtil.getInstance(this).writeShared(SUPERVISOR,presentSize);
break;
}
}
//要更新演示页面的分组请求
/*ArrayList<GroupBean> groupBeans = updateGroup();
if (groupAdapter != null) {
groupAdapter.setDataList(groupBeans);
}*/
}
@Override @Override
public void onQueryStatus(String desc, boolean status) { public void onQueryStatus(String desc, boolean status) {
runOnUiThread(()->{ runOnUiThread(()->{
...@@ -439,7 +192,7 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -439,7 +192,7 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
isModified = true; isModified = true;
SharedUtil.getInstance(this).writeShared("isModified",isModified); SharedUtil.getInstance(this).writeShared("isModified",isModified);
//更新连接状态 //更新连接状态
updateDeviceConnect(); //updateDeviceConnect();
} }
@Override @Override
...@@ -451,7 +204,8 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -451,7 +204,8 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
@Override @Override
public void onAllConnectStatus(boolean hasConnect, int type) { public void onAllConnectStatus(boolean hasConnect, int type) {
Log.i(TAG, "onAllConnectStatus: 接收到的连接状态 hasConnect="+hasConnect); //有个问题只有进行配置了这里才返回,还是不写这里,要看连接情况直接看连接的ip
/*Log.i(TAG, "onAllConnectStatus: 接收到的连接状态 hasConnect="+hasConnect);
Log.i(TAG, "onAllConnectStatus: type="+type); Log.i(TAG, "onAllConnectStatus: type="+type);
runOnUiThread(()->{ runOnUiThread(()->{
HashMap<String, Boolean> devicesConnect = MyApplication.getInstance().devicesConnect; HashMap<String, Boolean> devicesConnect = MyApplication.getInstance().devicesConnect;
...@@ -473,8 +227,23 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que ...@@ -473,8 +227,23 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
mBinding.tvLeaveError.setVisibility(View.GONE); mBinding.tvLeaveError.setVisibility(View.GONE);
} }
} }
}); });*/
} }
@Override
public void OnIPChange(String ipAddress, String networkType) {
networkChange = "连接的网络IP: "+ipAddress;
runOnUiThread(() -> {
mBinding.tvDeviceDesc.setText(deviceDesc+networkChange);
});
}
@Override
public void OnIPLost(String error) {
networkChange = "网络未连接";
runOnUiThread(() -> {
mBinding.tvDeviceDesc.setText(deviceDesc+networkChange);
});
}
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.srthinker.statinfo.wedget; ...@@ -2,6 +2,7 @@ package com.srthinker.statinfo.wedget;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.widget.LinearLayout; import android.widget.LinearLayout;
...@@ -31,8 +32,17 @@ public class EditView extends LinearLayout { ...@@ -31,8 +32,17 @@ public class EditView extends LinearLayout {
} }
public void initItem(String title,String hint){ public void initItem(String title,String hint){
/*mBinding.tvTitle.setText(title);
mBinding.etContent.setHint(hint);*/
initItem(title,hint,18);
}
public void initItem(String title,String hint,float textSize){
mBinding.tvTitle.setText(title); mBinding.tvTitle.setText(title);
mBinding.etContent.setHint(hint); mBinding.etContent.setHint(hint);
mBinding.tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP,textSize);
mBinding.etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP,textSize);
mBinding.tvStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP,textSize);
} }
public void setContent(String content){ public void setContent(String content){
...@@ -54,7 +64,7 @@ public class EditView extends LinearLayout { ...@@ -54,7 +64,7 @@ public class EditView extends LinearLayout {
} }
public String getContent(){ public String getContent(){
return mBinding.etContent.getText().toString(); return mBinding.etContent.getText().toString().trim();
} }
public void setInputType(int type){ public void setInputType(int type){
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
android:padding="15dp" android:padding="15dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/tv_device_config"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/white" android:textColor="@color/white"
...@@ -56,7 +57,7 @@ ...@@ -56,7 +57,7 @@
android:textSize="@dimen/text_12_5" android:textSize="@dimen/text_12_5"
android:layout_toRightOf="@+id/tv_enter_text" android:layout_toRightOf="@+id/tv_enter_text"
android:layout_alignBottom="@+id/tv_enter_text" android:layout_alignBottom="@+id/tv_enter_text"
android:visibility="visible" android:visibility="gone"
android:layout_marginLeft="5dp"/> android:layout_marginLeft="5dp"/>
<TextView <TextView
android:id="@+id/tv_leave_text" android:id="@+id/tv_leave_text"
...@@ -77,7 +78,7 @@ ...@@ -77,7 +78,7 @@
android:textSize="@dimen/text_12_5" android:textSize="@dimen/text_12_5"
android:layout_toLeftOf="@+id/tv_leave_text" android:layout_toLeftOf="@+id/tv_leave_text"
android:layout_alignBottom="@+id/tv_leave_text" android:layout_alignBottom="@+id/tv_leave_text"
android:visibility="visible" android:visibility="gone"
android:layout_marginRight="5dp"/> android:layout_marginRight="5dp"/>
</RelativeLayout> </RelativeLayout>
...@@ -91,6 +92,7 @@ ...@@ -91,6 +92,7 @@
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/tv_person_config"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/white" android:textColor="@color/white"
...@@ -141,7 +143,7 @@ ...@@ -141,7 +143,7 @@
android:gravity="left|center" android:gravity="left|center"
android:layout_marginTop="17dp" android:layout_marginTop="17dp"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/text_10"/> android:textSize="@dimen/text_12_5"/>
</LinearLayout> </LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/black">
<ImageView
android:id="@+id/iv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_close"
android:padding="10dp"
android:layout_gravity="right"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_port_status"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_status_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textColor="@color/red"/>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment