diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java
index 0b7f7a944c..ac50d3c1f6 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java
@@ -192,10 +192,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
double avg;
if (bgReadings.size() > 3) {
- BgReading now = bgReadings.get(sizeRecords - 1);
- BgReading last = bgReadings.get(sizeRecords - 2);
- BgReading last1 = bgReadings.get(sizeRecords - 3);
- BgReading last2 = bgReadings.get(sizeRecords - 4);
+ BgReading now = bgReadings.get(sizeRecords - 4);
+ BgReading last = bgReadings.get(sizeRecords - 3);
+ BgReading last1 = bgReadings.get(sizeRecords - 2);
+ BgReading last2 = bgReadings.get(sizeRecords - 1);
if (last2.value > 30) {
minutes = 3 * 5;
change = now.value - last2.value;
@@ -212,7 +212,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
avg = change / minutes * 5;
result.glucose = now.value;
- result.delta = change;
+ result.delta = now.value - last.value;
result.avgdelta = avg;
}
} catch (SQLException e) {
diff --git a/app/src/main/res/layout/openapsma_fragment.xml b/app/src/main/res/layout/openapsma_fragment.xml
index 6211029393..f508c5bed0 100644
--- a/app/src/main/res/layout/openapsma_fragment.xml
+++ b/app/src/main/res/layout/openapsma_fragment.xml
@@ -36,7 +36,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="Small Text"
android:id="@+id/openapsma_lastrun"
android:layout_marginLeft="10dp" />
@@ -64,7 +63,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="Small Text"
android:id="@+id/openapsma_glucosestatus"
android:layout_marginLeft="10dp" />
@@ -138,7 +132,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="Small Text"
android:id="@+id/openapsma_result"
android:layout_marginLeft="10dp" />