From 88616adb15004980c2315d0968109957db140763 Mon Sep 17 00:00:00 2001 From: jacques Date: Sun, 4 Jul 2021 22:20:40 +0200 Subject: [PATCH 1/2] Change takezore 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; From 5c2c20d80b2b0f9840498bd0a86ee72209315f7a Mon Sep 17 00:00:00 2001 From: jacques Date: Sun, 4 Jul 2021 22:21:22 +0200 Subject: [PATCH 2/2] Add todo comment for deprecated code. --- app/src/main/java/net/foucry/pilldroid/DrugListActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java index c9d3ef3..394a095 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java @@ -376,7 +376,7 @@ public class DrugListActivity extends AppCompatActivity { Context context = this; Intent intent = new Intent(context, DrugDetailActivity.class); intent.putExtra("drug", aDrug); - startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); + startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); // todo deprecated overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); } @@ -473,7 +473,7 @@ public class DrugListActivity extends AppCompatActivity { Context context = v.getContext(); Intent intent = new Intent(context, DrugDetailActivity.class); intent.putExtra("drug", drugCourant); - startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); + startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); // todo: deprecated overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); } });