optimize import and clean dead code

This commit is contained in:
jacques 2022-03-12 21:43:30 +01:00
parent 2f2c31b1c9
commit dc71f57a73
6 changed files with 11 additions and 121 deletions

View file

@ -1,5 +1,7 @@
package net.foucry.pilldroid;
import static net.foucry.pilldroid.R.id.detail_toolbar;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
@ -13,14 +15,11 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import java.io.Serializable;
import java.util.Date;
import static net.foucry.pilldroid.R.id.detail_toolbar;
import net.foucry.pilldroid.dao.MedicDAO;
import net.foucry.pilldroid.models.Medic;
import java.util.Date;
/**
* An activity representing a single Drug detail screen. This
* activity is only used narrow width devices. On tablet-size devices,
@ -81,9 +80,6 @@ public class DrugDetailActivity extends AppCompatActivity {
if (savedInstanceState == null) {
// Create the detail fragment and add it to the activity
// using a fragment transaction.
/*Bundle arguments = new Bundle();
arguments.putSerializable("medic",
getIntent().getExtras());*/
Bundle arguments = new Bundle();
arguments.putSerializable("medic", aMedic);
DrugDetailFragment fragment = new DrugDetailFragment();
@ -114,7 +110,6 @@ public class DrugDetailActivity extends AppCompatActivity {
Log.d(TAG, "Time to save new values");
PilldroidDatabase prescriptions = null;
DBHelper dbHelper = new DBHelper(this);
assert false;
MedicDAO medicDAO = prescriptions.getMedicDAO();

View file

@ -36,15 +36,14 @@ import androidx.room.Room;
import com.google.zxing.client.android.Intents;
import com.journeyapps.barcodescanner.ScanOptions;
import java.io.Serializable;
import net.foucry.pilldroid.dao.MedicDAO;
import net.foucry.pilldroid.models.Medic;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import net.foucry.pilldroid.dao.MedicDAO;
import net.foucry.pilldroid.models.Medic;
/**
* An activity representing a list of Drugs is activity
* has different presentations for handset and tablet-size devices. On
@ -65,7 +64,6 @@ public class DrugListActivity extends AppCompatActivity {
private ActivityResultLauncher<ScanOptions> mBarcodeScannerLauncher;
private static final String TAG = DrugListActivity.class.getName();
private DBHelper dbHelper;
private DBDrugs dbDrug;
public PilldroidDatabase prescriptions;
public PilldroidDatabase medications;
@ -114,7 +112,7 @@ public class DrugListActivity extends AppCompatActivity {
// Set view content
setContentView(R.layout.activity_drug_list);
dbHelper = new DBHelper(this);
DBHelper dbHelper = new DBHelper(this);
dbDrug = new DBDrugs(this);
Toolbar toolbar = findViewById(R.id.toolbar);
@ -157,49 +155,6 @@ public class DrugListActivity extends AppCompatActivity {
System.out.println(prescriptions);
Log.d(TAG, "prescriptions ==" + prescriptions);
}
/*
if (dbHelper.getCount() == 0) {
// String cis, String cip13, String nom, String mode_administration,
// String presentation,double stock, double prise, int warn, int alert
// Limit for randoms generator
final int min_stock = 5;
final int max_stock = 50;
final int min_prise = 0;
final int max_prise = 3;
dbHelper.addDrug(new Drug("60000011", "3400930000011", "Médicament test 01", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
dbHelper.addDrug(new Drug("60000012", "3400930000012", "Médicament test 02", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
dbHelper.addDrug(new Drug("60000013", "3400930000013", "Médicament test 03", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
dbHelper.addDrug(new Drug("60000014", "3400930000014", "Médicament test 04", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
dbHelper.addDrug(new Drug("60000015", "3400930000015", "Médicament test 05", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
dbHelper.addDrug(new Drug("60000016", "3400930000016", "Médicament test 06", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
dbHelper.addDrug(new Drug("60000017", "3400930000017", "Médicament test 07", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
dbHelper.addDrug(new Drug("60000018", "3400930000018", "Médicament test 08", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
dbHelper.addDrug(new Drug("60000019", "3400930000019", "Médicament test 09", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
dbHelper.addDrug(new Drug("60000010", "3400930000010", "Médicament test 10", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
intRandomExclusive(min_stock, max_stock), intRandomExclusive(min_prise, max_prise), 14, 7, UtilDate.dateAtNoon(new Date()).getTime()));
}*/
}
mBarcodeScannerLauncher = registerForActivityResult(new PilldroidScanContract(),
@ -274,15 +229,6 @@ public class DrugListActivity extends AppCompatActivity {
MedicDAO medicDAO = prescriptions.getMedicDAO();
medics = medicDAO.getAllMedics();
/*dbHelper = new DBHelper(getApplicationContext());
if (!(drugs == null)) {
if (!drugs.isEmpty()) {
drugs.clear();
}
}
drugs = dbHelper.getAllDrugs();*/
View mRecyclerView = findViewById(R.id.drug_list);
assert mRecyclerView != null;
setupRecyclerView((RecyclerView) mRecyclerView);
@ -312,11 +258,6 @@ public class DrugListActivity extends AppCompatActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
/*if (requestCode != CUSTOMIZED_REQUEST_CODE && requestCode != IntentIntegrator.REQUEST_CODE) {
// This is important, otherwise the result will not be passed to the fragment
super.onActivityResult(requestCode, resultCode, data);
return;
}*/
if (requestCode == CUSTOMIZED_REQUEST_CODE) {
if (BuildConfig.DEBUG) {
Toast.makeText(this, "REQUEST_CODE = " + requestCode +

View file

@ -3,8 +3,6 @@ package net.foucry.pilldroid;
import androidx.room.AutoMigration;
import androidx.room.Database;
import androidx.room.RoomDatabase;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import net.foucry.pilldroid.dao.MedicDAO;
import net.foucry.pilldroid.models.Medic;
@ -15,8 +13,7 @@ import net.foucry.pilldroid.models.Medic;
autoMigrations = {
@AutoMigration(from = 1, to = 2),
@AutoMigration(from = 2, to = 3),
},
exportSchema = true
}
)
public abstract class PilldroidDatabase extends RoomDatabase {

View file

@ -1,41 +1,11 @@
package net.foucry.pilldroid;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Locale;
import java.util.Random;
public class Utils {
private static final String TAG = Utils.class.getName();
public static final int SELECT_BARCODE_REQUEST = 2;
public static final int BARCODE_SCAN = 3;
public static void CopyStream(InputStream is, OutputStream os)
{
final int buffer_size=1024;
try
{
byte[] bytes=new byte[buffer_size];
for(;;)
{
int count=is.read(bytes, 0, buffer_size);
if(count==-1)
break;
os.write(bytes, 0, count);
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Return a random number between twovalues - use to gənerate a false demo DB
* @param min minimal value accepted

View file

@ -1,7 +1,5 @@
package net.foucry.pilldroid.dao;
import static net.foucry.pilldroid.UtilDate.dateAtNoon;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
@ -10,8 +8,6 @@ import androidx.room.Update;
import net.foucry.pilldroid.models.Medic;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Dao

View file

@ -25,11 +25,7 @@ public class Medic implements Serializable {
private Long last_update;
/* public Medic(@NonNull Integer id) {
this.id = id;
}*/
public void setCis(String cis)
public void setCis(@NonNull String cis)
{
this.cis = cis;
}
@ -69,12 +65,7 @@ public class Medic implements Serializable {
this.last_update = last_update;
}
//@NonNull
/*public Integer getId() {
return this.id;
}*/
@NonNull
@NonNull
public String getCis() {
return this.cis;
}