问题修改

This commit is contained in:
jjLv 2025-08-21 15:47:05 +08:00
parent 322aa13332
commit 6df7e26e28
13 changed files with 96 additions and 39 deletions

View File

@ -936,10 +936,10 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
flEngine.unInit();
flEngine = null;
}
if (serialPort != null) {
serialPort.close();
serialPort = null;
}
// if (serialPort != null) {
// serialPort.close();
// serialPort = null;
// }
if (outputStream != null) {
try {
outputStream.close();

View File

@ -113,8 +113,10 @@ public class LoginFragment extends BaseFragment<ActivityLoginBinding> {
if (jsonObject.getIntValue("code") == 500) {
Log.e(TAG, "登录失败: " + jsonObject.getString("msg"));
requireActivity().runOnUiThread(() -> {
dialog.dismiss();
dialog = null;
if(dialog != null){
dialog.dismiss();
dialog = null;
}
XToastUtils.error(jsonObject.getString("msg"));
});
return;

View File

@ -376,6 +376,7 @@ public class PalmFragment extends BaseFragment<ActivityPlamBinding> {
saveImage(bytes);
}
} catch (Exception e) {
XToastUtils.error("处理图像时出错 ");
Log.e(TAG, "处理图像错误: " + e.getMessage());
} finally {
if (image != null) {

View File

@ -44,6 +44,7 @@ import okhttp3.RequestBody;
@Page(name = "起始页", anim = CoreAnim.none)
public class StartFragment extends BaseFragment<ActivityStartBinding> {
private OkHttpService service = new OkHttpService();
@NonNull
@Override
protected ActivityStartBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
@ -52,17 +53,21 @@ public class StartFragment extends BaseFragment<ActivityStartBinding> {
@Override
protected void initViews() {
binding.btnStart.setOnClickListener(view->{
binding.btnStart.setOnClickListener(view -> {
Log.d("StartFragment", "checkToken: 开始验证Token");
//验证token是否失效
checkToken(new ResponseCallBack(){
checkToken(new ResponseCallBack() {
@Override
public void onSuccess() {
requireActivity().runOnUiThread(() -> ((MainActivity) requireActivity()).updateView(2));
}
@Override
public void onFail(String msg) {
requireActivity().runOnUiThread(()-> XToastUtils.error("Token验证失败,请重新登录!"));
requireActivity().runOnUiThread(() -> {
((MainActivity) requireActivity()).updateView(-1);
XToastUtils.error("Token验证失败,请重新登录!");
});
}
});
});
@ -73,9 +78,9 @@ public class StartFragment extends BaseFragment<ActivityStartBinding> {
}
public void checkToken(ResponseCallBack callBack){
public void checkToken(ResponseCallBack callBack) {
Log.d("StartFragment", "checkToken: 开始验证Token");
ThreadPoolManager.getExecutor().execute(()->{
ThreadPoolManager.getExecutor().execute(() -> {
String url = WorkConfig.getBaseUrl() + "/api/android/device/checkToken";
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
String jsonString = json.toString();
@ -93,7 +98,7 @@ public class StartFragment extends BaseFragment<ActivityStartBinding> {
} else {
if (result.contains("操作成功")) {
// 发送广播或更新UI
callBack.onSuccess();
callBack.onSuccess();
} else {
// 发送广播或更新UI
callBack.onFail("Token验证失败");

View File

@ -25,10 +25,10 @@ public class WorkConfig {
throw new UnsupportedOperationException("Cannot instantiate utility class");
}
//本地
protected static String baseUrl = "http://192.168.0.34:48380/smart-canteen";
protected static String prefixesUrl = "http://192.168.0.34:48380";
// protected static String baseUrl = "http://192.168.0.244:48380/smart-canteen";
// protected static String prefixesUrl = "http://192.168.0.244:48380";
// protected static String baseUrl = "http://192.168.0.34:48380/smart-canteen";
// protected static String prefixesUrl = "http://192.168.0.34:48380";
protected static String baseUrl = "http://192.168.0.244:48380/smart-canteen";
protected static String prefixesUrl = "http://192.168.0.244:48380";
protected static String fileUrl = "http://192.168.0.14:9090/lnyst/";
protected static String updateUrl = "https://www.baidu.com";
protected static String serverUri = "tcp://192.168.0.244:1883";

View File

@ -0,0 +1,20 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient
android:angle="0"
android:endColor="@color/primary_dark"
android:startColor="@color/primary_dark" />
<corners android:radius="8dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:angle="0"
android:endColor="@color/primary"
android:startColor="@color/primary" />
<corners android:radius="8dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<stroke
android:width="1dp"
android:color="@color/edittext_border" />
<corners android:radius="8dp" />
</shape>

View File

@ -1,5 +1,8 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white"/>
<corners android:radius="5dp"/>
<stroke
android:width="1dp"
android:color="@color/edittext_border" />
<corners android:radius="8dp" />
</shape>

View File

@ -4,5 +4,5 @@
<solid android:color="#00000000" /> <!-- 透明 -->
<stroke
android:width="3dp"
android:color="#4BCFCF" /> <!-- 圆形边框(可选) -->
android:color="#6C92E4" /> <!-- 圆形边框(可选) -->
</shape>

View File

@ -0,0 +1,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="135"
android:endColor="#F5F7FA"
android:startColor="#E8EEF7" />
</shape>

View File

@ -155,7 +155,7 @@
android:text="00.0"
android:layout_gravity="end"
android:layout_marginEnd="25dp"
android:textColor="#606060"
android:textColor="#4C81F4"
android:textFontWeight="1000"
android:textSize="25sp" />
<TextView
@ -169,11 +169,14 @@
</FrameLayout>
<FrameLayout
android:id="@+id/face_rect_view_container"
android:layout_width="470dp"
android:layout_height="470dp"
android:background="@drawable/face_bg"
android:padding="1px"
android:layout_gravity="center">
<FrameLayout
android:id="@+id/face_rect_view_container"
android:layout_width="460dp"
android:layout_height="460dp"
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
@ -190,13 +193,17 @@
</LinearLayout>
<TextureView
android:id="@+id/texture_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="465dp"
android:layout_height="465dp"
android:layout_gravity="center"
/>
<com.bonus.canteen.face.widget.FaceRectView
android:id="@+id/face_rect_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_width="465dp"
android:layout_gravity="center"
android:layout_height="465dp" />
</FrameLayout>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"

View File

@ -6,10 +6,10 @@
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="800dp"
android:layout_height="500dp"
android:layout_width="900dp"
android:layout_height="600dp"
android:background="@drawable/title_gradient_bg"
android:padding="20dp"
android:padding="50dp"
android:layout_marginTop="-100dp"
android:orientation="vertical">
@ -17,7 +17,7 @@
android:layout_width="match_parent"
android:layout_height="100dp"
android:paddingLeft="@dimen/config_margin_10dp"
android:paddingRight="@dimen/config_margin_10dp">
android:paddingRight="70dp">
<TextView
android:layout_width="wrap_content"
@ -26,7 +26,7 @@
android:text="欢迎登录"
android:textColor="#333333"
android:textFontWeight="1000"
android:textSize="30sp" />
android:textSize="35sp" />
<TextView
android:layout_width="wrap_content"
@ -42,38 +42,38 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="@dimen/config_margin_20dp"
android:layout_marginTop="@dimen/config_margin_40dp"
android:paddingLeft="@dimen/config_margin_10dp"
android:paddingRight="@dimen/config_margin_10dp">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/et_username"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_height="80dp"
android:background="@drawable/edittext_border_white"
android:drawableStart="@drawable/ic_user"
android:paddingStart="0dp"
android:hint="请输入账号"
android:maxLength="11"
android:text="jkytj"
android:text="tqjsss"
tools:ignore="RtlSymmetry" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="@dimen/config_margin_20dp"
android:layout_marginTop="50dp"
android:paddingLeft="@dimen/config_margin_10dp"
android:paddingRight="@dimen/config_margin_10dp">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/et_password"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_height="80dp"
android:background="@drawable/edittext_border_white"
android:drawableStart="@drawable/ic_password"
android:paddingStart="0dp"
android:hint="请输入密码"
android:text="Bonus$2027"
android:text="Bonus$2031"
android:inputType="textPassword"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -81,14 +81,14 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center"
android:layout_marginTop="@dimen/config_margin_40dp"
android:layout_marginTop="60dp"
android:paddingLeft="@dimen/config_margin_10dp"
android:paddingRight="@dimen/config_margin_10dp">
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_height="65dp"
android:text="登录"
android:textColor="#FFFFFF"
android:background="@drawable/btn_border_bg_10_4c81f4"

View File

@ -4,7 +4,13 @@
<color name="colorPrimaryDark">#299EE3</color>
<color name="color_dark_green">#006e6b</color>
<color name="colorAccent">#299EE3</color>
<color name="primary">#4C81F4</color>
<color name="primary_dark">#3A6CD4</color>
<color name="text_primary">#333333</color>
<color name="text_secondary">#8A8A8A</color>
<color name="card_background">#FFFFFF</color>
<color name="edittext_border">#E0E0E0</color>
<color name="white">#FFFFFF</color>
<color name="config_color_select_bg">#FFF1F1F1</color>