Add debug code

This commit is contained in:
jacques 2022-12-08 16:57:19 +01:00
parent 9cf02aedda
commit 87fd45cfa1
3 changed files with 21 additions and 16 deletions

View file

@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>

View file

@ -37,20 +37,20 @@ public class AlarmReceiver extends BroadcastReceiver {
Date tomorrow;
LocalTime todayNow = LocalTime.now();
/*if (BuildConfig.DEBUG) {
if (BuildConfig.DEBUG) {
Date nextSchedule = calendar.getTime();
calendar.setTimeInMillis(nextSchedule.getTime());
} else {*/
calendar.set(Calendar.HOUR_OF_DAY, 11);
today = calendar.getTime();
calendar.add(Calendar.DAY_OF_YEAR, 1);
tomorrow = calendar.getTime();
if (todayNow.isBefore(LocalTime.NOON)) {
calendar.setTimeInMillis(today.getTime());
} else {
calendar.setTimeInMillis(tomorrow.getTime());
calendar.set(Calendar.HOUR_OF_DAY, 11);
today = calendar.getTime();
calendar.add(Calendar.DAY_OF_YEAR, 1);
tomorrow = calendar.getTime();
if (todayNow.isBefore(LocalTime.NOON)) {
calendar.setTimeInMillis(today.getTime());
} else {
calendar.setTimeInMillis(tomorrow.getTime());
}
}
//}
PendingIntent alarmIntent;
@ -59,14 +59,14 @@ public class AlarmReceiver extends BroadcastReceiver {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
/*if (BuildConfig.DEBUG) {
if (BuildConfig.DEBUG) {
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,(calendar.getTimeInMillis()),
AlarmManager.ELAPSED_REALTIME, alarmIntent);
} else {*/
} else {
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, (calendar.getTimeInMillis()),
AlarmManager.INTERVAL_DAY, alarmIntent);
//}
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, (calendar.getTimeInMillis()),
AlarmManager.INTERVAL_DAY, alarmIntent);
}
Log.d(TAG, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()));
if (BuildConfig.DEBUG) {

View file

@ -164,8 +164,12 @@ public class Prescription implements Serializable {
}*/
if (numberOfDays > 0) {
float currentStock = 0;
float newStock = 0;
double takeDuringPeriod = this.take * numberOfDays;
setStock((float) (getStock() - takeDuringPeriod));
currentStock = getStock();
newStock = (float) (currentStock - takeDuringPeriod);
setStock((float) newStock);
setLast_update(new Date().getTime());
}
}