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="选择班组:" />