Change List type;

Add loop to move suspended treatment at the end of the list
This commit is contained in:
jacques 2021-03-20 21:32:01 +01:00
parent 5b0a3c4655
commit 7b632b18d9

View file

@ -8,7 +8,9 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@ -35,7 +37,7 @@ class DBHelper extends SQLiteOpenHelper {
private static final String KEY_SEUIL_ALERT = "alerte";
private static final String KEY_LAST_UPDATE = "last_update";
final List<Medicament> medicaments = new LinkedList<>();
final List<Medicament> medicaments = new ArrayList<>();
private static final String TAG = DBHelper.class.getName();
@ -277,6 +279,17 @@ class DBHelper extends SQLiteOpenHelper {
}
});
// Move medicament with prise = 0 at the end of the list
for (int position = 0 ; position < getCount() ; position++ ) {
currentMedicament = getItem(position);
double currentPrise = currentMedicament.getPrise();
if (currentPrise == 0)
{
medicament = medicaments.remove(position);
medicaments.add(medicaments.size(), medicament);
}
}
Log.d(TAG, "getAllDrugs " + medicaments.toString());
return medicaments;