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 {
//如果都有
//给从接口获取新的数据之前有分过组的数据写分组的信息,已经被删除的人员也要删除掉
ArrayList<PersonEntity> needDelPersons = new ArrayList<>();
int equal_name = 0;
for (PersonEntity queryPerson : queryPersons) {
String queryId = queryPerson.getId();
String query_name = queryPerson.getPerson_name();
boolean isFound = false;
for (PersonEntity newPersonEntity : personEntities) {
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());
isFound = true;
break;
}
}
if (!isFound){
/*if (!isFound){
needDelPersons.add(queryPerson);
}
}*/
}
Log.i(TAG, "updatePerson: 和已分配的相同名字的总数="+equal_name);
if (personHelper != null) {
personHelper.delete(queryPersons);
personHelper.save(personEntities);
Log.i(TAG, "updatePerson: needDelPersons.size()="+needDelPersons.size());
personHelper.delete(needDelPersons);
/*Log.i(TAG, "updatePerson: needDelPersons.size()="+needDelPersons.size());
personHelper.delete(needDelPersons);*/
}
}
......@@ -111,9 +123,17 @@ public class PersonMgr {
List<PersonEntity> needUpdate = new ArrayList<>();
for (PersonEntity personEntity : personEntities) {
String personId = personEntity.getId();
String person_name = personEntity.getPerson_name();
for (PersonEntity queryPerson : queryPersons) {
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());
needUpdate.add(queryPerson);
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;
import com.srthinker.statinfo.api.kuangshi.client.DefaultApiClient;
import com.srthinker.statinfo.database.entity.PersonEntity;
import com.srthinker.statinfo.listener.DeviceCallback;
import com.srthinker.statinfo.listener.DevicePortCallback;
import com.srthinker.statinfo.listener.QueryPersonCallback;
import com.srthinker.statinfo.util.common.DateUtil;
import com.srthinker.statinfo.util.common.ThreadPool;
......@@ -48,6 +49,7 @@ public class ApiManager {
private PersonApiImpl personApi;
private boolean lastConnect = false;
private QueryPersonCallback queryPersonsCallback;
private DevicePortCallback devicePortCallback;
public ApiManager(String username, String password, String serverIp,int type){
......@@ -74,6 +76,10 @@ public class ApiManager {
this.queryPersonsCallback = queryPersonsCallback;
}
public void setOnDevicePortCallback(DevicePortCallback devicePortCallback){
this.devicePortCallback = devicePortCallback;
}
public void start(){
isRunning = true;
isFirstStatus = true;
......@@ -100,6 +106,9 @@ public class ApiManager {
//登录出错,打印错误信息
System.out.println(JSONObject.toJSONString(loginResp));
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),JSONObject.toJSONString(loginResp));
}
return;
}
sessionId = loginResp.getSessionId();
......@@ -114,13 +123,18 @@ public class ApiManager {
}
}catch (ApiClientException e2){
updateLastConnect(false);
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),"authRunnable:"+serverIp+"--e2-->"+e2.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
updateLastConnect(false);
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),"authRunnable:"+serverIp+"--e-->"+e.getMessage());
}
Log.i(TAG, "run: authRunnable抛异常:ip="+serverIp);
if (isRunning){
handler.postDelayed(authThreadRunnable,2000);
handler.postDelayed(authThreadRunnable,10000);
}
}
}
......@@ -229,6 +243,7 @@ public class ApiManager {
PersonEntity passBean = new PersonEntity();
passBean.setId(dataBean.getPerson_id());
passBean.setPerson_name(dataBean.getPerson_name());
//String id_number = dataBean.getId_number();
String timestamp = dataBean.getTimestamp();
String timeString = DateUtil.zoneToDateString(timestamp, "HH:mm");
passBean.setTimestamp(timeString);
......@@ -250,9 +265,15 @@ public class ApiManager {
}
} catch (ApiClientException e2){
updateLastConnect(false);
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),"passRecordRunnable:"+serverIp+"--e2-->"+e2.getMessage());
}
} catch (Exception e) {
Log.i(TAG, "run: passRecordRunnable抛异常");
updateLastConnect(false);
if (devicePortCallback != null) {
devicePortCallback.getDevicePortStatus(DateUtil.getNowDateTimeFormat(),"passRecordRunnable:"+serverIp+"--e-->"+e.getMessage());
}
e.printStackTrace();
}
......@@ -301,6 +322,9 @@ public class ApiManager {
PersonEntity personEntity = new PersonEntity();
personEntity.setId(personData.getId());
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);
}
totalPersonLists.addAll(personEntities);
......
......@@ -5,12 +5,14 @@ import static com.srthinker.statinfo.constant.InOutType.LEAVE_TYPE;
import android.util.Log;
import com.srthinker.statinfo.bean.StatusInfoBean;
import com.srthinker.statinfo.database.entity.ConfigEntity;
import com.srthinker.statinfo.database.entity.PersonEntity;
import com.srthinker.statinfo.database.helper.ConfigHelper;
import com.srthinker.statinfo.listener.DeviceCallback;
import com.srthinker.statinfo.listener.QueryPersonCallback;
import com.srthinker.statinfo.listener.upper.UpperDevicesCallback;
import com.srthinker.statinfo.listener.upper.UpperDevicesPortCallback;
import com.srthinker.statinfo.util.common.ThreadPool;
import java.util.ArrayList;
......@@ -34,6 +36,7 @@ public class ApiQuest {
private static LinkedHashMap<String,ApiManager> enterMgrHashMap = new LinkedHashMap<>();
private static LinkedHashMap<String,ApiManager> leaveMgrHashMap = new LinkedHashMap<>();
private String oneEnterIp;
private UpperDevicesPortCallback upperDevicesPortCallback;
public static ApiQuest getInstance(){
if (apiQuest == null) {
......@@ -48,6 +51,10 @@ public class ApiQuest {
this.upperDevicesCallback = upperDevicesCallback;
}
public void setOnUpperDevicesPortCallback(UpperDevicesPortCallback upperDevicesPortCallback){
this.upperDevicesPortCallback = upperDevicesPortCallback;
}
private void initData(int type){
if (type==ENTER_TYPE){
isEnterAllConnect = false;
......@@ -96,6 +103,12 @@ public class ApiQuest {
ApiManager enterMgr = new ApiManager(username, password, ip, ENTER_TYPE);
enterMgrHashMap.put(ip,enterMgr);
enterMgr.start();
enterMgr.setOnDevicePortCallback((time, info) -> {
StatusInfoBean statusInfoBean = new StatusInfoBean(time, info,ENTER_TYPE);
if (upperDevicesPortCallback != null) {
upperDevicesPortCallback.onDevicesPort(statusInfoBean);
}
});
enterMgr.setOnDeviceCallback(new DeviceCallback() {
@Override
public void getPassInfo(List<PersonEntity> passEntities, int type) {
......@@ -137,13 +150,14 @@ public class ApiQuest {
isEnterAllConnect = true;
synchronized (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();
if (!connect){
isEnterAllConnect = false;
break;
}
}
//Log.i(TAG, "onConnectStatus: isEnterAllConnect="+isEnterAllConnect);
if (upperDevicesCallback != null) {
upperDevicesCallback.onAllConnectStatus(isEnterAllConnect,type);
}
......@@ -165,6 +179,12 @@ public class ApiQuest {
ApiManager leaveMgr = new ApiManager(username, password, ip, LEAVE_TYPE);
leaveMgrHashMap.put(ip,leaveMgr);
leaveMgr.start();
leaveMgr.setOnDevicePortCallback((time, info) -> {
StatusInfoBean statusInfoBean = new StatusInfoBean(time, info,LEAVE_TYPE);
if (upperDevicesPortCallback != null) {
upperDevicesPortCallback.onDevicesPort(statusInfoBean);
}
});
leaveMgr.setOnDeviceCallback(new DeviceCallback() {
@Override
public void getPassInfo(List<PersonEntity> passEntities, int type) {
......@@ -236,6 +256,7 @@ public class ApiQuest {
}
public boolean queryPersons(QueryPersonCallback callback){
Log.i(TAG, "queryPersons: enterMgrHashMap.size="+enterMgrHashMap.size());
if (enterMgrHashMap.size()>0){
ApiManager oneEnterMgr = enterMgrHashMap.get(oneEnterIp);
if (oneEnterMgr != null) {
......
......@@ -6,14 +6,14 @@ import java.util.ArrayList;
import java.util.List;
public class StatSize {
//id和时间相同的进行去重过滤
//名字和时间相同的进行去重过滤
public static List<PersonEntity> filterList(List<PersonEntity> personEntityList){
List<PersonEntity> filterPersonList = new ArrayList<>();
if (personEntityList != null) {
for (PersonEntity personEntity : personEntityList) {
boolean shouldAdd = true;
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;
break;
}
......
......@@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.srthinker.statinfo.adapter.GroupShowAdapter;
import com.srthinker.statinfo.bean.Group2Bean;
import com.srthinker.statinfo.bean.StatusInfoBean;
import com.srthinker.statinfo.constant.GroupConst;
import com.srthinker.statinfo.database.entity.ConfigEntity;
import com.srthinker.statinfo.database.entity.PersonEntity;
......@@ -31,6 +32,7 @@ import com.srthinker.statinfo.databinding.ActivityNewMainBinding;
import com.srthinker.statinfo.download.upper.DownloadViewModel;
import com.srthinker.statinfo.download.upper.UpperDownloadCallback;
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.StatSize;
import com.srthinker.statinfo.uis.news.SettingActivity;
......@@ -52,7 +54,7 @@ import java.util.HashMap;
import java.util.List;
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 com.srthinker.statinfo.databinding.ActivityNewMainBinding mBinding;
......@@ -104,6 +106,7 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
Intent intent = new Intent(this, SettingActivity.class);
startActivity(intent);
});
mLoadDialog = new LoadDialog(this); //1.0.2版本把这个漏了
}
/*private void initGroup() {
......@@ -186,6 +189,7 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
Log.i(TAG, "onDestroy: Main--destroy");
networkIPMonitor.stopMonitoring();
ApiQuest.getInstance().stopApi();
clearStatusInfoBeans();
super.onDestroy();
}
......@@ -199,15 +203,22 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
private void questApi() {
List<ConfigEntity> enterConfigList = ConfigHelper.getInstance().queryByType(ENTER_TYPE);
ApiQuest.getInstance().startApi(enterConfigList,ENTER_TYPE);
ApiQuest.getInstance().setOnUpperDevicesCallback(this);
List<ConfigEntity> leaveConfigList = ConfigHelper.getInstance().queryByType(LEAVE_TYPE);
ApiQuest.getInstance().startApi(leaveConfigList,LEAVE_TYPE);
ApiQuest.getInstance().setOnUpperDevicesCallback(this);
ApiQuest.getInstance().setOnUpperDevicesPortCallback(this);
}
@Override
public void OnIPLost(String error) {
ApiQuest.getInstance().stopApi();
//修改状态
List<ConfigEntity> configEntities = ConfigHelper.getInstance().queryAll();
for (ConfigEntity configEntity : configEntities) {
configEntity.setConnect(false);
//更新ip接口状态
ConfigHelper.getInstance().update(configEntity);
}
}
@Override
......@@ -219,21 +230,22 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
@Override
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){
devicesConnect.put("enter_connect",hasConnect);
// SharedUtil.getInstance(this).writeShared("enter_connect",hasConnect);
}else if (type==LEAVE_TYPE){
// SharedUtil.getInstance(this).writeShared("leave_connect",hasConnect);
devicesConnect.put("leave_connect",hasConnect);
}
}*/
}
private void updatePassInfo(List<PersonEntity> passEntities, int type) {
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());
}*/
}
if (type ==ENTER_TYPE){
if (passEntities != null) {
int size = passEntities.size();
......@@ -312,10 +324,13 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
}
for (PersonEntity personEntity : personEntityList) {
String personId = personEntity.getId();
String personName = personEntity.getPerson_name();
for (PersonEntity queryPerson : mQueryPersonList) {
String queryId = queryPerson.getId();
String queryName = queryPerson.getPerson_name();
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);
groupSizeHashMap.put(group,totalSize+1);
}
......@@ -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 {
private static MyApplication application;
//声明一个公共的变量,存储网络状态
public HashMap<String,Boolean> devicesConnect = new HashMap<>();
// 1秒钟后重启应用
private int time = 1000;
......
......@@ -291,7 +291,7 @@ public class ConfigDlgFragment extends DialogFragment {
Window window = getDialog().getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//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);
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,6 +2,7 @@ package com.srthinker.statinfo.wedget;
import android.content.Context;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
......@@ -31,8 +32,17 @@ public class EditView extends LinearLayout {
}
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.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){
......@@ -54,7 +64,7 @@ public class EditView extends LinearLayout {
}
public String getContent(){
return mBinding.etContent.getText().toString();
return mBinding.etContent.getText().toString().trim();
}
public void setInputType(int type){
......
......@@ -23,6 +23,7 @@
android:padding="15dp"
android:orientation="vertical">
<TextView
android:id="@+id/tv_device_config"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
......@@ -56,7 +57,7 @@
android:textSize="@dimen/text_12_5"
android:layout_toRightOf="@+id/tv_enter_text"
android:layout_alignBottom="@+id/tv_enter_text"
android:visibility="visible"
android:visibility="gone"
android:layout_marginLeft="5dp"/>
<TextView
android:id="@+id/tv_leave_text"
......@@ -77,7 +78,7 @@
android:textSize="@dimen/text_12_5"
android:layout_toLeftOf="@+id/tv_leave_text"
android:layout_alignBottom="@+id/tv_leave_text"
android:visibility="visible"
android:visibility="gone"
android:layout_marginRight="5dp"/>
</RelativeLayout>
......@@ -91,6 +92,7 @@
android:layout_marginTop="15dp"
android:orientation="vertical">
<TextView
android:id="@+id/tv_person_config"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
......@@ -141,7 +143,7 @@
android:gravity="left|center"
android:layout_marginTop="17dp"
android:textColor="@color/white"
android:textSize="@dimen/text_10"/>
android:textSize="@dimen/text_12_5"/>
</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