增加 - 登录页面记录班组

master
wangh 4 months ago
parent 6d749568ef
commit 488407ed9d

@ -59,6 +59,18 @@ public class MainActivity extends BaseActivity {
List<TeamBeen> teamBeens = gson.fromJson(gson.toJson(response.body().getData()), new TypeToken<List<TeamBeen>>() { List<TeamBeen> teamBeens = gson.fromJson(gson.toJson(response.body().getData()), new TypeToken<List<TeamBeen>>() {
}.getType()); }.getType());
user.setTeamBeens(teamBeens); 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(); getPda();
@ -125,10 +137,10 @@ public class MainActivity extends BaseActivity {
// 登录 // 登录
public void login(View view) { public void login(View view) {
// if (!loginState) { if (!loginState) {
// Toast.makeText(this, "设备未注册,不允许登录", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "设备未注册,不允许登录", Toast.LENGTH_SHORT).show();
// return; return;
// } }
String teamCode = user.getTeamCode(); String teamCode = user.getTeamCode();
if (teamCode==null||teamCode.isEmpty()) return; if (teamCode==null||teamCode.isEmpty()) return;
dialog.show(); dialog.show();

@ -26,8 +26,8 @@ import okhttp3.MediaType;
public abstract class BaseActivity extends AppCompatActivity { public abstract class BaseActivity extends AppCompatActivity {
private MyBroad receiver; private MyBroad receiver;
public static String url="http://192.168.137.1:8080"; // public static String url="http://192.168.0.102:8080";
// public static String url = "http://10.100.72.10:8080"; public static String url = "http://10.100.72.10:8080";
public ProgressDialog dialog; public ProgressDialog dialog;
public Gson gson; public Gson gson;
public MediaType JSON = MediaType.parse("application/json; charset=utf-8"); public MediaType JSON = MediaType.parse("application/json; charset=utf-8");

@ -1,5 +1,7 @@
package com.example.aucma_mes.entity; package com.example.aucma_mes.entity;
import java.util.Objects;
/** /**
* @author wanghao * @author wanghao
* @date 2023/12/13 14:00 * @date 2023/12/13 14:00
@ -23,4 +25,19 @@ public class TeamBeen {
public void setTeamName(String teamName) { public void setTeamName(String teamName) {
this.teamName = 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;
}
} }

@ -113,6 +113,7 @@
android:text="选择班组:" /> android:text="选择班组:" />
<Spinner <Spinner
android:id="@+id/login_team_spinner"
android:textAlignment="center" android:textAlignment="center"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

Loading…
Cancel
Save