mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-21 20:19:23 +01:00
Fix a bug in scheduleAlarm with the timeZone.
This commit is contained in:
parent
43b4010b22
commit
c19787694e
1 changed files with 7 additions and 8 deletions
|
@ -32,16 +32,14 @@ import com.google.zxing.integration.android.IntentIntegrator;
|
|||
import com.google.zxing.integration.android.IntentResult;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static net.foucry.pilldroid.UtilDate.date2String;
|
||||
import static net.foucry.pilldroid.UtilDate.dateAtNoon;
|
||||
import static net.foucry.pilldroid.Utils.intRandomExclusive;
|
||||
|
||||
// Todo: - use same color in website and about
|
||||
|
||||
/**
|
||||
* An activity representing a list of Medicaments. This activity
|
||||
* has different presentations for handset and tablet-size devices. On
|
||||
|
@ -369,21 +367,22 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
public void scheduleAlarm() {
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY,12);
|
||||
Date today = calendar.getTime();
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
Date tomorow = calendar.getTime();
|
||||
Date tomorrow = calendar.getTime();
|
||||
|
||||
if (today.before(dateAtNoon(today))) {
|
||||
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(tomorow.getTime());
|
||||
calendar.setTimeInMillis(tomorrow.getTime());
|
||||
}
|
||||
|
||||
calendar.set(Calendar.HOUR_OF_DAY,12);
|
||||
|
||||
PendingIntent alarmIntent;
|
||||
|
||||
Intent intent = new Intent(this, AlarmReceiver.class);
|
||||
|
|
Loading…
Reference in a new issue