Android代码12月6日提交

This commit is contained in:
Levi 2024-12-06 23:51:40 +08:00
parent ebf09cae36
commit 876caec3c6
12 changed files with 31 additions and 36 deletions

View File

@ -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
}

View File

@ -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);

View File

@ -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);

View File

@ -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<Result> call, retrofit2.Response<Result> 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();
}
}

View File

@ -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<Result> call, Response<Result> 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();
}
}

View File

@ -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<Result> call, Response<Result> 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();
}
}

View File

@ -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()+"");

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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"