commit c0ca9316e088e405f7fb9e5637150bf913ee683f Author: Levi Date: Sun Oct 27 23:18:07 2024 +0800 Android代码第一次提交 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..b3405b3 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +My Application \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..67850bd --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..0897082 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0ad17cb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..169e624 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,69 @@ +plugins { + alias(libs.plugins.android.application) +} + +android { + namespace 'com.c202101020117' + compileSdk 34 + + defaultConfig { + applicationId "com.c202101020117" + minSdk 24 + targetSdk 34 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + +// implementation libs.appcompat +// implementation libs.material +// implementation libs.activity +// implementation libs.constraintlayout +// testImplementation libs.junit +// androidTestImplementation libs.ext.junit +// androidTestImplementation libs.espresso.core + + implementation 'com.github.bumptech.glide:glide:4.4.0' + + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + implementation("com.squareup.okhttp3:okhttp:4.11.0") + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.retrofit2:converter-gson:2.9.0' + + // 基础依赖包,必须要依赖 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' + // kotlin扩展(可选) + implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' + // fragment快速实现(可选)已废弃 + implementation 'com.geyifeng.immersionbar:immersionbar-components:3.2.2' + + implementation 'io.github.scwang90:refresh-layout-kernel:2.0.5'//核心必须依赖 + implementation 'io.github.scwang90:refresh-header-classics:2.0.5'//经典刷新头 + implementation 'io.github.scwang90:refresh-header-radar:2.0.5'//雷达刷新头 + implementation 'io.github.scwang90:refresh-header-falsify:2.0.5'//虚拟刷新头 + 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' //经典加载 + +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/c202101020117/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/c202101020117/ExampleInstrumentedTest.java new file mode 100644 index 0000000..0c090fb --- /dev/null +++ b/app/src/androidTest/java/com/c202101020117/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.c202101020117; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.c202101020117", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..47e8945 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Action/Action1.java b/app/src/main/java/com/c202101020117/Action/Action1.java new file mode 100644 index 0000000..7cd579a --- /dev/null +++ b/app/src/main/java/com/c202101020117/Action/Action1.java @@ -0,0 +1,226 @@ +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.content.Intent; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +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.Home; +import com.c202101020117.Login; +import com.c202101020117.package1.Api; +import com.c202101020117.package1.Drug3; +import com.c202101020117.package1.InformationList; +import com.c202101020117.package1.MySQLiteOpenHelper; +import com.c202101020117.R; +import com.c202101020117.package1.Drug2; +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 java.util.ArrayList; +import java.util.List; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class Action1 extends AppCompatActivity { + + RecyclerView recyclerView; + MyAdapter myAdapter; + List drug2List = new ArrayList<>(); + TextView back; + List informationListBeans; + SmartRefreshLayout smartRefreshLayout; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_action1); + ImmersionBar.with(this).init(); + + informationListBeans = new ArrayList<>(); + + myAdapter = new MyAdapter(); + recyclerView = findViewById(R.id.recyclerView2); + recyclerView.setAdapter(myAdapter); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + + smartRefreshLayout=findViewById(R.id.smarlayout1); + smartRefreshLayout.setRefreshHeader(new ClassicsHeader(this)); + smartRefreshLayout.setRefreshFooter(new ClassicsFooter(this)); + //列表下拉刷新 + smartRefreshLayout.setOnRefreshListener(new OnRefreshListener() { + @Override + public void onRefresh(@NonNull RefreshLayout refreshLayout) { + smartRefreshLayout.finishRefresh(500); + //列表旧数据清除 + drug2List.clear(); + //构造数据 + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(Action1.this,"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + Cursor cursor = db.query("Drugs",new String[] {"Dno","Dname","Dclassification","Quantity_required","Sno"},null,null,null,null,null); + Cursor cursor1 = db.query("Sum_view",new String[] {"Dno","sum"},null,null,null,null,null); + while (cursor.moveToNext()){ + Drug2 drug2 = new Drug2(); + drug2.Dno = cursor.getString(0); + drug2.Dname = cursor.getString(1); + drug2.Quantity_required = cursor.getInt(3); + drug2.Sno = cursor.getString(4); + while (cursor1.moveToNext()){ + if(drug2.Dno.equals(cursor1.getString(0))){ + drug2.Quantity = cursor1.getInt(1); + if(drug2.Quantity-drug2.Quantity_required<0){ + drug2List.add(drug2); + } + } + } + cursor1.moveToFirst(); + } + myAdapter.notifyDataSetChanged(); + } + }); + + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(Action1.this,"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + Cursor cursor = db.query("Drugs",new String[] {"Dno","Dname","Dclassification","Quantity_required","Sno"},null,null,null,null,null); + Cursor cursor1 = db.query("Sum_view",new String[] {"Dno","sum"},null,null,null,null,null); + while (cursor.moveToNext()){ + Drug2 drug2 = new Drug2(); + drug2.Dno = cursor.getString(0); + drug2.Dname = cursor.getString(1); + drug2.Quantity_required = cursor.getInt(3); + drug2.Sno = cursor.getString(4); + while (cursor1.moveToNext()){ + if(drug2.Dno.equals(cursor1.getString(0))){ + drug2.Quantity = cursor1.getInt(1); + if(drug2.Quantity-drug2.Quantity_required<0){ + drug2List.add(drug2); + } + } + } + cursor1.moveToFirst(); + } + myAdapter.notifyDataSetChanged(); + + + + back = findViewById(R.id.textView64); + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + } + + public class MyAdapter extends RecyclerView.Adapter{ + + @NonNull + @Override + //加载布局文件 + public MyViewHoler onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(Action1.this) + .inflate(R.layout.item2_layout,parent,false); + MyViewHoler myViewHoler = new MyViewHoler(view); + return myViewHoler; + } + + @Override + //每个条目加载一次,该方法就会被调用一次 + public void onBindViewHolder(@NonNull MyViewHoler holder, int position) { + holder.DnoTv.setText(drug2List.get(position).Dno); + holder.DnameTv.setText(drug2List.get(position).Dname); + holder.Quantity_required.setText(drug2List.get(position).Quantity_required+""); + holder.QuantityTv.setText(drug2List.get(position).Quantity+""); + holder.SnoTv.setText(drug2List.get(position).Sno); + holder.constraintLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + SharedPreferences sharedPreferences = getSharedPreferences("action1",MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putBoolean("need",true); + editor.putString("Dno",holder.DnoTv.getText()+""); + editor.commit(); + + Intent intent = new Intent(Action1.this, Action4.class); + startActivity(intent); + } + }); + + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("https://www.fastmock.site/") + .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 + .build(); + Api api = retrofit.create(Api.class); + Call informationListCall = api.getInformationList(); + informationListCall.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + informationListBeans.addAll(response.body().informationlist); + for(int i=0;i call, Throwable t) { + + } + }); + + } + + @Override + //用来控制限制列表条数 + public int getItemCount() { + return drug2List.size(); + } + } + + //缓存列表数据 + public class MyViewHoler extends RecyclerView.ViewHolder{ + + TextView DnoTv; + TextView DnameTv; + TextView Quantity_required; + TextView QuantityTv; + TextView SnoTv; + ConstraintLayout constraintLayout; + ImageView imageView; + + public MyViewHoler(@NonNull View itemView) { + super(itemView); + DnoTv = itemView.findViewById(R.id.textView48); + DnameTv = itemView.findViewById(R.id.textView46); + Quantity_required = itemView.findViewById(R.id.textView52); + QuantityTv = itemView.findViewById(R.id.textView53); + SnoTv = itemView.findViewById(R.id.textView50); + imageView = itemView.findViewById(R.id.imageView14); + constraintLayout = itemView.findViewById(R.id.constraintLayout13); + } + } +} \ 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 new file mode 100644 index 0000000..b2d82c5 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Action/Action2.java @@ -0,0 +1,223 @@ +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.content.Intent; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +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 com.bumptech.glide.Glide; +import com.c202101020117.package1.Api; +import com.c202101020117.package1.InformationList; +import com.c202101020117.package1.MySQLiteOpenHelper; +import com.c202101020117.R; +import com.c202101020117.package1.Drug3; +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 java.util.ArrayList; +import java.util.List; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class Action2 extends AppCompatActivity { + + RecyclerView recyclerView; + MyAdapter myAdapter; + List drug3List = new ArrayList<>(); + TextView back; + List informationListBeans; + SmartRefreshLayout smartRefreshLayout; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_action2); + ImmersionBar.with(this).init(); + + informationListBeans = new ArrayList<>(); + + myAdapter = new MyAdapter(); + recyclerView = findViewById(R.id.recyclerView3); + recyclerView.setAdapter(myAdapter); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + + smartRefreshLayout=findViewById(R.id.smarlayout); + smartRefreshLayout.setRefreshHeader(new ClassicsHeader(this)); + smartRefreshLayout.setRefreshFooter(new ClassicsFooter(this)); + //列表下拉刷新 + smartRefreshLayout.setOnRefreshListener(new OnRefreshListener() { + @Override + public void onRefresh(@NonNull RefreshLayout refreshLayout) { + smartRefreshLayout.finishRefresh(500); + //列表旧数据清除 + drug3List.clear(); + //构造数据 + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(Action2.this,"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + Cursor cursor1 = db.query("Information_view",new String[] {"Dno","Dname","Sno","MFD","EXP","Datediff","Quantity"},null,null,null,null,null); + while (cursor1.moveToNext()){ + Drug3 drug3 = new Drug3(); + drug3.Datediff = cursor1.getDouble(5); + if(drug3.Datediff<=15){ + drug3.Dno = cursor1.getString(0); + drug3.Dname = cursor1.getString(1); + drug3.Sno = cursor1.getString(2); + drug3.MFD = cursor1.getString(3); + drug3.EXP = cursor1.getString(4); + drug3.Quantity = cursor1.getInt(6); + drug3List.add(drug3); + } + } + myAdapter.notifyDataSetChanged(); + } + }); + + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(Action2.this,"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + Cursor cursor = db.query("Information_view",new String[] {"Dno","Dname","Sno","MFD","EXP","Datediff","Quantity"},null,null,null,null,null); + while (cursor.moveToNext()){ + Drug3 drug3 = new Drug3(); + drug3.Datediff = cursor.getDouble(5); + if(drug3.Datediff<=15){ + drug3.Dno = cursor.getString(0); + drug3.Dname = cursor.getString(1); + drug3.Sno = cursor.getString(2); + drug3.MFD = cursor.getString(3); + drug3.EXP = cursor.getString(4); + drug3.Quantity = cursor.getInt(6); + drug3List.add(drug3); + } + } + myAdapter.notifyDataSetChanged(); + + back = findViewById(R.id.textView67); + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + } + + public class MyAdapter extends RecyclerView.Adapter{ + + @NonNull + @Override + //加载布局文件 + public MyViewHoler onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(Action2.this) + .inflate(R.layout.item3_layout,parent,false); + MyViewHoler myViewHoler = new MyViewHoler(view); + return myViewHoler; + } + + @Override + //每个条目加载一次,该方法就会被调用一次 + public void onBindViewHolder(@NonNull MyViewHoler holder, int position) { + holder.DnoTv.setText(drug3List.get(position).Dno); + holder.DnameTv.setText(drug3List.get(position).Dname); + holder.SnoTv.setText(drug3List.get(position).Sno); + holder.MFDTv.setText(drug3List.get(position).MFD); + holder.EXPTv.setText(drug3List.get(position).EXP); + holder.DatediffTv.setText((int)(drug3List.get(position).Datediff)+""); + holder.QuantityTv.setText(drug3List.get(position).Quantity+""); + holder.constraintLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + SharedPreferences sharedPreferences = getSharedPreferences("action2",MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putBoolean("need",true); + 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(Action2.this, Action5.class); + startActivity(intent); + } + }); + + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("https://www.fastmock.site/") + .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 + .build(); + Api api = retrofit.create(Api.class); + Call informationListCall = api.getInformationList(); + informationListCall.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + informationListBeans.addAll(response.body().informationlist); + for(int i=0;i call, Throwable t) { + + } + }); + } + + @Override + //用来控制限制列表条数 + public int getItemCount() { + return drug3List.size(); + } + } + + //缓存列表数据 + public class MyViewHoler extends RecyclerView.ViewHolder{ + + //Dno,Dname,Sno,MFD,EXP,Datediff,Quantity + 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); + 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); + 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/Action/Action3.java b/app/src/main/java/com/c202101020117/Action/Action3.java new file mode 100644 index 0000000..696dd99 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Action/Action3.java @@ -0,0 +1,21 @@ +package com.c202101020117.Action; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +import com.c202101020117.R; +import com.gyf.immersionbar.ImmersionBar; + + +public class Action3 extends AppCompatActivity { + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_action3); + ImmersionBar.with(this).init(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Action/Action4.java b/app/src/main/java/com/c202101020117/Action/Action4.java new file mode 100644 index 0000000..4250aff --- /dev/null +++ b/app/src/main/java/com/c202101020117/Action/Action4.java @@ -0,0 +1,81 @@ +package com.c202101020117.Action; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.ContentValues; +import android.content.SharedPreferences; +import android.database.sqlite.SQLiteDatabase; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.c202101020117.R; +import com.c202101020117.package1.MySQLiteOpenHelper; +import com.gyf.immersionbar.ImmersionBar; + +public class Action4 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_action4); + ImmersionBar.with(this).init(); + + text1 = findViewById(R.id.editTextTextPersonName5); + text2 = findViewById(R.id.editTextTextPersonName4); + text3 = findViewById(R.id.editTextTextPersonName3); + text4 = findViewById(R.id.editTextTextPersonName6); + confirm = findViewById(R.id.textView78); + + SharedPreferences sharedPreferences = getSharedPreferences("action1",MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + Boolean need = sharedPreferences.getBoolean("need",false); + + if(need){ + text1.setText(sharedPreferences.getString("Dno","")); + editor.clear(); + editor.commit(); + }else{ + text1.setText(""); + } + + confirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(Action4.this,"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + ContentValues contentValues = new ContentValues(); + contentValues.put("Dno",text1.getText()+""); + contentValues.put("MFD",text2.getText()+""); + contentValues.put("EXP",text3.getText()+""); + contentValues.put("Quantity",text4.getText()+""); + try { + db.insert("Date_and_Quantity",null,contentValues); + Toast.makeText(Action4.this,"增添成功",Toast.LENGTH_LONG).show(); + } catch (Exception e) { + Toast.makeText(Action4.this,"数据输入错误",Toast.LENGTH_LONG).show(); + throw new RuntimeException(e); + } + } + }); + + + back = findViewById(R.id.textView79); + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Action/Action5.java b/app/src/main/java/com/c202101020117/Action/Action5.java new file mode 100644 index 0000000..2143080 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Action/Action5.java @@ -0,0 +1,81 @@ +package com.c202101020117.Action; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.SharedPreferences; +import android.database.SQLException; +import android.database.sqlite.SQLiteDatabase; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.c202101020117.Login; +import com.c202101020117.R; +import com.c202101020117.package1.MySQLiteOpenHelper; +import com.gyf.immersionbar.ImmersionBar; + +public class Action5 extends AppCompatActivity { + + TextView back; + EditText text1; + EditText text2; + EditText text3; + TextView confirm; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_action5); + ImmersionBar.with(this).init(); + + text1 = findViewById(R.id.editTextTextPersonName7); + text2 = findViewById(R.id.editTextTextPersonName8); + text3 = findViewById(R.id.editTextTextPersonName9); + confirm = findViewById(R.id.textView86); + + SharedPreferences sharedPreferences = getSharedPreferences("action2",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","")); + editor.clear(); + editor.commit(); + }else{ + text1.setText(""); + text2.setText(""); + text3.setText(""); + } + + confirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(Action5.this,"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + String Dno = text1.getText()+""; + String MFD = text2.getText()+""; + String EXP = text3.getText()+""; + String sql = "delete from Date_and_Quantity where Dno = '"+Dno+"' and MFD = '"+MFD+"' and EXP = '"+EXP+"'"; + try { + db.execSQL(sql); + Toast.makeText(Action5.this,"删除成功",Toast.LENGTH_LONG).show(); + } catch (SQLException e) { + Toast.makeText(Action5.this,"数据输入有误",Toast.LENGTH_LONG).show(); + throw new RuntimeException(e); + } + } + }); + + back = findViewById(R.id.textView82); + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Action/DetailedInformation.java b/app/src/main/java/com/c202101020117/Action/DetailedInformation.java new file mode 100644 index 0000000..8420d19 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Action/DetailedInformation.java @@ -0,0 +1,136 @@ +package com.c202101020117.Action; + +import androidx.appcompat.app.AppCompatActivity; + +import android.app.Activity; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.c202101020117.package1.MySQLiteOpenHelper; +import com.c202101020117.R; +import com.c202101020117.package1.Api; +import com.c202101020117.package1.InformationList; +import com.gyf.immersionbar.ImmersionBar; + + +import java.util.ArrayList; +import java.util.List; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class DetailedInformation extends AppCompatActivity { + TextView DnoTv; + TextView DnameTv; + TextView DclassificationTv; + TextView QuantityTv; + TextView Quantity_requiredTv; + TextView SnoTv; + TextView back; + TextView text1; + TextView text2; + TextView text3; + TextView text4; + TextView text5; + TextView text6; + TextView text7; + + ImageView imageView; + List informationListBeans; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_detailed_information); + ImmersionBar.with(this).init(); + + DnoTv = findViewById(R.id.textView25); + DnameTv = findViewById(R.id.textView18); + DclassificationTv = findViewById(R.id.textView31); + QuantityTv = findViewById(R.id.textView22); + Quantity_requiredTv = findViewById(R.id.textView29); + SnoTv = findViewById(R.id.textView21); + text1 = findViewById(R.id.textView42); + text2 = findViewById(R.id.textView40); + text3 = findViewById(R.id.textView38); + text4 = findViewById(R.id.textView27); + text5 = findViewById(R.id.textView34); + text6 = findViewById(R.id.textView37); + text7 = findViewById(R.id.textView68); + imageView = findViewById(R.id.imageView7); + + SharedPreferences sharedPreferences = getSharedPreferences("user", Activity.MODE_PRIVATE); + String thisDno = sharedPreferences.getString("Dno",null); + + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(DetailedInformation.this,"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + Cursor cursor = db.query("Drugs",new String[] {"Dno","Dname","Dclassification","Quantity_required","Sno"},null,null,null,null,null); + Cursor cursor1 = db.query("Sum_view",new String[] {"Dno","sum"},null,null,null,null,null); + while(cursor.moveToNext()){ + if(cursor.getString(0).equals(thisDno)){ + DnoTv.setText(cursor.getString(0)); + DnameTv.setText(cursor.getString(1)); + DclassificationTv.setText(cursor.getString(2)); + Quantity_requiredTv.setText(cursor.getInt(3)+""); + SnoTv.setText(cursor.getString(4)); + } + } + while(cursor1.moveToNext()){ + if(cursor1.getString(0).equals(thisDno)){ + QuantityTv.setText(cursor1.getInt(1)+""); + } + } + + back = findViewById(R.id.textView19); + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + + informationListBeans = new ArrayList<>(); + + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("https://apifoxmock.com/") + .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 + .build(); + Api api = retrofit.create(Api.class); + Call informationListCall = api.getInformationList(); + informationListCall.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + informationListBeans.addAll(response.body().informationlist); + for(int i=0;i call, Throwable t) { + + } + }); + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Fragment/DrugListFragment.java b/app/src/main/java/com/c202101020117/Fragment/DrugListFragment.java new file mode 100644 index 0000000..32720c3 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Fragment/DrugListFragment.java @@ -0,0 +1,266 @@ +package com.c202101020117.Fragment; + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.os.Bundle; + +import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.c202101020117.Action.Action1; +import com.c202101020117.Action.DetailedInformation; +import com.c202101020117.package1.Api; +import com.c202101020117.package1.Drug2; +import com.c202101020117.package1.InformationList; +import com.c202101020117.package1.MySQLiteOpenHelper; +import com.c202101020117.package1.Drug; +import com.c202101020117.R; +import com.c202101020117.package1.Drug4; +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 java.util.ArrayList; +import java.util.List; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + + +public class DrugListFragment extends Fragment { + + RecyclerView recyclerView; + ImageView select; + EditText editText; + MyAdapter myAdapter; + List drugList = new ArrayList<>(); + List drug4list = new ArrayList<>(); + List informationListBeans; + SmartRefreshLayout smartRefreshLayout; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View view = inflater.inflate(R.layout.fragment_list, container, false); + + select = view.findViewById(R.id.imageView13); + editText = view.findViewById(R.id.editTextTextPersonName2); + recyclerView = view.findViewById(R.id.recycleView); + myAdapter = new MyAdapter(); + recyclerView.setAdapter(myAdapter); + recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); + + informationListBeans = new ArrayList<>(); + + smartRefreshLayout=view.findViewById(R.id.smarlayout2); + smartRefreshLayout.setRefreshHeader(new ClassicsHeader(getContext())); + smartRefreshLayout.setRefreshFooter(new ClassicsFooter(getContext())); + //列表下拉刷新 + smartRefreshLayout.setOnRefreshListener(new OnRefreshListener() { + @Override + public void onRefresh(@NonNull RefreshLayout refreshLayout) { + smartRefreshLayout.finishRefresh(500); + //列表旧数据清除 + drugList.clear(); + drug4list.clear(); + //构造数据 + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(getActivity(),"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + Cursor cursor = db.query("Drugs",new String[] {"Dno","Dname","Dclassification","Quantity_required","Sno"},null,null,null,null,null); + Cursor cursor1 = db.query("Sum_view",new String[] {"Dno","sum"},null,null,null,null,null); + while(cursor.moveToNext()){ + Drug drug = new Drug(); + drug.Dno = cursor.getString(0); + drug.Dname = cursor.getString(1); + drug.Dclassification = cursor.getString(2); + drug.Quantity_required = cursor.getInt(3); + drug.Sno = cursor.getString(4); + + drugList.add(drug); + } + while(cursor1.moveToNext()){ + Drug4 drug4 = new Drug4(); + drug4.Dno = cursor1.getString(0); + drug4.sum = cursor1.getInt(1); + drug4list.add(drug4); + } + myAdapter.notifyDataSetChanged(); + } + }); + + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(getActivity(),"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + Cursor cursor = db.query("Drugs",new String[] {"Dno","Dname","Dclassification","Quantity_required","Sno"},null,null,null,null,null); + Cursor cursor1 = db.query("Sum_view",new String[] {"Dno","sum"},null,null,null,null,null); + while(cursor.moveToNext()){ + Drug drug = new Drug(); + drug.Dno = cursor.getString(0); + drug.Dname = cursor.getString(1); + drug.Dclassification = cursor.getString(2); + drug.Quantity_required = cursor.getInt(3); + drug.Sno = cursor.getString(4); + drugList.add(drug); + } + while(cursor1.moveToNext()){ + Drug4 drug4 = new Drug4(); + drug4.Dno = cursor1.getString(0); + drug4.sum = cursor1.getInt(1); + drug4list.add(drug4); + } + myAdapter.notifyDataSetChanged(); + + select.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //列表旧数据清除 + drugList.clear(); + drug4list.clear(); + + String str = editText.getText().toString(); + //列表旧数据清除 + drugList.clear(); + drug4list.clear(); + //构造数据 + MySQLiteOpenHelper mySQLiteOpenHelper = new MySQLiteOpenHelper(getActivity(),"test1.db",null,1); + SQLiteDatabase db = mySQLiteOpenHelper.getWritableDatabase(); + Cursor cursor = db.query("Drugs",new String[] {"Dno","Dname","Dclassification","Quantity_required","Sno"},null,null,null,null,null); + Cursor cursor1 = db.query("Sum_view",new String[] {"Dno","sum"},null,null,null,null,null); + while(cursor.moveToNext()){ + Drug drug = new Drug(); + drug.Dno = cursor.getString(0); + drug.Dname = cursor.getString(1); + drug.Dclassification = cursor.getString(2); + drug.Quantity_required = cursor.getInt(3); + drug.Sno = cursor.getString(4); + if(drug.Dno.equals(str)||drug.Dname.equals(str)){ + str = drug.Dno; + drugList.add(drug); + break; + } + } + while(cursor1.moveToNext()){ + Drug4 drug4 = new Drug4(); + drug4.Dno = cursor1.getString(0); + drug4.sum = cursor1.getInt(1); + if(drug4.Dno.equals(str)){ + drug4list.add(drug4); + break; + } + } + myAdapter.notifyDataSetChanged(); + + } + }); + + return view; + } + + public class MyAdapter extends RecyclerView.Adapter{ + + @NonNull + @Override + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(getActivity()).inflate(R.layout.item_layout,parent,false); + MyViewHolder myViewHolder = new MyViewHolder(view); + return myViewHolder; + } + + @Override + public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { + holder.DnoTv.setText(drugList.get(position).Dno); + holder.DnameTv.setText(drugList.get(position).Dname); + holder.DclassificationTv.setText(drugList.get(position).Dclassification); + for(int i=0;i informationListCall = api.getInformationList(); + informationListCall.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + informationListBeans.addAll(response.body().informationlist); + for(int i=0;i call, Throwable t) { + + } + }); + } + + @Override + public int getItemCount() { + return drugList.size(); + } + } + + public class MyViewHolder extends RecyclerView.ViewHolder{ + TextView DnoTv; + TextView DnameTv; + TextView DclassificationTv; + TextView QuantityTv; + TextView SnoTv; + ImageView imageView; + ConstraintLayout constraintLayout; + + public MyViewHolder(@NonNull View itemView) { + super(itemView); + DnoTv = itemView.findViewById(R.id.textView12); + DnameTv = itemView.findViewById(R.id.textView11); + DclassificationTv = itemView.findViewById(R.id.textView13); + QuantityTv = itemView.findViewById(R.id.textView15); + SnoTv = itemView.findViewById(R.id.textView17); + imageView = itemView.findViewById(R.id.imageView6); + constraintLayout = itemView.findViewById(R.id.constraintLayout6); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Fragment/HomeFragment.java b/app/src/main/java/com/c202101020117/Fragment/HomeFragment.java new file mode 100644 index 0000000..6fb07d0 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Fragment/HomeFragment.java @@ -0,0 +1,56 @@ +package com.c202101020117.Fragment; + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.c202101020117.Home; +import com.c202101020117.Login; +import com.c202101020117.R; + +public class HomeFragment extends Fragment { + TextView quit; + TextView accountTv; + TextView userTv; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View view = inflater.inflate(R.layout.fragment_home, container, false); + + SharedPreferences sharedPreferences = getActivity().getSharedPreferences("user", Activity.MODE_PRIVATE); + String thisAccount = sharedPreferences.getString("account",null); + String thisUser = sharedPreferences.getString("user",null); + + accountTv = view.findViewById(R.id.textView92); + userTv = view.findViewById(R.id.textView91); + accountTv.setText(thisAccount); + userTv.setText(thisUser); + + quit = view.findViewById(R.id.textView93); + quit.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + SharedPreferences sharedPreferences = getActivity().getSharedPreferences("user", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.clear(); + editor.commit(); + + Intent intent = new Intent(getActivity(), Login.class); + startActivity(intent); + getActivity().finish(); + } + }); + + return view; + } +} \ 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 new file mode 100644 index 0000000..cbd6605 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Fragment/ScreeningFragment.java @@ -0,0 +1,50 @@ +package com.c202101020117.Fragment; + +import android.content.Intent; +import android.os.Bundle; + +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.c202101020117.Action.Action1; +import com.c202101020117.Action.Action2; +import com.c202101020117.R; + + +public class ScreeningFragment extends Fragment { + + ConstraintLayout action1; + ConstraintLayout action2; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View view = inflater.inflate(R.layout.fragment_screening, container, false); + + action1 = view.findViewById(R.id.constraintLayout9); + action2 = view.findViewById(R.id.constraintLayout8); + + action1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(getActivity(), Action1.class); + startActivity(intent); + } + }); + + action2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(getActivity(), Action2.class); + startActivity(intent); + } + }); + + return view; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Fragment/UpdateFragment.java b/app/src/main/java/com/c202101020117/Fragment/UpdateFragment.java new file mode 100644 index 0000000..1ae5bf9 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Fragment/UpdateFragment.java @@ -0,0 +1,60 @@ +package com.c202101020117.Fragment; + +import android.content.Intent; +import android.os.Bundle; + +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.c202101020117.Action.Action3; +import com.c202101020117.Action.Action4; +import com.c202101020117.Action.Action5; +import com.c202101020117.R; + +public class UpdateFragment extends Fragment { + + ConstraintLayout action3; + ConstraintLayout action4; + ConstraintLayout action5; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View view = inflater.inflate(R.layout.fragment_update, container, false); + + action3 = view.findViewById(R.id.constraintLayout11); + action4 = view.findViewById(R.id.constraintLayout13); + action5 = view.findViewById(R.id.constraintLayout12); + + action3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(getActivity(), Action3.class); + startActivity(intent); + } + }); + + action4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(getActivity(), Action4.class); + startActivity(intent); + } + }); + + action5.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(getActivity(), Action5.class); + startActivity(intent); + } + }); + + return view; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Home.java b/app/src/main/java/com/c202101020117/Home.java new file mode 100644 index 0000000..a44a974 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Home.java @@ -0,0 +1,124 @@ +package com.c202101020117; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.constraintlayout.widget.ConstraintLayout; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import com.c202101020117.Fragment.HomeFragment; +import com.c202101020117.Fragment.DrugListFragment; +import com.c202101020117.Fragment.ScreeningFragment; +import com.c202101020117.Fragment.UpdateFragment; +import com.gyf.immersionbar.ImmersionBar; + +public class Home extends AppCompatActivity { + + HomeFragment homeFragment; + DrugListFragment drugListFragment; + ScreeningFragment screeningFragment; + UpdateFragment updateFragment; + ConstraintLayout home; + ConstraintLayout list; + ConstraintLayout screening; + ConstraintLayout update; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_home); + ImmersionBar.with(this).init(); + + homeFragment = new HomeFragment(); + drugListFragment = new DrugListFragment(); + screeningFragment = new ScreeningFragment(); + updateFragment = new UpdateFragment(); + getSupportFragmentManager().beginTransaction().add(R.id.fragment,homeFragment).commit(); + getSupportFragmentManager().beginTransaction().add(R.id.fragment,drugListFragment).commit(); + getSupportFragmentManager().beginTransaction().add(R.id.fragment,screeningFragment).commit(); + getSupportFragmentManager().beginTransaction().add(R.id.fragment,updateFragment).commit(); + getSupportFragmentManager().beginTransaction() + .show(homeFragment) + .hide(drugListFragment) + .hide(screeningFragment) + .hide(updateFragment) + .commit(); + + home = findViewById(R.id.constraintLayout2); + list = findViewById(R.id.constraintLayout); + screening = findViewById(R.id.constraintLayout3); + update = findViewById(R.id.constraintLayout4); + home.setSelected(true); + list.setSelected(false); + screening.setSelected(false); + update.setSelected(false); + + home.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + home.setSelected(true); + list.setSelected(false); + screening.setSelected(false); + update.setSelected(false); + getSupportFragmentManager().beginTransaction() + .show(homeFragment) + .hide(drugListFragment) + .hide(screeningFragment) + .hide(updateFragment) + .commit(); + } + }); + + list.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + home.setSelected(false); + list.setSelected(true); + screening.setSelected(false); + update.setSelected(false); + getSupportFragmentManager().beginTransaction() + .hide(homeFragment) + .show(drugListFragment) + .hide(screeningFragment) + .hide(updateFragment) + .commit(); + } + }); + + screening.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + home.setSelected(false); + list.setSelected(false); + screening.setSelected(true); + update.setSelected(false); + getSupportFragmentManager().beginTransaction() + .hide(homeFragment) + .hide(drugListFragment) + .show(screeningFragment) + .hide(updateFragment) + .commit(); + } + }); + + update.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + home.setSelected(false); + list.setSelected(false); + screening.setSelected(false); + update.setSelected(true); + getSupportFragmentManager().beginTransaction() + .hide(homeFragment) + .hide(drugListFragment) + .hide(screeningFragment) + .show(updateFragment) + .commit(); + } + }); + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c202101020117/Login.java b/app/src/main/java/com/c202101020117/Login.java new file mode 100644 index 0000000..c80eca4 --- /dev/null +++ b/app/src/main/java/com/c202101020117/Login.java @@ -0,0 +1,100 @@ +package com.c202101020117; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import com.c202101020117.package1.Api; +import com.c202101020117.package1.UserList; +import com.gyf.immersionbar.ImmersionBar; + +import java.util.ArrayList; +import java.util.List; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class Login extends AppCompatActivity { + + EditText account; + EditText password; + Button login ; + List userlistBeans; + Boolean findAccount; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + ImmersionBar.with(this).init(); + + account = findViewById(R.id.editTextTextPersonName); + password = findViewById(R.id.editTextNumberPassword); + login = findViewById(R.id.button); + + userlistBeans = new ArrayList<>(); + + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("https://apifoxmock.com/") + .addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析 + .build(); + Api api = retrofit.create(Api.class); + + Call userListCall = api.getUserList(); + userListCall.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + userlistBeans.addAll(response.body().userlist); + } + + @Override + public void onFailure(Call call, Throwable t) { + + } + }); + + login.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + findAccount = false; + UserList.UserlistBean userlistBean; + String str1 = account.getText().toString(); + String str2 = password.getText().toString(); + for(int i=0;i getUserList(); + + //https://www.fastmock.site/mock/ddb290c0f0b0d2f5aed6b9d8ff2ed00b/Levi/information + //https://apifoxmock.com/m1/5358908-5030687-default/test2 + @GET("m1/5358908-5030687-default/test2") + Call getInformationList(); +} diff --git a/app/src/main/java/com/c202101020117/package1/Drug.java b/app/src/main/java/com/c202101020117/package1/Drug.java new file mode 100644 index 0000000..2be4d7b --- /dev/null +++ b/app/src/main/java/com/c202101020117/package1/Drug.java @@ -0,0 +1,9 @@ +package com.c202101020117.package1; + +public class Drug { + public String Dno; + public String Dname; + public String Dclassification; + public int Quantity_required; + public String Sno; +} diff --git a/app/src/main/java/com/c202101020117/package1/Drug2.java b/app/src/main/java/com/c202101020117/package1/Drug2.java new file mode 100644 index 0000000..f638610 --- /dev/null +++ b/app/src/main/java/com/c202101020117/package1/Drug2.java @@ -0,0 +1,9 @@ +package com.c202101020117.package1; + +public class Drug2 { + public String Dno; + public String Dname; + public String Sno; + public int Quantity_required; + public int Quantity; +} diff --git a/app/src/main/java/com/c202101020117/package1/Drug3.java b/app/src/main/java/com/c202101020117/package1/Drug3.java new file mode 100644 index 0000000..7d741af --- /dev/null +++ b/app/src/main/java/com/c202101020117/package1/Drug3.java @@ -0,0 +1,12 @@ +package com.c202101020117.package1; + +public class Drug3 { + public String Dno; + public String Dname; + public String Sno; + public String MFD; + public String EXP; + public double Datediff; + public int Quantity; + +} diff --git a/app/src/main/java/com/c202101020117/package1/Drug4.java b/app/src/main/java/com/c202101020117/package1/Drug4.java new file mode 100644 index 0000000..2e69025 --- /dev/null +++ b/app/src/main/java/com/c202101020117/package1/Drug4.java @@ -0,0 +1,6 @@ +package com.c202101020117.package1; + +public class Drug4 { + public String Dno; + public int sum; +} diff --git a/app/src/main/java/com/c202101020117/package1/InformationList.java b/app/src/main/java/com/c202101020117/package1/InformationList.java new file mode 100644 index 0000000..3e785a3 --- /dev/null +++ b/app/src/main/java/com/c202101020117/package1/InformationList.java @@ -0,0 +1,33 @@ +package com.c202101020117.package1; + +import java.util.List; + +public class InformationList { + + public List informationlist; + + public static class InformationlistBean { + /** + * Dno : A0001 + * head : https://tse3-mm.cn.bing.net/th/id/OIP-C.MjMKFFP09RejA7So3Gv45AHaFj?pid=ImgDet&rs=1 + * text1 : 苍术,陈皮,厚朴(姜制),白芷,茯苓,大腹皮,生半夏,甘草浸膏,广藿香油,紫苏叶油 + * text2 : 本品为深棕色的澄清液体(贮存略有沉淀);味辛、苦。 + * text3 : 解表化湿,理气和中。 + * text4 : 口服。一次半支(5毫升)~1支(10毫升),一日2次,用时摇匀。 + * text5 : 服用藿香正气水有发生药疹、紫癜的个别报道。 + * text6 : 尚不明确。 + * text7 : 1.忌烟、酒及辛辣、生冷、油腻食物,饮食宜清淡。 + 1.忌烟、酒及辛辣、生冷、油腻食物,饮食宜清淡。 + */ + + public String Dno; + public String head; + public String text1; + public String text2; + public String text3; + public String text4; + public String text5; + public String text6; + public String text7; + } +} diff --git a/app/src/main/java/com/c202101020117/package1/MySQLiteOpenHelper.java b/app/src/main/java/com/c202101020117/package1/MySQLiteOpenHelper.java new file mode 100644 index 0000000..ecce587 --- /dev/null +++ b/app/src/main/java/com/c202101020117/package1/MySQLiteOpenHelper.java @@ -0,0 +1,52 @@ +package com.c202101020117.package1; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +import androidx.annotation.Nullable; + +public class MySQLiteOpenHelper extends SQLiteOpenHelper { + public MySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) { + super(context, name, factory, version); + } + + + //创建表 + @Override + public void onCreate(SQLiteDatabase sqLiteDatabase) { + String sql1 = "create table Drugs(\n" + + "Dno varchar2(5) primary key,\n" + + "Dname varchar2(20) not null,\n" + + "Dclassification varchar2(20) not null,\n" + + "Quantity_required int not null,\n" + + "Sno varchar2(5) not null\n" + + ")"; + String sql2 = "create table Date_and_Quantity(\n" + + "Dno varchar2(5),\n" + + "MFD date,\n" + + "EXP date,\n" + + "Quantity int not null,\n" + + "foreign key(Dno) references Drugs(Dno)\n" + + ")"; + String sql3 = "create view Information_view as\n" + + "select Drugs.Dno,Dname,Sno,MFD,EXP,JULIANDAY(EXP)-JULIANDAY(date()) Datediff,Quantity\n" + + "from Drugs,Date_and_Quantity\n" + + "where Drugs.Dno = Date_and_Quantity.Dno"; + String sql4 = "create view Sum_view as\n" + + "select Dno,sum(Quantity) sum\n" + + "from Date_and_Quantity\n" + + "group by Dno"; + + sqLiteDatabase.execSQL(sql1); + sqLiteDatabase.execSQL(sql2); + sqLiteDatabase.execSQL(sql3); + sqLiteDatabase.execSQL(sql4); + } + + //更新表数据 + @Override + public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) { + + } +} diff --git a/app/src/main/java/com/c202101020117/package1/UserList.java b/app/src/main/java/com/c202101020117/package1/UserList.java new file mode 100644 index 0000000..04568f5 --- /dev/null +++ b/app/src/main/java/com/c202101020117/package1/UserList.java @@ -0,0 +1,23 @@ +package com.c202101020117.package1; + +import java.util.List; + +public class UserList { + + + public List userlist; + + public static class UserlistBean { + /** + * head : null + * account : 001 + * user : Levi + * password : 123456 + */ + + public String head; + public String account; + public String user; + public String password; + } +} diff --git a/app/src/main/res/color/color.xml b/app/src/main/res/color/color.xml new file mode 100644 index 0000000..e362c44 --- /dev/null +++ b/app/src/main/res/color/color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/action1_1.png b/app/src/main/res/drawable/action1_1.png new file mode 100644 index 0000000..c449473 Binary files /dev/null and b/app/src/main/res/drawable/action1_1.png differ diff --git a/app/src/main/res/drawable/action1_2.png b/app/src/main/res/drawable/action1_2.png new file mode 100644 index 0000000..f653607 Binary files /dev/null and b/app/src/main/res/drawable/action1_2.png differ diff --git a/app/src/main/res/drawable/action2_1.png b/app/src/main/res/drawable/action2_1.png new file mode 100644 index 0000000..691a1e7 Binary files /dev/null and b/app/src/main/res/drawable/action2_1.png differ diff --git a/app/src/main/res/drawable/action2_2.png b/app/src/main/res/drawable/action2_2.png new file mode 100644 index 0000000..a52ed0f Binary files /dev/null and b/app/src/main/res/drawable/action2_2.png differ diff --git a/app/src/main/res/drawable/action2_3.png b/app/src/main/res/drawable/action2_3.png new file mode 100644 index 0000000..b913b0e Binary files /dev/null and b/app/src/main/res/drawable/action2_3.png differ diff --git a/app/src/main/res/drawable/background.jpg b/app/src/main/res/drawable/background.jpg new file mode 100644 index 0000000..b1a8894 Binary files /dev/null and b/app/src/main/res/drawable/background.jpg differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/p1.png b/app/src/main/res/drawable/p1.png new file mode 100644 index 0000000..6e71d7c Binary files /dev/null and b/app/src/main/res/drawable/p1.png differ diff --git a/app/src/main/res/drawable/p2.png b/app/src/main/res/drawable/p2.png new file mode 100644 index 0000000..17ad5fe Binary files /dev/null and b/app/src/main/res/drawable/p2.png differ diff --git a/app/src/main/res/drawable/p3.png b/app/src/main/res/drawable/p3.png new file mode 100644 index 0000000..b5a9441 Binary files /dev/null and b/app/src/main/res/drawable/p3.png differ diff --git a/app/src/main/res/drawable/p4.png b/app/src/main/res/drawable/p4.png new file mode 100644 index 0000000..2ffda4c Binary files /dev/null and b/app/src/main/res/drawable/p4.png differ diff --git a/app/src/main/res/drawable/shape.xml b/app/src/main/res/drawable/shape.xml new file mode 100644 index 0000000..4387bd0 --- /dev/null +++ b/app/src/main/res/drawable/shape.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape2.xml b/app/src/main/res/drawable/shape2.xml new file mode 100644 index 0000000..89e5ae0 --- /dev/null +++ b/app/src/main/res/drawable/shape2.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shujugengxin.xml b/app/src/main/res/drawable/shujugengxin.xml new file mode 100644 index 0000000..9ca21ae --- /dev/null +++ b/app/src/main/res/drawable/shujugengxin.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shujugengxin_select.png b/app/src/main/res/drawable/shujugengxin_select.png new file mode 100644 index 0000000..d0cfdde Binary files /dev/null and b/app/src/main/res/drawable/shujugengxin_select.png differ diff --git a/app/src/main/res/drawable/shujugengxin_unselect.png b/app/src/main/res/drawable/shujugengxin_unselect.png new file mode 100644 index 0000000..3e49868 Binary files /dev/null and b/app/src/main/res/drawable/shujugengxin_unselect.png differ diff --git a/app/src/main/res/drawable/yaopinliebiao.xml b/app/src/main/res/drawable/yaopinliebiao.xml new file mode 100644 index 0000000..ba10d96 --- /dev/null +++ b/app/src/main/res/drawable/yaopinliebiao.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/yaopinliebiao_select.png b/app/src/main/res/drawable/yaopinliebiao_select.png new file mode 100644 index 0000000..c9f4801 Binary files /dev/null and b/app/src/main/res/drawable/yaopinliebiao_select.png differ diff --git a/app/src/main/res/drawable/yaopinliebiao_unselect.png b/app/src/main/res/drawable/yaopinliebiao_unselect.png new file mode 100644 index 0000000..22eefb3 Binary files /dev/null and b/app/src/main/res/drawable/yaopinliebiao_unselect.png differ diff --git a/app/src/main/res/drawable/yaopinshaicha.xml b/app/src/main/res/drawable/yaopinshaicha.xml new file mode 100644 index 0000000..ddc0ba6 --- /dev/null +++ b/app/src/main/res/drawable/yaopinshaicha.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/yaopinshaicha_select.png b/app/src/main/res/drawable/yaopinshaicha_select.png new file mode 100644 index 0000000..c798234 Binary files /dev/null and b/app/src/main/res/drawable/yaopinshaicha_select.png differ diff --git a/app/src/main/res/drawable/yaopinshaicha_unselect.png b/app/src/main/res/drawable/yaopinshaicha_unselect.png new file mode 100644 index 0000000..d377b87 Binary files /dev/null and b/app/src/main/res/drawable/yaopinshaicha_unselect.png differ diff --git a/app/src/main/res/drawable/zhuye.xml b/app/src/main/res/drawable/zhuye.xml new file mode 100644 index 0000000..0931f40 --- /dev/null +++ b/app/src/main/res/drawable/zhuye.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/zhuye_select.png b/app/src/main/res/drawable/zhuye_select.png new file mode 100644 index 0000000..6a5d597 Binary files /dev/null and b/app/src/main/res/drawable/zhuye_select.png differ diff --git a/app/src/main/res/drawable/zhuye_unselect.png b/app/src/main/res/drawable/zhuye_unselect.png new file mode 100644 index 0000000..d9f7b44 Binary files /dev/null and b/app/src/main/res/drawable/zhuye_unselect.png differ diff --git a/app/src/main/res/layout/activity_action1.xml b/app/src/main/res/layout/activity_action1.xml new file mode 100644 index 0000000..79bc17f --- /dev/null +++ b/app/src/main/res/layout/activity_action1.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000..d87c7fa --- /dev/null +++ b/app/src/main/res/layout/activity_action2.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000..fba0ee4 --- /dev/null +++ b/app/src/main/res/layout/activity_action3.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_action4.xml b/app/src/main/res/layout/activity_action4.xml new file mode 100644 index 0000000..2a1b3ba --- /dev/null +++ b/app/src/main/res/layout/activity_action4.xml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_action5.xml b/app/src/main/res/layout/activity_action5.xml new file mode 100644 index 0000000..ea34a11 --- /dev/null +++ b/app/src/main/res/layout/activity_action5.xml @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_detailed_information.xml b/app/src/main/res/layout/activity_detailed_information.xml new file mode 100644 index 0000000..7bdcd53 --- /dev/null +++ b/app/src/main/res/layout/activity_detailed_information.xml @@ -0,0 +1,357 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml new file mode 100644 index 0000000..468630f --- /dev/null +++ b/app/src/main/res/layout/activity_home.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..7263a22 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + +