mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-10 16:01:16 +01:00
Optimize import;
Optimize constuctMedList; Add call to DetailActivity after scan; Fix typo and small other bugs
This commit is contained in:
parent
017e28c016
commit
4b7d403ce0
1 changed files with 16 additions and 26 deletions
|
@ -33,8 +33,6 @@ import com.google.zxing.integration.android.IntentResult;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -103,7 +101,6 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
|
||||
public void constructMedsList()
|
||||
{
|
||||
Medicament currentMedicament;
|
||||
dbHelper = new DBHelper(getApplicationContext());
|
||||
|
||||
if (!(medicaments == null)) {
|
||||
|
@ -113,19 +110,6 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
}
|
||||
medicaments = dbHelper.getAllDrugs();
|
||||
|
||||
Collections.sort(medicaments, new Comparator<Medicament>() {
|
||||
@Override
|
||||
public int compare(Medicament lhs, Medicament rhs) {
|
||||
return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
|
||||
}
|
||||
});
|
||||
|
||||
for (int position = 0 ; position < this.getCount() ; position++ ) {
|
||||
currentMedicament = this.getItem(position);
|
||||
currentMedicament.newStock(currentMedicament.getStock());
|
||||
dbHelper.updateDrug(currentMedicament);
|
||||
}
|
||||
|
||||
View mRecyclerView = findViewById(R.id.medicament_list);
|
||||
assert mRecyclerView != null;
|
||||
setupRecyclerView((RecyclerView) mRecyclerView);
|
||||
|
@ -146,11 +130,12 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
toolbar.setTitle(getTitle());
|
||||
}
|
||||
|
||||
if (DEMO) {
|
||||
// Added to drop database each the app is launch.
|
||||
if (DBDEMO) {
|
||||
dbHelper.dropDrug();
|
||||
}
|
||||
|
||||
if (DEMO) {
|
||||
if (dbHelper.getCount() == 0) {
|
||||
|
||||
// String cis, String cip13, String nom, String mode_administration,
|
||||
|
@ -306,7 +291,7 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
/**
|
||||
* show keybordInput dialoo
|
||||
* show keyboardInput dialog
|
||||
*/
|
||||
protected void showInputDialog() {
|
||||
// get prompts.xml view
|
||||
|
@ -332,7 +317,7 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
alert.show();
|
||||
}
|
||||
|
||||
/***
|
||||
/**
|
||||
* Ask if the medicament found in the database should be include in the
|
||||
* user database
|
||||
* @param med Medicament- medicament to be added
|
||||
|
@ -362,13 +347,19 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add New medimenant to the user database
|
||||
* Add New medicament to the user database
|
||||
* @param med Medicament - medicament to be added
|
||||
*/
|
||||
private void addMedToList(Medicament med)
|
||||
{
|
||||
med.setDateEndOfStock();
|
||||
mAdapter.addItem(med);
|
||||
|
||||
Log.d(TAG, "Call MedicamentDetailActivity");
|
||||
Context context = this;
|
||||
Intent intent = new Intent(context, MedicamentDetailActivity.class);
|
||||
intent.putExtra("medicament", med);
|
||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -484,7 +475,7 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
holder.mContentView.setText(mValues.get(position).getNom());
|
||||
holder.mEndOfStock.setText(dateEndOfStock);
|
||||
|
||||
// Test to change background programmaticaly
|
||||
// Test to change background programmatically
|
||||
if (mValues.get(position).getPrise() == 0) {
|
||||
holder.mView.setBackgroundResource(R.drawable.gradient_bg);
|
||||
} else {
|
||||
|
@ -518,8 +509,7 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, MedicamentDetailActivity.class);
|
||||
intent.putExtra("medicament", medicamentCourant);
|
||||
int requestCode =1;
|
||||
startActivityForResult(intent, requestCode);
|
||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue