mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Add If Build.Config tests
remove dead code
This commit is contained in:
parent
f2a4d65802
commit
682af77f97
1 changed files with 7 additions and 29 deletions
|
@ -39,7 +39,7 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|||
scheduleAlarm(context);
|
||||
}
|
||||
|
||||
Toast.makeText(context, "New stock calculated", Toast.LENGTH_LONG).show();
|
||||
if (BuildConfig.DEBUG) { Toast.makeText(context, "New stock calculated", Toast.LENGTH_LONG).show(); }
|
||||
createNotificationChannel(context);
|
||||
DBHelper dbHelper = new DBHelper(context);
|
||||
dbHelper.getAllDrugs();
|
||||
|
@ -123,34 +123,19 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|||
Date today;
|
||||
Date tomorrow;
|
||||
|
||||
/*if (BuildConfig.DEBUG) {
|
||||
calendar.add(Calendar.HOUR_OF_DAY, 12);
|
||||
today = calendar.getTime();
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
tomorrow = calendar.getTime();
|
||||
} else {*/
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 11);
|
||||
today = calendar.getTime();
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
tomorrow = calendar.getTime();
|
||||
// }
|
||||
|
||||
LocalTime todayNow = LocalTime.now();
|
||||
|
||||
if (todayNow.isBefore(LocalTime.NOON)) {
|
||||
// schedule date = today
|
||||
//calendar.setTimeInMillis(dateAtNoon(today).getTime());
|
||||
calendar.setTimeInMillis(today.getTime());
|
||||
} else {
|
||||
// schedule date = tomorrow
|
||||
calendar.setTimeInMillis(tomorrow.getTime());
|
||||
}
|
||||
|
||||
/* if (BuildConfig.DEBUG)
|
||||
{
|
||||
calendar.setTimeInMillis(today.getTime());
|
||||
}*/
|
||||
|
||||
PendingIntent alarmIntent;
|
||||
|
||||
Intent intent = new Intent(context, AlarmReceiver.class);
|
||||
|
@ -158,18 +143,11 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|||
|
||||
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
|
||||
boolean alarmUp = (PendingIntent.getBroadcast(context, 0, intent,
|
||||
PendingIntent.FLAG_NO_CREATE) != null);
|
||||
if (alarmUp) {
|
||||
Log.d(TAG, "Alarm already active");
|
||||
}
|
||||
|
||||
|
||||
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,(calendar.getTimeInMillis()),
|
||||
AlarmManager.INTERVAL_DAY, alarmIntent);
|
||||
|
||||
Log.d(TAG, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()));
|
||||
|
||||
Toast.makeText(context, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()), Toast.LENGTH_SHORT).show();
|
||||
if (BuildConfig.DEBUG) { Toast.makeText(context, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()), Toast.LENGTH_SHORT).show(); }
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue