Add debug code

This commit is contained in:
jacques 2022-07-24 10:55:34 +02:00
parent 5c2866a543
commit 4620ca0f98
2 changed files with 166 additions and 144 deletions

View file

@ -14,7 +14,7 @@ import android.widget.Toast;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.google.zxing.client.android.BuildConfig;
//import com.google.zxing.client.android.BuildConfig;
import net.foucry.pilldroid.dao.PrescriptionsDAO;
import net.foucry.pilldroid.databases.PrescriptionDatabase;
@ -159,10 +159,19 @@ public class AlarmReceiver extends BroadcastReceiver {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (BuildConfig.DEBUG) {
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,(calendar.getTimeInMillis()),
AlarmManager.ELAPSED_REALTIME, alarmIntent);
} else {
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, (calendar.getTimeInMillis()),
AlarmManager.INTERVAL_DAY, alarmIntent);
}
Log.d(TAG, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()));
if (BuildConfig.DEBUG) {
Toast.makeText(context, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()), Toast.LENGTH_LONG).show();
}
if (BuildConfig.DEBUG) { Toast.makeText(context, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()), Toast.LENGTH_SHORT).show(); }
}

View file

@ -1,9 +1,13 @@
package net.foucry.pilldroid.models;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import net.foucry.pilldroid.BuildConfig;
import net.foucry.pilldroid.UtilDate;
import java.io.Serializable;
@ -12,8 +16,10 @@ import java.util.Date;
@Entity(tableName = "prescriptions")
public class Prescription implements Serializable {
private static final String TAG = Prescription.class.getName();;
@PrimaryKey
@NonNull private String cis;
@NonNull
private String cis;
private String cip13;
private String name;
private String administration_mode;
@ -26,8 +32,7 @@ public class Prescription implements Serializable {
private String label_group;
private Integer generic_type;
public void setCis(@NonNull String cis)
{
public void setCis(@NonNull String cis) {
this.cis = cis;
}
@ -46,6 +51,7 @@ public class Prescription implements Serializable {
public void setPresentation(String presentation) {
this.presentation = presentation;
}
public void setStock(Float stock) {
this.stock = stock;
}
@ -114,6 +120,7 @@ public class Prescription implements Serializable {
public int getWarnThreshold() {
return this.warning;
}
public String getLabel_group() {
return label_group;
}
@ -150,6 +157,12 @@ public class Prescription implements Serializable {
Date lastUpdate = new Date(getLast_update());
int numberOfDays = UtilDate.nbOfDaysBetweenDateAndToday(lastUpdate);
if (BuildConfig.DEBUG) {
numberOfDays = 1;
Log.d(TAG, "Set NumberOfDays = 1");
}
if (numberOfDays > 0) {
double takeDuringPeriod = this.take * numberOfDays;
setStock((float) (getStock() - takeDuringPeriod));