bug修改
This commit is contained in:
parent
964760e69d
commit
f4f13c2ef8
|
|
@ -2,7 +2,7 @@
|
|||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "2cfc52157095ba7809e8f8e5ade25bac",
|
||||
"identityHash": "579afa9522feaddfe81cdb2c30e2ab24",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "user_info",
|
||||
|
|
@ -167,7 +167,7 @@
|
|||
},
|
||||
{
|
||||
"tableName": "device_info",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `deviceId` INTEGER, `deviceNo` TEXT, `canteenId` TEXT, `areaId` TEXT, `devicePwd` TEXT, `deviceType` TEXT, `deviceCategory` TEXT, `deviceSize` TEXT, `deviceName` TEXT, `deviceSn` TEXT, `subPlace` TEXT, `subPlaceName` TEXT, `deviceNetworkState` INTEGER, `deviceRepairPeriod` INTEGER, `deviceExtendInfo` TEXT, `delFlag` TEXT, `areaName` TEXT, `canteenName` TEXT, `ip` TEXT, `channel` TEXT)",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `deviceId` TEXT, `deviceNo` TEXT, `canteenId` TEXT, `areaId` TEXT, `devicePwd` TEXT, `deviceType` TEXT, `deviceCategory` TEXT, `deviceSize` TEXT, `deviceName` TEXT, `deviceSn` TEXT, `subPlace` TEXT, `subPlaceName` TEXT, `deviceNetworkState` INTEGER, `deviceRepairPeriod` INTEGER, `deviceExtendInfo` TEXT, `delFlag` TEXT, `areaName` TEXT, `canteenName` TEXT, `ip` TEXT, `channel` TEXT)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
|
|
@ -178,7 +178,7 @@
|
|||
{
|
||||
"fieldPath": "deviceId",
|
||||
"columnName": "deviceId",
|
||||
"affinity": "INTEGER",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
|
|
@ -421,7 +421,7 @@
|
|||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '2cfc52157095ba7809e8f8e5ade25bac')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '579afa9522feaddfe81cdb2c30e2ab24')"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -17,10 +17,13 @@
|
|||
|
||||
package com.bonus.canteen.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.serialport.SerialPort;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
|
|
@ -53,8 +56,15 @@ import com.xuexiang.xutil.common.ClickUtils;
|
|||
import org.easydarwin.easypusher.R;
|
||||
import org.easydarwin.easypusher.databinding.ActivityMainBinding;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
|
@ -65,6 +75,11 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements C
|
|||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private final OkHttpService service = new OkHttpService();
|
||||
private SerialPort serialPort = null;
|
||||
private OutputStream outputStream = null;
|
||||
private InputStream inputStream = null;
|
||||
private boolean isStopRead = false;
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
@Override
|
||||
protected ActivityMainBinding viewBindingInflate(LayoutInflater inflater) {
|
||||
|
|
@ -78,7 +93,13 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements C
|
|||
initView();
|
||||
initTab();
|
||||
startUpdateTime();
|
||||
// 如果时间是00:00:00,更新日期和星期
|
||||
binding.date.setText(DateTimeHelper.getNowDate());
|
||||
//获取当前星期几
|
||||
String week = DateTimeHelper.getWeekOfDate(new Date());
|
||||
binding.week.setText(week);
|
||||
binding.back.setOnClickListener(v -> updateView(1));
|
||||
initPort();
|
||||
}
|
||||
|
||||
private void startUpdateTime() {
|
||||
|
|
@ -213,7 +234,7 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements C
|
|||
JSONObject json = new JSONObject();
|
||||
DeviceInfo deviceInfo = AppDatabase.getDatabase(this).deviceInfoDao().getDeviceInfoOne();
|
||||
json.put("staffId", userInfo.getUserId());
|
||||
json.put("deviceId", deviceInfo.getDeviceId());
|
||||
json.put("deviceId", deviceInfo != null ? deviceInfo.getDeviceId() : "-1");
|
||||
json.put("temperatureValue", userInfo.getTemperature());
|
||||
json.put("recordTime", DateTimeHelper.getNowDate());
|
||||
json.put("faceCheckImg", userInfo.getFaceCheckImg());
|
||||
|
|
@ -245,4 +266,104 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements C
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initPort() {
|
||||
try {
|
||||
if (serialPort != null) {
|
||||
serialPort.close();
|
||||
}
|
||||
serialPort = null;
|
||||
outputStream = null;
|
||||
inputStream = null;
|
||||
serialPort = SerialPort.newBuilder(new File("/dev/ttyS2"), 115200)
|
||||
.dataBits(8)
|
||||
.stopBits(1)
|
||||
.parity(0)
|
||||
.build();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
outputStream = serialPort.getOutputStream();
|
||||
inputStream = serialPort.getInputStream();
|
||||
ThreadPoolManager.getExecutor().execute(this::readData);
|
||||
}
|
||||
|
||||
protected void readData() {
|
||||
isStopRead = false;
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
if (inputStream.available() > 0) {
|
||||
inputStream.skip(inputStream.available());
|
||||
}
|
||||
while (!isStopRead) {
|
||||
if (inputStream == null) {
|
||||
Thread.sleep(200);
|
||||
continue;
|
||||
}
|
||||
if (inputStream.available() <= 0) {
|
||||
Thread.sleep(200);
|
||||
continue;
|
||||
}
|
||||
byte[] tempBuffer = new byte[1024];
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
int tempSize = inputStream.read(tempBuffer);
|
||||
for (int i = 0; i < tempSize; i++) {
|
||||
hexString.append(String.format("%02X ", tempBuffer[i]));
|
||||
}
|
||||
//开始为 5A 5AA
|
||||
if (tempBuffer[0] != 0x5A && tempBuffer[1] != 0x5A) {
|
||||
if (!isStopRead && !ThreadPoolManager.getExecutor().isShutdown()) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> parseTheData(hexString.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint({"SetTextI18n", "UseCompatLoadingForDrawables", "DefaultLocale"})
|
||||
protected void parseTheData(String hex) {
|
||||
byte[] byteArray = hexStringToByteArray(new StringBuilder(hex));
|
||||
List<Integer> numList = new ArrayList<>();
|
||||
for (int i = 0; i < byteArray.length / 2; i++) {
|
||||
int value = byteArray[2 * i + 1] * 256 + (byteArray[2 * i] & 0xFF);
|
||||
numList.add(value);
|
||||
}
|
||||
List<Double> pixelTempList = new ArrayList<>();
|
||||
for (int i = 2; i < numList.size(); i++) {
|
||||
pixelTempList.add(numList.get(i) / 100.0);
|
||||
}
|
||||
Double maxValue = pixelTempList.isEmpty() ? null : Collections.max(pixelTempList);
|
||||
try {
|
||||
pixelTempList.remove(0);
|
||||
pixelTempList.remove(0);
|
||||
if (maxValue < 36.5) {
|
||||
maxValue = 36.5;
|
||||
}
|
||||
if (maxValue > 39.5) {
|
||||
maxValue = 39.5;
|
||||
}
|
||||
Intent broad = new Intent();
|
||||
broad.setAction("action.updateTemperatureUI");
|
||||
broad.putExtra("temperature", maxValue + "");
|
||||
sendBroadcast(broad);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "parseTheData: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public byte[] hexStringToByteArray(StringBuilder hexString) {
|
||||
String[] hexArray = hexString.toString().trim().split("\\s+");
|
||||
byte[] byteArray = new byte[hexArray.length];
|
||||
for (int i = 0; i < hexArray.length; i++) {
|
||||
byteArray[i] = (byte) Integer.parseInt(hexArray[i], 16);
|
||||
}
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.viewbinding.ViewBinding;
|
||||
|
||||
import com.bonus.canteen.fragment.StartFragment;
|
||||
import com.xuexiang.xpage.base.XPageActivity;
|
||||
import com.xuexiang.xpage.base.XPageFragment;
|
||||
import com.xuexiang.xpage.core.CoreSwitchBean;
|
||||
|
|
@ -141,6 +142,15 @@ public abstract class BaseActivity<Binding extends ViewBinding> extends XPageAct
|
|||
public <T extends XPageFragment> T switchPage(Class<T> clazz) {
|
||||
return switchPage(clazz, null); // 重载到带Bundle的方法
|
||||
}
|
||||
/**
|
||||
* 切换fragment
|
||||
*
|
||||
* @param clazz 页面类
|
||||
* @return 打开的fragment对象
|
||||
*/
|
||||
public <T extends XPageFragment> T switchPageNew(Class<T> clazz) {
|
||||
return openPage(clazz, false);
|
||||
}
|
||||
public <T extends XPageFragment> T switchPage(Class<T> clazz, Bundle bundle) {
|
||||
// 1. 防抖检查
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
|
@ -202,11 +212,6 @@ public abstract class BaseActivity<Binding extends ViewBinding> extends XPageAct
|
|||
}
|
||||
return null;
|
||||
}
|
||||
// public <T extends XPageFragment> T switchPage(Class<T> clazz, Bundle bundle) {
|
||||
// CoreSwitchBean page = new CoreSwitchBean(clazz)
|
||||
// .setBundle(bundle);
|
||||
// return (T) openPage(page);
|
||||
// }
|
||||
/**
|
||||
* 序列化对象
|
||||
*
|
||||
|
|
@ -253,4 +258,8 @@ public abstract class BaseActivity<Binding extends ViewBinding> extends XPageAct
|
|||
return page == null || page.getBundle() == null || page.getBundle().getBoolean(KEY_SUPPORT_SLIDE_BACK, true);
|
||||
}
|
||||
|
||||
public void popToFragment(Class<StartFragment> startFragmentClass, boolean b) {
|
||||
getSupportFragmentManager().popBackStackImmediate(startFragmentClass.getName(), b ? 0 : FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
switchPage(StartFragment.class,null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class DeviceInfo {
|
|||
|
||||
/** 设备id */
|
||||
@ColumnInfo
|
||||
private Long deviceId;
|
||||
private String deviceId;
|
||||
|
||||
/** 设备编号 */
|
||||
@ColumnInfo
|
||||
|
|
@ -105,11 +105,11 @@ public class DeviceInfo {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getDeviceId() {
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(Long deviceId) {
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,14 @@
|
|||
package com.bonus.canteen.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Point;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Environment;
|
||||
import android.serialport.SerialPort;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
@ -77,11 +81,7 @@ import org.easydarwin.easypusher.databinding.ActivityFaceBinding;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -101,11 +101,6 @@ import io.reactivex.schedulers.Schedulers;
|
|||
public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
||||
private static final String TAG = "FaceFragment";
|
||||
private OkHttpService service = new OkHttpService();
|
||||
private SerialPort serialPort = null;
|
||||
private OutputStream outputStream = null;
|
||||
private InputStream inputStream = null;
|
||||
private boolean isStopRead = false;
|
||||
|
||||
private CameraHelper cameraHelper;
|
||||
private DrawHelper drawHelper;
|
||||
private Camera.Size previewSize;
|
||||
|
|
@ -178,7 +173,7 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
private FaceSearchResultAdapter adapter;
|
||||
UserInfo userInfo = null;
|
||||
private boolean isStartUpload = false;
|
||||
|
||||
UpdateUIBroadcastReceiver broadcastReceiver;
|
||||
@NonNull
|
||||
@Override
|
||||
protected ActivityFaceBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
|
||||
|
|
@ -190,7 +185,7 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
previewView = findViewById(R.id.texture_preview);
|
||||
faceRectView = findViewById(R.id.face_rect_view);
|
||||
FrameLayout faceRectContainer = findViewById(R.id.face_rect_view_container);
|
||||
|
||||
registerBroadcastReceiver();
|
||||
// 设置为圆形
|
||||
faceRectContainer.setOutlineProvider(new ViewOutlineProvider() {
|
||||
@Override
|
||||
|
|
@ -211,15 +206,31 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
} catch (Exception e) {
|
||||
Log.e(TAG, "initView: 销毁失败 或者 无需销毁");
|
||||
}
|
||||
initPort();
|
||||
initModular();
|
||||
initEngine();
|
||||
initCamera();
|
||||
new Handler().postDelayed(() -> {
|
||||
initEngine();
|
||||
initCamera();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
public void initModular() {
|
||||
new Thread(this::activeFaceEngine).start();
|
||||
}
|
||||
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
||||
private void registerBroadcastReceiver() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("action.updateTemperatureUI");
|
||||
broadcastReceiver = new UpdateUIBroadcastReceiver();
|
||||
getActivity().registerReceiver(broadcastReceiver, filter);
|
||||
}
|
||||
private class UpdateUIBroadcastReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e(TAG, "接收到广播");
|
||||
String temperature = intent.getStringExtra("temperature");
|
||||
binding.celsius.setText(temperature);
|
||||
}
|
||||
}
|
||||
|
||||
public String APP_ID;
|
||||
public String SDK_KEY;
|
||||
|
|
@ -470,88 +481,7 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
cameraHelper.start();
|
||||
}
|
||||
|
||||
private void initPort() {
|
||||
try {
|
||||
if (serialPort != null) {
|
||||
serialPort.close();
|
||||
}
|
||||
serialPort = SerialPort.newBuilder(new File("/dev/ttyS2"), 115200)
|
||||
.dataBits(8)
|
||||
.stopBits(1)
|
||||
.parity(0)
|
||||
.build();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
outputStream = serialPort.getOutputStream();
|
||||
inputStream = serialPort.getInputStream();
|
||||
ThreadPoolManager.getExecutor().execute(this::readData);
|
||||
}
|
||||
|
||||
protected void readData() {
|
||||
isStopRead = false;
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
if (inputStream.available() > 0) {
|
||||
inputStream.skip(inputStream.available());
|
||||
}
|
||||
while (!isStopRead) {
|
||||
if (inputStream == null) {
|
||||
Thread.sleep(200);
|
||||
continue;
|
||||
}
|
||||
if (inputStream.available() <= 0) {
|
||||
Thread.sleep(200);
|
||||
continue;
|
||||
}
|
||||
byte[] tempBuffer = new byte[1024];
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
int tempSize = inputStream.read(tempBuffer);
|
||||
for (int i = 0; i < tempSize; i++) {
|
||||
hexString.append(String.format("%02X ", tempBuffer[i]));
|
||||
}
|
||||
//开始为 5A 5AA
|
||||
if (tempBuffer[0] != 0x5A && tempBuffer[1] != 0x5A) {
|
||||
if (!isStopRead && !ThreadPoolManager.getExecutor().isShutdown()) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> parseTheData(hexString.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint({"SetTextI18n", "UseCompatLoadingForDrawables", "DefaultLocale"})
|
||||
protected void parseTheData(String hex) {
|
||||
byte[] byteArray = hexStringToByteArray(new StringBuilder(hex));
|
||||
List<Integer> numList = new ArrayList<>();
|
||||
for (int i = 0; i < byteArray.length / 2; i++) {
|
||||
int value = byteArray[2 * i + 1] * 256 + (byteArray[2 * i] & 0xFF);
|
||||
numList.add(value);
|
||||
}
|
||||
int sum = 0;
|
||||
for (int num : numList) {
|
||||
sum += num;
|
||||
}
|
||||
List<Double> pixelTempList = new ArrayList<>();
|
||||
for (int i = 2; i < numList.size(); i++) {
|
||||
pixelTempList.add(numList.get(i) / 100.0);
|
||||
}
|
||||
Double maxValue = pixelTempList.isEmpty() ? null : Collections.max((Collection<? extends Double>) pixelTempList);
|
||||
try {
|
||||
pixelTempList.remove(0);
|
||||
pixelTempList.remove(0);
|
||||
if (maxValue > 30.0 && maxValue < 42.0) {
|
||||
binding.celsius.setText(String.format("%.1f", maxValue));
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
Log.e(TAG, "parseTheData: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将map中key对应的value增1回传
|
||||
|
|
@ -769,7 +699,7 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
}
|
||||
requestFeatureStatusMap.put(requestId, RequestFeatureStatus.SUCCEED);
|
||||
if (faceHelper != null) {
|
||||
if (!isStartUpload){
|
||||
if (!isStartUpload) {
|
||||
isStartUpload = true;
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
userInfo = AppDatabase.getDatabase(requireContext()).userDao().getUserInfoById(compareResult.getCustId());
|
||||
|
|
@ -778,10 +708,9 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
requireActivity().runOnUiThread(() -> {
|
||||
binding.code.setText(userInfo.getAccId());
|
||||
binding.name.setText(userInfo.getUserName());
|
||||
binding.sex.setText(userInfo.getLoginType());
|
||||
binding.sex.setText(userInfo.getLoginType().equals("0") ? "男" : "女");
|
||||
binding.phone.setText(userInfo.getPhone());
|
||||
binding.postName.setText(userInfo.getNickName());
|
||||
//上传脸部照片
|
||||
uploadFaceImage();
|
||||
});
|
||||
});
|
||||
|
|
@ -811,7 +740,7 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
});
|
||||
}
|
||||
|
||||
private void uploadFaceImage(){
|
||||
private void uploadFaceImage() {
|
||||
Log.e(TAG, "uploadFaceImage: 开始上传人脸照片");
|
||||
//执行拍照并上传
|
||||
if (cameraHelper != null) {
|
||||
|
|
@ -836,6 +765,7 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
// 拍照完成后,继续预览,保持相机活性
|
||||
cameraHelper.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTakePictureFailed(Exception e) {
|
||||
Log.e(TAG, "拍照失败: " + e.getMessage());
|
||||
|
|
@ -844,10 +774,11 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
cameraHelper.start();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
isStartUpload = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传照片
|
||||
* 使用OkHttpService上传图片到服务器
|
||||
|
|
@ -879,14 +810,14 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
if (photoResponse == null) {
|
||||
isStartUpload = false;
|
||||
requireActivity().runOnUiThread(() -> XToastUtils.error("图片上传失败,请重试!"));
|
||||
}else{
|
||||
} else {
|
||||
Log.e(TAG, "上传图片成功: " + photoResponse.getUrl());
|
||||
// 更新用户信息中的头像URL
|
||||
if (userInfo != null) {
|
||||
userInfo.setFaceCheckImg(photoResponse.getUrl());
|
||||
userInfo.setTemperature(binding.celsius.getText().toString());
|
||||
((MainActivity)getActivity()).updateUserInfo(userInfo);
|
||||
((MainActivity)getActivity()).updateView(3);
|
||||
((MainActivity) getActivity()).updateUserInfo(userInfo);
|
||||
binding.getRoot().postDelayed(() -> ((MainActivity) getActivity()).updateView(3), 1000);
|
||||
Log.e(TAG, "更新用户信息中的脸部照片: " + userInfo.getFaceCheckImg());
|
||||
} else {
|
||||
isStartUpload = false;
|
||||
|
|
@ -903,14 +834,6 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
}
|
||||
});
|
||||
}
|
||||
public byte[] hexStringToByteArray(StringBuilder hexString) {
|
||||
String[] hexArray = hexString.toString().trim().split("\\s+");
|
||||
byte[] byteArray = new byte[hexArray.length];
|
||||
for (int i = 0; i < hexArray.length; i++) {
|
||||
byteArray[i] = (byte) Integer.parseInt(hexArray[i], 16);
|
||||
}
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListeners() {
|
||||
|
|
@ -919,7 +842,7 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
isStopRead = true;
|
||||
getActivity().unregisterReceiver(broadcastReceiver);
|
||||
if (cameraHelper != null) {
|
||||
cameraHelper.release();
|
||||
cameraHelper = null;
|
||||
|
|
@ -936,26 +859,6 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
|
|||
flEngine.unInit();
|
||||
flEngine = null;
|
||||
}
|
||||
// if (serialPort != null) {
|
||||
// serialPort.close();
|
||||
// serialPort = null;
|
||||
// }
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error closing output stream: " + e.getMessage());
|
||||
}
|
||||
outputStream = null;
|
||||
}
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error closing input stream: " + e.getMessage());
|
||||
}
|
||||
inputStream = null;
|
||||
}
|
||||
if (delayFaceTaskCompositeDisposable != null && !delayFaceTaskCompositeDisposable.isDisposed()) {
|
||||
delayFaceTaskCompositeDisposable.clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ public class UpdateBasicData {
|
|||
public ResponseVo getDeviceBase() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("deviceSn", AppUtil.getSn(context));
|
||||
Log.e(TAG, "getDeviceBase AppUtil.getSn(context): " + AppUtil.getSn(context));
|
||||
String jsonString = json.toString();
|
||||
MediaType mediaType = MediaType.parse(MEDIA_TYPE);
|
||||
// 创建 RequestBody
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -152,18 +152,19 @@
|
|||
android:id="@+id/celsius"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="00.0"
|
||||
android:text="30.0"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginEnd="25dp"
|
||||
android:textColor="#4C81F4"
|
||||
android:textFontWeight="1000"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="℃"
|
||||
android:layout_gravity="end"
|
||||
android:textColor="#606060"
|
||||
android:text="℃"
|
||||
android:textColor="#4C81F4"
|
||||
android:textFontWeight="1000"
|
||||
android:textSize="25sp" />
|
||||
|
||||
|
|
|
|||
|
|
@ -22,16 +22,16 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="欢迎登录"
|
||||
android:fontFamily="@font/source_han_sans_cn_bold"
|
||||
android:textColor="#333333"
|
||||
android:textFontWeight="1000"
|
||||
android:textSize="35sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginTop="22dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="welcome to login in"
|
||||
android:textColor="#AFAFAF"
|
||||
|
|
|
|||
Loading…
Reference in New Issue