Cosmetic change in the code

This commit is contained in:
jacques 2021-06-18 20:10:07 +02:00
parent be9fc0a358
commit ed6052ba1b

View file

@ -272,12 +272,23 @@ class DBHelper extends SQLiteOpenHelper {
}
}
Log.d(TAG, "Before sort == " + drugs.toString());
/*drugs.sort(Comparator.comparing(Drug::getDateEndOfStock)
.thenComparing(Drug::getStock));*/
drugs.sort(new Comparator<Drug>() {
@Override
public int compare(Drug lhs, Drug rhs) {
if (lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()) != 0)
return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
else
return (int) (lhs.getStock() - rhs.getStock());
}
});
Log.d(TAG, "After sort " + drugs.toString());
// Move drug with prise = 0 at the end of the list
for (int position = 0 ; position < getCount() ; position++ ) {
@ -289,9 +300,6 @@ class DBHelper extends SQLiteOpenHelper {
drugs.add(drugs.size(), drug);
}
}
Log.d(TAG, "getAllDrugs " + drugs.toString());
return drugs;
}
@ -301,7 +309,7 @@ class DBHelper extends SQLiteOpenHelper {
*/
public void updateDrug(Drug drug) {
Log.d(TAG, "Update Drug == " + drug);
Log.d(TAG, "Update Drug == " + drug.toString());
// Get reference to writable DB
SQLiteDatabase db = this.getWritableDatabase();
@ -329,6 +337,7 @@ class DBHelper extends SQLiteOpenHelper {
// Close DB
db.close();
Log.d(TAG, "values == " + values.toString());
}
/**