plusminis edit shows toast when hit limit

This commit is contained in:
Milos Kozak 2016-08-08 10:08:30 +02:00
parent 294f9d6c99
commit 88698576a2
4 changed files with 20 additions and 5 deletions

View file

@ -17,6 +17,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
/** /**
* Created by mike on 28.06.2016. * Created by mike on 28.06.2016.
*/ */
@ -109,13 +112,21 @@ public class PlusMinusEditText implements View.OnKeyListener,
private void inc() { private void inc() {
value += step; value += step;
if (value > maxValue) value = maxValue; if (value > maxValue) {
value = maxValue;
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit));
stopUpdating();
}
updateEditText(); updateEditText();
} }
private void dec() { private void dec() {
value -= step; value -= step;
if (value < minValue) value = minValue; if (value < minValue) {
value = minValue;
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit));
stopUpdating();
}
updateEditText(); updateEditText();
} }
@ -137,8 +148,10 @@ public class PlusMinusEditText implements View.OnKeyListener,
} }
private void stopUpdating() { private void stopUpdating() {
mUpdater.shutdownNow(); if (mUpdater != null) {
mUpdater = null; mUpdater.shutdownNow();
mUpdater = null;
}
} }
@Override @Override

View file

@ -27,7 +27,7 @@ public class ToastUtils {
playSound(ctx, soundID); playSound(ctx, soundID);
} }
public static void playSound(final Context ctx, final int soundID) { private static void playSound(final Context ctx, final int soundID) {
final MediaPlayer soundMP = MediaPlayer.create(ctx, soundID); final MediaPlayer soundMP = MediaPlayer.create(ctx, soundID);
soundMP.start(); soundMP.start();
soundMP.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { soundMP.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

View file

@ -299,4 +299,5 @@
<string name="objectives_5_gate">Jeden týden úspěšného používání s běžným příjmem sacharidů</string> <string name="objectives_5_gate">Jeden týden úspěšného používání s běžným příjmem sacharidů</string>
<string name="objectives_5_objective">Upravit bazály a koeficinty, když bude potřeba a povolit automatickou detekci citlivosti na inzulín</string> <string name="objectives_5_objective">Upravit bazály a koeficinty, když bude potřeba a povolit automatickou detekci citlivosti na inzulín</string>
<string name="objectives_6_objective">Povolit další fukce pro běžné používání jako AMA</string> <string name="objectives_6_objective">Povolit další fukce pro běžné používání jako AMA</string>
<string name="youareonallowedlimit">Dosaženo limitu</string>
</resources> </resources>

View file

@ -301,5 +301,6 @@
<string name="objectives_5_objective">Adjust basals and ratios if needed, and then enable auto-sens</string> <string name="objectives_5_objective">Adjust basals and ratios if needed, and then enable auto-sens</string>
<string name="objectives_5_gate">1 week successful daytime looping with regular carb entry</string> <string name="objectives_5_gate">1 week successful daytime looping with regular carb entry</string>
<string name="objectives_6_objective">Enabling additional features for daytime use, such as advanced meal assist</string> <string name="objectives_6_objective">Enabling additional features for daytime use, such as advanced meal assist</string>
<string name="youareonallowedlimit">You reached allowed limit</string>
</resources> </resources>