From 876caec3c682af8aaf5bee56016546dbba70cad9 Mon Sep 17 00:00:00 2001 From: Levi Date: Fri, 6 Dec 2024 23:51:40 +0800 Subject: [PATCH] =?UTF-8?q?Android=E4=BB=A3=E7=A0=8112=E6=9C=886=E6=97=A5?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ---- .../com/c202101020117/Action/Action1.java | 2 +- .../com/c202101020117/Action/Action2.java | 2 +- .../com/c202101020117/Action/Action3.java | 19 ++++++++++--------- .../com/c202101020117/Action/Action4.java | 13 ++++++------- .../com/c202101020117/Action/Action5.java | 13 ++++++------- .../com/c202101020117/Action/Action6.java | 4 ++-- .../Action/DetailedInformation.java | 2 +- .../Fragment/DrugListFragment.java | 2 +- .../c202101020117/Fragment/HomeFragment.java | 2 +- .../main/java/com/c202101020117/Login.java | 2 +- app/src/main/res/layout/activity_action3.xml | 2 +- 12 files changed, 31 insertions(+), 36 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6cd1819..ce514cf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,5 @@ plugins { alias(libs.plugins.android.application) - alias(libs.plugins.kotlin.android) } android { @@ -30,9 +29,6 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } buildFeatures { compose true } diff --git a/app/src/main/java/com/c202101020117/Action/Action1.java b/app/src/main/java/com/c202101020117/Action/Action1.java index 3a1f42b..d4c58b8 100644 --- a/app/src/main/java/com/c202101020117/Action/Action1.java +++ b/app/src/main/java/com/c202101020117/Action/Action1.java @@ -73,7 +73,7 @@ public class Action1 extends AppCompatActivity { //获取数据 Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); diff --git a/app/src/main/java/com/c202101020117/Action/Action2.java b/app/src/main/java/com/c202101020117/Action/Action2.java index 59d09dd..b0c468d 100644 --- a/app/src/main/java/com/c202101020117/Action/Action2.java +++ b/app/src/main/java/com/c202101020117/Action/Action2.java @@ -72,7 +72,7 @@ public class Action2 extends AppCompatActivity { //获取数据 Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); diff --git a/app/src/main/java/com/c202101020117/Action/Action3.java b/app/src/main/java/com/c202101020117/Action/Action3.java index 5ac974f..d3d489b 100644 --- a/app/src/main/java/com/c202101020117/Action/Action3.java +++ b/app/src/main/java/com/c202101020117/Action/Action3.java @@ -32,6 +32,7 @@ public class Action3 extends AppCompatActivity { EditText text3; EditText text4; TextView confirm; + int id; @Override protected void onCreate(Bundle savedInstanceState) { @@ -54,6 +55,7 @@ public class Action3 extends AppCompatActivity { Boolean need = sharedPreferences.getBoolean("need", false); if (need) { + id = sharedPreferences.getInt("id", 0); text1.setText(sharedPreferences.getString("Dno", "")); text2.setText(sharedPreferences.getString("MFD", "")); text3.setText(sharedPreferences.getString("EXP", "")); @@ -71,7 +73,7 @@ public class Action3 extends AppCompatActivity { @Override public void onClick(View view) { DrugInfo drugInfo = new DrugInfo(); - int id = sharedPreferences.getInt("id", 0); + String dno = text1.getText() + ""; String MFD = text2.getText() + ""; String EXP = text3.getText() + ""; @@ -88,7 +90,7 @@ public class Action3 extends AppCompatActivity { //获取数据 Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); @@ -98,18 +100,17 @@ public class Action3 extends AppCompatActivity { @Override public void onResponse(Call call, retrofit2.Response response) { Result result = response.body(); - if (result.code == 200) { - Toast.makeText(Action3.this, "修改成功", Toast.LENGTH_LONG).show(); - Intent intent = new Intent(Action3.this, Action6.class); - startActivity(intent); - }else{ - Toast.makeText(Action3.this, "修改失败", Toast.LENGTH_LONG).show(); - } if (result.code == 401){ Toast.makeText(Action3.this, "请重新登录", Toast.LENGTH_LONG).show(); Intent intent = new Intent(Action3.this, Login.class); startActivity(intent); AppConctroller.exit(); + }else if (result.code == 200) { + Toast.makeText(Action3.this, "修改成功", Toast.LENGTH_LONG).show(); + Intent intent = new Intent(Action3.this, Action6.class); + startActivity(intent); + }else{ + Toast.makeText(Action3.this, "修改失败", Toast.LENGTH_LONG).show(); } } diff --git a/app/src/main/java/com/c202101020117/Action/Action4.java b/app/src/main/java/com/c202101020117/Action/Action4.java index 3d8b843..8e30c03 100644 --- a/app/src/main/java/com/c202101020117/Action/Action4.java +++ b/app/src/main/java/com/c202101020117/Action/Action4.java @@ -70,7 +70,7 @@ public class Action4 extends AppCompatActivity { //获取数据 Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); @@ -86,17 +86,16 @@ public class Action4 extends AppCompatActivity { @Override public void onResponse(Call call, Response response) { Result result = response.body(); - if (result.code == 200) { - Toast.makeText(Action4.this, "增添成功", Toast.LENGTH_LONG).show(); - finish(); - } else { - Toast.makeText(Action4.this, "数据输入错误", Toast.LENGTH_LONG).show(); - } if(result.code == 401){ Toast.makeText(Action4.this, "请重新登录", Toast.LENGTH_LONG).show(); Intent intent = new Intent(Action4.this, Login.class); startActivity(intent); AppConctroller.exit(); + }else if (result.code == 200) { + Toast.makeText(Action4.this, "增添成功", Toast.LENGTH_LONG).show(); + finish(); + } else { + Toast.makeText(Action4.this, "数据输入错误", Toast.LENGTH_LONG).show(); } } diff --git a/app/src/main/java/com/c202101020117/Action/Action5.java b/app/src/main/java/com/c202101020117/Action/Action5.java index 7f15248..502684e 100644 --- a/app/src/main/java/com/c202101020117/Action/Action5.java +++ b/app/src/main/java/com/c202101020117/Action/Action5.java @@ -73,7 +73,7 @@ public class Action5 extends AppCompatActivity { //获取数据 Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); @@ -88,17 +88,16 @@ public class Action5 extends AppCompatActivity { @Override public void onResponse(Call call, Response response) { Result result = response.body(); - if (result.code == 200) { - Toast.makeText(Action5.this, "删除成功", Toast.LENGTH_LONG).show(); - finish(); - } else { - Toast.makeText(Action5.this, "数据输入错误", Toast.LENGTH_LONG).show(); - } if(result.code == 401){ Toast.makeText(Action5.this, "请重新登录", Toast.LENGTH_LONG).show(); Intent intent = new Intent(Action5.this, Login.class); startActivity(intent); AppConctroller.exit(); + }else if (result.code == 200) { + Toast.makeText(Action5.this, "删除成功", Toast.LENGTH_LONG).show(); + finish(); + } else { + Toast.makeText(Action5.this, "数据输入错误", Toast.LENGTH_LONG).show(); } } diff --git a/app/src/main/java/com/c202101020117/Action/Action6.java b/app/src/main/java/com/c202101020117/Action/Action6.java index 511064d..c1e0208 100644 --- a/app/src/main/java/com/c202101020117/Action/Action6.java +++ b/app/src/main/java/com/c202101020117/Action/Action6.java @@ -72,7 +72,7 @@ public class Action6 extends AppCompatActivity { //获取数据 Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); @@ -163,7 +163,7 @@ public class Action6 extends AppCompatActivity { SharedPreferences sharedPreferences = getSharedPreferences("action6",MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean("need",true); - editor.putInt("id",holder.idTv.getId()); + editor.putInt("id",Integer.parseInt(holder.idTv.getText()+"")); editor.putString("Dno",holder.DnoTv.getText()+""); editor.putString("MFD",holder.MFDTv.getText()+""); editor.putString("EXP",holder.EXPTv.getText()+""); diff --git a/app/src/main/java/com/c202101020117/Action/DetailedInformation.java b/app/src/main/java/com/c202101020117/Action/DetailedInformation.java index 5b93069..b6e8d10 100644 --- a/app/src/main/java/com/c202101020117/Action/DetailedInformation.java +++ b/app/src/main/java/com/c202101020117/Action/DetailedInformation.java @@ -75,7 +75,7 @@ public class DetailedInformation extends AppCompatActivity { //获取数据 Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); diff --git a/app/src/main/java/com/c202101020117/Fragment/DrugListFragment.java b/app/src/main/java/com/c202101020117/Fragment/DrugListFragment.java index dd6e529..6035bb8 100644 --- a/app/src/main/java/com/c202101020117/Fragment/DrugListFragment.java +++ b/app/src/main/java/com/c202101020117/Fragment/DrugListFragment.java @@ -65,7 +65,7 @@ public class DrugListFragment extends Fragment { //获取数据 Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); diff --git a/app/src/main/java/com/c202101020117/Fragment/HomeFragment.java b/app/src/main/java/com/c202101020117/Fragment/HomeFragment.java index 2cd61f9..b73daf2 100644 --- a/app/src/main/java/com/c202101020117/Fragment/HomeFragment.java +++ b/app/src/main/java/com/c202101020117/Fragment/HomeFragment.java @@ -43,7 +43,7 @@ public class HomeFragment extends Fragment { String token = sharedPreferences.getString("token", null); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); diff --git a/app/src/main/java/com/c202101020117/Login.java b/app/src/main/java/com/c202101020117/Login.java index 6595269..82a9041 100644 --- a/app/src/main/java/com/c202101020117/Login.java +++ b/app/src/main/java/com/c202101020117/Login.java @@ -40,7 +40,7 @@ public class Login extends AppCompatActivity { login = findViewById(R.id.button); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://10.138.63.204:8080/") + .baseUrl("http://10.135.18.27:8080/") .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 .build(); RYApi api = retrofit.create(RYApi.class); diff --git a/app/src/main/res/layout/activity_action3.xml b/app/src/main/res/layout/activity_action3.xml index 143d4a9..2f1e6a4 100644 --- a/app/src/main/res/layout/activity_action3.xml +++ b/app/src/main/res/layout/activity_action3.xml @@ -74,7 +74,7 @@ android:id="@+id/editTextText32" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginEnd="36dp" + android:layout_marginEnd="24dp" android:ems="10" android:gravity="center" android:inputType="textPersonName"