diff --git a/app/build.gradle b/app/build.gradle index 169e624..6cd1819 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,6 @@ plugins { alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) } android { @@ -14,6 +15,9 @@ android { versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary true + } } buildTypes { @@ -26,6 +30,20 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + kotlinOptions { + jvmTarget = '1.8' + } + buildFeatures { + compose true + } + composeOptions { + kotlinCompilerExtensionVersion '1.5.1' + } + packaging { + resources { + excludes += '/META-INF/{AL2.0,LGPL2.1}' + } + } } dependencies { @@ -43,6 +61,14 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'com.google.android.material:material:1.5.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + implementation libs.lifecycle.runtime.ktx + implementation libs.activity.compose + implementation platform(libs.compose.bom) + implementation libs.ui + implementation libs.ui.graphics + implementation libs.ui.tooling.preview + implementation libs.material3 + implementation libs.activity testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' @@ -64,6 +90,10 @@ dependencies { implementation 'io.github.scwang90:refresh-header-material:2.0.5' //谷歌刷新头 implementation 'io.github.scwang90:refresh-header-two-level:2.0.5' //二级刷新头 implementation 'io.github.scwang90:refresh-footer-ball:2.0.5' //球脉冲加载 - implementation 'io.github.scwang90:refresh-footer-classics:2.0.5' //经典加载 + implementation 'io.github.scwang90:refresh-footer-classics:2.0.5' + androidTestImplementation platform(libs.compose.bom) + androidTestImplementation libs.ui.test.junit4 + debugImplementation libs.ui.tooling + debugImplementation libs.ui.test.manifest//经典加载 } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 47e8945..3fb38c0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,9 @@ android:supportsRtl="true" android:theme="@style/Theme.MyApplication" android:usesCleartextTraffic="true"> + @@ -45,30 +48,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Action/Action2.java b/app/src/main/java/com/c202101020117/Action/Action2.java index 76b2d9a..59d09dd 100644 --- a/app/src/main/java/com/c202101020117/Action/Action2.java +++ b/app/src/main/java/com/c202101020117/Action/Action2.java @@ -58,7 +58,7 @@ public class Action2 extends AppCompatActivity { recyclerView.setAdapter(myAdapter); recyclerView.setLayoutManager(new LinearLayoutManager(this)); - back = findViewById(R.id.textView67); + back = findViewById(R.id.textView101); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -149,6 +149,7 @@ public class Action2 extends AppCompatActivity { @Override //每个条目加载一次,该方法就会被调用一次 public void onBindViewHolder(@NonNull MyViewHoler holder, int position) { + holder.idTv.setText(drugs.rows.get(position).id+""); holder.DnoTv.setText(drugs.rows.get(position).dno); holder.DnameTv.setText(drugs.rows.get(position).name); holder.SnoTv.setText(drugs.rows.get(position).sno); @@ -188,6 +189,7 @@ public class Action2 extends AppCompatActivity { //缓存列表数据 public class MyViewHoler extends RecyclerView.ViewHolder{ + TextView idTv; TextView DnoTv; TextView DnameTv; TextView SnoTv; @@ -200,11 +202,12 @@ public class Action2 extends AppCompatActivity { public MyViewHoler(@NonNull View itemView) { super(itemView); + idTv = itemView.findViewById(R.id.textView73); DnoTv = itemView.findViewById(R.id.textView58); DnameTv = itemView.findViewById(R.id.textView55); SnoTv = itemView.findViewById(R.id.textView61); MFDTv = itemView.findViewById(R.id.textView71); - EXPTv = itemView.findViewById(R.id.textView73); + EXPTv = itemView.findViewById(R.id.textView87); DatediffTv = itemView.findViewById(R.id.textView62); QuantityTv = itemView.findViewById(R.id.textView59); imageView = itemView.findViewById(R.id.imageView15); diff --git a/app/src/main/java/com/c202101020117/Action/Action3.java b/app/src/main/java/com/c202101020117/Action/Action3.java index 18296da..3bbd157 100644 --- a/app/src/main/java/com/c202101020117/Action/Action3.java +++ b/app/src/main/java/com/c202101020117/Action/Action3.java @@ -1,17 +1,62 @@ package com.c202101020117.Action; import androidx.appcompat.app.AppCompatActivity; + +import android.content.SharedPreferences; import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; + import com.c202101020117.R; import com.gyf.immersionbar.ImmersionBar; public class Action3 extends AppCompatActivity { + TextView back; + EditText text1; + EditText text2; + EditText text3; + EditText text4; + TextView confirm; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_action3); ImmersionBar.with(this).init(); + + back = findViewById(R.id.textView33); + text1 = findViewById(R.id.editTextText30); + text2 = findViewById(R.id.editTextText32); + text3 = findViewById(R.id.editTextText33); + text4 = findViewById(R.id.editTextText31); + confirm = findViewById(R.id.textView204); + + SharedPreferences sharedPreferences = getSharedPreferences("action6", MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + Boolean need = sharedPreferences.getBoolean("need", false); + + if (need) { + text1.setText(sharedPreferences.getString("Dno", "")); + text2.setText(sharedPreferences.getString("MFD", "")); + text3.setText(sharedPreferences.getString("EXP", "")); + text4.setText(sharedPreferences.getString("Quantity", "")); + editor.clear(); + editor.commit(); + } else { + text1.setText(""); + text2.setText(""); + text3.setText(""); + text4.setText(""); + } + + confirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + } + }); } } \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Action/Action6.java b/app/src/main/java/com/c202101020117/Action/Action6.java new file mode 100644 index 0000000..511064d --- /dev/null +++ b/app/src/main/java/com/c202101020117/Action/Action6.java @@ -0,0 +1,217 @@ +package com.c202101020117.Action; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.bumptech.glide.Glide; +import com.c202101020117.AppConctroller; +import com.c202101020117.Login; +import com.c202101020117.R; +import com.c202101020117.package1.Drug2ListResult; +import com.c202101020117.package1.RYApi; +import com.gyf.immersionbar.ImmersionBar; +import com.scwang.smart.refresh.footer.ClassicsFooter; +import com.scwang.smart.refresh.header.ClassicsHeader; +import com.scwang.smart.refresh.layout.SmartRefreshLayout; +import com.scwang.smart.refresh.layout.api.RefreshLayout; +import com.scwang.smart.refresh.layout.listener.OnRefreshListener; +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class Action6 extends AppCompatActivity { + + RecyclerView recyclerView; + MyAdapter myAdapter; + TextView back; + SmartRefreshLayout smartRefreshLayout; + + Drug2ListResult drugs; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_action6); + ImmersionBar.with(this).init(); + + //添加Activity到容器中 + AppConctroller.addActivity(this); + + myAdapter = new MyAdapter(); + recyclerView = findViewById(R.id.recyclerview6); + recyclerView.setAdapter(myAdapter); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + + back = findViewById(R.id.textView103); + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + AppConctroller.removeActivity(Action6.this); + finish(); + } + }); + + SharedPreferences sharedPreferences = getSharedPreferences("user", Activity.MODE_PRIVATE); + String token = sharedPreferences.getString("token", null); + + //获取数据 + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("http://10.138.63.204:8080/") + .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 + .build(); + RYApi api = retrofit.create(RYApi.class); + + Call drug2ListResultCall = api.getDateQuantityList("Bearer " + token); + drug2ListResultCall.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + drugs = response.body(); + if(drugs.code == 200){ + myAdapter.notifyDataSetChanged(); + } + if(drugs.code == 401){ + Toast.makeText(Action6.this, "请重新登录", Toast.LENGTH_LONG).show(); + Intent intent = new Intent(Action6.this, Login.class); + startActivity(intent); + AppConctroller.exit(); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + + } + }); + + //列表刷新 + smartRefreshLayout=findViewById(R.id.smarlayout6); + smartRefreshLayout.setRefreshHeader(new ClassicsHeader(this)); + smartRefreshLayout.setRefreshFooter(new ClassicsFooter(this)); + smartRefreshLayout.setOnRefreshListener(new OnRefreshListener() { + @Override + public void onRefresh(@NonNull RefreshLayout refreshLayout) { + + Call drug2ListResultCall = api.getDateQuantityList("Bearer " + token); + drug2ListResultCall.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + drugs = response.body(); + if(drugs.code == 200){ + smartRefreshLayout.finishRefresh(500); + myAdapter.notifyDataSetChanged(); + } + if(drugs.code == 401){ + Toast.makeText(Action6.this, "请重新登录", Toast.LENGTH_LONG).show(); + Intent intent = new Intent(Action6.this, Login.class); + startActivity(intent); + AppConctroller.exit(); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + + } + }); + } + }); + } + + public class MyAdapter extends RecyclerView.Adapter{ + + @NonNull + @Override + //加载布局文件 + public MyViewHoler onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(Action6.this) + .inflate(R.layout.item3_layout,parent,false); + MyViewHoler myViewHoler = new MyViewHoler(view); + return myViewHoler; + } + + @Override + //每个条目加载一次,该方法就会被调用一次 + public void onBindViewHolder(@NonNull Action6.MyViewHoler holder, int position) { + holder.idTv.setText(drugs.rows.get(position).id+""); + holder.DnoTv.setText(drugs.rows.get(position).dno); + holder.DnameTv.setText(drugs.rows.get(position).name); + holder.SnoTv.setText(drugs.rows.get(position).sno); + holder.MFDTv.setText(drugs.rows.get(position).mFD); + holder.EXPTv.setText(drugs.rows.get(position).eXP); + holder.QuantityTv.setText(drugs.rows.get(position).quantity+""); + holder.DatediffTv.setText((int)(drugs.rows.get(position).datediff)+""); + Glide.with(Action6.this).load(drugs.rows.get(position).picture).into(holder.imageView); + holder.constraintLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + SharedPreferences sharedPreferences = getSharedPreferences("action6",MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putBoolean("need",true); + editor.putInt("id",holder.idTv.getId()); + editor.putString("Dno",holder.DnoTv.getText()+""); + editor.putString("MFD",holder.MFDTv.getText()+""); + editor.putString("EXP",holder.EXPTv.getText()+""); + editor.putString("Quantity",holder.QuantityTv.getText()+""); + editor.commit(); + + Intent intent = new Intent(Action6.this, Action3.class); + startActivity(intent); + } + }); + } + + @Override + //用来控制限制列表条数 + public int getItemCount() { + if(drugs != null) + return drugs.rows.size(); + else + return 0; + } + } + + //缓存列表数据 + public class MyViewHoler extends RecyclerView.ViewHolder{ + + TextView idTv; + TextView DnoTv; + TextView DnameTv; + TextView SnoTv; + TextView MFDTv; + TextView EXPTv; + TextView DatediffTv; + TextView QuantityTv; + ImageView imageView; + ConstraintLayout constraintLayout; + + public MyViewHoler(@NonNull View itemView) { + super(itemView); + idTv = itemView.findViewById(R.id.textView73); + DnoTv = itemView.findViewById(R.id.textView58); + DnameTv = itemView.findViewById(R.id.textView55); + SnoTv = itemView.findViewById(R.id.textView61); + MFDTv = itemView.findViewById(R.id.textView71); + EXPTv = itemView.findViewById(R.id.textView87); + DatediffTv = itemView.findViewById(R.id.textView62); + QuantityTv = itemView.findViewById(R.id.textView59); + imageView = itemView.findViewById(R.id.imageView15); + constraintLayout = itemView.findViewById(R.id.action2_item); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Fragment/ScreeningFragment.java b/app/src/main/java/com/c202101020117/Fragment/ScreeningFragment.java index da63457..5495a7e 100644 --- a/app/src/main/java/com/c202101020117/Fragment/ScreeningFragment.java +++ b/app/src/main/java/com/c202101020117/Fragment/ScreeningFragment.java @@ -9,6 +9,7 @@ import android.view.View; import android.view.ViewGroup; import com.c202101020117.Action.Action1; import com.c202101020117.Action.Action2; +import com.c202101020117.Action.Action6; import com.c202101020117.R; @@ -16,6 +17,7 @@ public class ScreeningFragment extends Fragment { ConstraintLayout action1; ConstraintLayout action2; + ConstraintLayout action6; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -25,6 +27,7 @@ public class ScreeningFragment extends Fragment { action1 = view.findViewById(R.id.constraintLayout9); action2 = view.findViewById(R.id.constraintLayout8); + action6 = view.findViewById(R.id.constraintLayout23); action1.setOnClickListener(new View.OnClickListener() { @Override @@ -42,6 +45,14 @@ public class ScreeningFragment extends Fragment { } }); + action6.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(getActivity(), Action6.class); + startActivity(intent); + } + }); + return view; } } \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/package1/Drug2ListResult.java b/app/src/main/java/com/c202101020117/package1/Drug2ListResult.java index 73fb528..b5fff92 100644 --- a/app/src/main/java/com/c202101020117/package1/Drug2ListResult.java +++ b/app/src/main/java/com/c202101020117/package1/Drug2ListResult.java @@ -17,7 +17,7 @@ public class Drug2ListResult { public Object updateBy; public Object updateTime; public Object remark; - public Object id; + public Integer id; public String dno; public String name; public String picture; diff --git a/app/src/main/java/com/c202101020117/package1/RYApi.java b/app/src/main/java/com/c202101020117/package1/RYApi.java index 5cf5347..0283d04 100644 --- a/app/src/main/java/com/c202101020117/package1/RYApi.java +++ b/app/src/main/java/com/c202101020117/package1/RYApi.java @@ -33,6 +33,10 @@ public interface RYApi { @GET("/system/adrug/specificationlist") Call getDrugSpecificationByDno(@Header("Authorization") String token, @Query("dno") String dno); + //http://127.0.0.1:8080/system/adrug/datequantitylist + @GET("/system/adrug/datequantitylist") + Call getDateQuantityList(@Header("Authorization") String token); + //http://127.0.0.1:8080/system/adrug/undersupplylist @GET("/system/adrug/undersupplylist") Call getUndersupplyDrugList(@Header("Authorization") String token); diff --git a/app/src/main/res/layout/activity_action1.xml b/app/src/main/res/layout/activity_action1.xml index 79bc17f..cfc06fa 100644 --- a/app/src/main/res/layout/activity_action1.xml +++ b/app/src/main/res/layout/activity_action1.xml @@ -46,11 +46,6 @@ + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_action2.xml b/app/src/main/res/layout/activity_action2.xml index d87c7fa..1ccb559 100644 --- a/app/src/main/res/layout/activity_action2.xml +++ b/app/src/main/res/layout/activity_action2.xml @@ -8,7 +8,7 @@ tools:context=".Action.Action2"> + app:layout_constraintTop_toTopOf="@+id/textView100" /> + app:layout_constraintTop_toBottomOf="@+id/textView100" + app:layout_constraintVertical_bias="0.0"> + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_action3.xml b/app/src/main/res/layout/activity_action3.xml index 237cd03..143d4a9 100644 --- a/app/src/main/res/layout/activity_action3.xml +++ b/app/src/main/res/layout/activity_action3.xml @@ -46,5 +46,120 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_action6.xml b/app/src/main/res/layout/activity_action6.xml new file mode 100644 index 0000000..00f63fb --- /dev/null +++ b/app/src/main/res/layout/activity_action6.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_screening.xml b/app/src/main/res/layout/fragment_screening.xml index 283ba53..78c7886 100644 --- a/app/src/main/res/layout/fragment_screening.xml +++ b/app/src/main/res/layout/fragment_screening.xml @@ -10,19 +10,35 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + + + + app:layout_constraintTop_toBottomOf="@+id/constraintLayout23"> diff --git a/app/src/main/res/layout/item3_layout.xml b/app/src/main/res/layout/item3_layout.xml index 75618ac..be003af 100644 --- a/app/src/main/res/layout/item3_layout.xml +++ b/app/src/main/res/layout/item3_layout.xml @@ -16,8 +16,19 @@ android:background="@drawable/shape" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent"> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="1.0"> + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4cacd0f..0084edb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,4 +2,5 @@ My Application Hello blank fragment + Action6 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 565f8c2..5bec31d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { alias(libs.plugins.android.application) apply false + alias(libs.plugins.kotlin.android) apply false } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bdc2b99..19dd738 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,10 @@ appcompat = "1.6.1" material = "1.10.0" activity = "1.8.0" constraintlayout = "2.1.4" +kotlin = "1.9.0" +lifecycleRuntimeKtx = "2.6.1" +activityCompose = "1.8.0" +composeBom = "2024.04.01" [libraries] junit = { group = "junit", name = "junit", version.ref = "junit" } @@ -16,7 +20,18 @@ appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "a material = { group = "com.google.android.material", name = "material", version.ref = "material" } activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } +lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } +activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } +compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } +ui = { group = "androidx.compose.ui", name = "ui" } +ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } +ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } +ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } +material3 = { group = "androidx.compose.material3", name = "material3" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }