From 488407ed9d61c079c5951a61ce4033de381e5342 Mon Sep 17 00:00:00 2001 From: wangh <123456> Date: Tue, 30 Jul 2024 15:41:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20-=20=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=AE=B0=E5=BD=95=E7=8F=AD=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/aucma_mes/MainActivity.java | 20 +++++++++++++++---- .../example/aucma_mes/base/BaseActivity.java | 4 ++-- .../example/aucma_mes/entity/TeamBeen.java | 17 ++++++++++++++++ app/src/main/res/layout/activity_main.xml | 1 + 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/example/aucma_mes/MainActivity.java b/app/src/main/java/com/example/aucma_mes/MainActivity.java index de982f1..a1a9075 100644 --- a/app/src/main/java/com/example/aucma_mes/MainActivity.java +++ b/app/src/main/java/com/example/aucma_mes/MainActivity.java @@ -59,6 +59,18 @@ public class MainActivity extends BaseActivity { List teamBeens = gson.fromJson(gson.toJson(response.body().getData()), new TypeToken>() { }.getType()); user.setTeamBeens(teamBeens); + String teamName = SharedPreferencesUtils.getstring("teamName", null); + if (teamName!=null){ + TeamBeen teamBeen=new TeamBeen(); + teamBeen.setTeamName(teamName); + int position = teamBeens.indexOf(teamBeen); + Log.e("TAG", "记录位置:" +position ); + binding.loginTeamSpinner.post(new Runnable() { + public void run() { + binding.loginTeamSpinner.setSelection(position); + } + }); + } } }); getPda(); @@ -125,10 +137,10 @@ public class MainActivity extends BaseActivity { // 登录 public void login(View view) { - // if (!loginState) { - // Toast.makeText(this, "设备未注册,不允许登录", Toast.LENGTH_SHORT).show(); - // return; - // } + if (!loginState) { + Toast.makeText(this, "设备未注册,不允许登录", Toast.LENGTH_SHORT).show(); + return; + } String teamCode = user.getTeamCode(); if (teamCode==null||teamCode.isEmpty()) return; dialog.show(); diff --git a/app/src/main/java/com/example/aucma_mes/base/BaseActivity.java b/app/src/main/java/com/example/aucma_mes/base/BaseActivity.java index 4b7248f..08f0f4e 100644 --- a/app/src/main/java/com/example/aucma_mes/base/BaseActivity.java +++ b/app/src/main/java/com/example/aucma_mes/base/BaseActivity.java @@ -26,8 +26,8 @@ import okhttp3.MediaType; public abstract class BaseActivity extends AppCompatActivity { private MyBroad receiver; - public static String url="http://192.168.137.1:8080"; - // public static String url = "http://10.100.72.10:8080"; + // public static String url="http://192.168.0.102:8080"; + public static String url = "http://10.100.72.10:8080"; public ProgressDialog dialog; public Gson gson; public MediaType JSON = MediaType.parse("application/json; charset=utf-8"); diff --git a/app/src/main/java/com/example/aucma_mes/entity/TeamBeen.java b/app/src/main/java/com/example/aucma_mes/entity/TeamBeen.java index 547c2c0..9f2803b 100644 --- a/app/src/main/java/com/example/aucma_mes/entity/TeamBeen.java +++ b/app/src/main/java/com/example/aucma_mes/entity/TeamBeen.java @@ -1,5 +1,7 @@ package com.example.aucma_mes.entity; +import java.util.Objects; + /** * @author wanghao * @date 2023/12/13 14:00 @@ -23,4 +25,19 @@ public class TeamBeen { public void setTeamName(String teamName) { this.teamName = teamName; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + TeamBeen teamBeen = (TeamBeen) o; + + return Objects.equals(teamName, teamBeen.teamName); + } + + @Override + public int hashCode() { + return teamName != null ? teamName.hashCode() : 0; + } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 4e70f38..31b26d0 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -113,6 +113,7 @@ android:text="选择班组:" />