From d0f6f5b1dd96ec00347c6d6f36ad78b5e4166894 Mon Sep 17 00:00:00 2001 From: jacques Date: Sun, 4 Jul 2021 22:20:40 +0200 Subject: [PATCH] Change take loop --- app/src/main/java/net/foucry/pilldroid/DBHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/foucry/pilldroid/DBHelper.java b/app/src/main/java/net/foucry/pilldroid/DBHelper.java index 36a9fbe..bfaf962 100644 --- a/app/src/main/java/net/foucry/pilldroid/DBHelper.java +++ b/app/src/main/java/net/foucry/pilldroid/DBHelper.java @@ -292,13 +292,17 @@ class DBHelper extends SQLiteOpenHelper { // Move drug with prise = 0 at the end of the list // todo: If some drug moved, must redo all the loop - for (int position = 0 ; position < getCount() ; position++ ) { + int position = 0 ; + for ( int nbOps = 0; nbOps < getCount() ; nbOps ++ ) { currentDrug = getItem(position); double currentTake = currentDrug.getTake(); if (currentTake == 0) { drug = drugs.remove(position); drugs.add(drug); + } else + { + position++; } } return drugs;