Search in sources :

Example 1 with TimePickerFragment

use of com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment in project xDrip by NightscoutFoundation.

the class Reminders method askTime.

// //
private void askTime(final int position) {
    final Calendar calendar = Calendar.getInstance();
    final Reminder reminder = reminders.get(position);
    calendar.setTimeInMillis(reminder.next_due);
    final TimePickerFragment timePickerFragment = new TimePickerFragment();
    timePickerFragment.setTime(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE));
    timePickerFragment.setTitle("What time of day?");
    timePickerFragment.setTimeCallback(new ProfileAdapter.TimePickerCallbacks() {

        @Override
        public void onTimeUpdated(int newmins) {
            int min = newmins % 60;
            int hour = (newmins - min) / 60;
            calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), hour, min);
            reminder.next_due = calendar.getTimeInMillis();
            // reset this field
            reminder.snoozed_till = 0;
            reminder.save();
            freshen(reminder);
        }
    });
    timePickerFragment.show(this.getFragmentManager(), "TimePicker");
    // appears on top
    if (JoH.msTill(reminder.next_due) > Constants.DAY_IN_MS) {
        final DatePickerFragment datePickerFragment = new DatePickerFragment();
        datePickerFragment.setAllowFuture(true);
        datePickerFragment.setEarliestDate(JoH.tsl());
        datePickerFragment.setInitiallySelectedDate(reminder.next_due);
        datePickerFragment.setTitle("Which day?");
        datePickerFragment.setDateCallback(new ProfileAdapter.DatePickerCallbacks() {

            @Override
            public void onDateSet(int year, int month, int day) {
                calendar.set(year, month, day);
            }
        });
        datePickerFragment.show(this.getFragmentManager(), "DatePicker");
    }
}
Also used : ProfileAdapter(com.eveningoutpost.dexdrip.profileeditor.ProfileAdapter) DatePickerFragment(com.eveningoutpost.dexdrip.profileeditor.DatePickerFragment) Reminder(com.eveningoutpost.dexdrip.Models.Reminder) TimePickerFragment(com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment) Calendar(java.util.Calendar)

Example 2 with TimePickerFragment

use of com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment in project xDrip by NightscoutFoundation.

the class StartNewSensor method askSesorInsertionTime.

private void askSesorInsertionTime() {
    final Calendar calendar = Calendar.getInstance();
    TimePickerFragment timePickerFragment = new TimePickerFragment();
    timePickerFragment.setTime(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE));
    timePickerFragment.setTitle("What time was it inserted?");
    timePickerFragment.setTimeCallback(new ProfileAdapter.TimePickerCallbacks() {

        @Override
        public void onTimeUpdated(int newmins) {
            int min = newmins % 60;
            int hour = (newmins - min) / 60;
            ucalendar.set(ucalendar.get(Calendar.YEAR), ucalendar.get(Calendar.MONTH), ucalendar.get(Calendar.DAY_OF_MONTH), hour, min);
            if (DexCollectionType.hasLibre()) {
                // hack for warmup time
                ucalendar.add(Calendar.HOUR_OF_DAY, -1);
            }
            realStartSensor();
        }
    });
    timePickerFragment.show(activity.getFragmentManager(), "TimePicker");
}
Also used : ProfileAdapter(com.eveningoutpost.dexdrip.profileeditor.ProfileAdapter) TimePickerFragment(com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment) Calendar(java.util.Calendar)

Example 3 with TimePickerFragment

use of com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment in project xDrip-plus by jamorham.

the class Reminders method askTime.

// //
private void askTime(final int position) {
    final Calendar calendar = Calendar.getInstance();
    final Reminder reminder = reminders.get(position);
    calendar.setTimeInMillis(reminder.next_due);
    final TimePickerFragment timePickerFragment = new TimePickerFragment();
    timePickerFragment.setTime(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE));
    timePickerFragment.setTitle("What time of day?");
    timePickerFragment.setTimeCallback(new ProfileAdapter.TimePickerCallbacks() {

        @Override
        public void onTimeUpdated(int newmins) {
            int min = newmins % 60;
            int hour = (newmins - min) / 60;
            calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), hour, min);
            reminder.next_due = calendar.getTimeInMillis();
            // reset this field
            reminder.snoozed_till = 0;
            reminder.save();
            freshen(reminder);
        }
    });
    timePickerFragment.show(this.getFragmentManager(), "TimePicker");
    // appears on top
    if (JoH.msTill(reminder.next_due) > Constants.DAY_IN_MS) {
        final DatePickerFragment datePickerFragment = new DatePickerFragment();
        datePickerFragment.setAllowFuture(true);
        datePickerFragment.setEarliestDate(JoH.tsl());
        datePickerFragment.setInitiallySelectedDate(reminder.next_due);
        datePickerFragment.setTitle("Which day?");
        datePickerFragment.setDateCallback(new ProfileAdapter.DatePickerCallbacks() {

            @Override
            public void onDateSet(int year, int month, int day) {
                calendar.set(year, month, day);
            }
        });
        datePickerFragment.show(this.getFragmentManager(), "DatePicker");
    }
}
Also used : ProfileAdapter(com.eveningoutpost.dexdrip.profileeditor.ProfileAdapter) DatePickerFragment(com.eveningoutpost.dexdrip.profileeditor.DatePickerFragment) Reminder(com.eveningoutpost.dexdrip.Models.Reminder) TimePickerFragment(com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment) Calendar(java.util.Calendar)

Example 4 with TimePickerFragment

use of com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment in project xDrip-plus by jamorham.

the class StartNewSensor method askSesorInsertionTime.

private void askSesorInsertionTime() {
    final Calendar calendar = Calendar.getInstance();
    TimePickerFragment timePickerFragment = new TimePickerFragment();
    timePickerFragment.setTime(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE));
    timePickerFragment.setTitle("What time was it inserted?");
    timePickerFragment.setTimeCallback(new ProfileAdapter.TimePickerCallbacks() {

        @Override
        public void onTimeUpdated(int newmins) {
            int min = newmins % 60;
            int hour = (newmins - min) / 60;
            ucalendar.set(ucalendar.get(Calendar.YEAR), ucalendar.get(Calendar.MONTH), ucalendar.get(Calendar.DAY_OF_MONTH), hour, min);
            if (DexCollectionType.hasLibre()) {
                // hack for warmup time
                ucalendar.add(Calendar.HOUR_OF_DAY, -1);
            }
            realStartSensor();
        }
    });
    timePickerFragment.show(activity.getFragmentManager(), "TimePicker");
}
Also used : ProfileAdapter(com.eveningoutpost.dexdrip.profileeditor.ProfileAdapter) TimePickerFragment(com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment) Calendar(java.util.Calendar)

Aggregations

ProfileAdapter (com.eveningoutpost.dexdrip.profileeditor.ProfileAdapter)4 TimePickerFragment (com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment)4 Calendar (java.util.Calendar)4 Reminder (com.eveningoutpost.dexdrip.Models.Reminder)2 DatePickerFragment (com.eveningoutpost.dexdrip.profileeditor.DatePickerFragment)2