use of james.alarmio.dialogs.TimeChooserDialog in project Alarmio by TheAndroidMaster.
the class AlarmActivity method onSlideLeft.
@Override
public void onSlideLeft() {
final int[] minutes = new int[] { 2, 5, 10, 20, 30, 60 };
CharSequence[] names = new CharSequence[minutes.length + 1];
for (int i = 0; i < minutes.length; i++) {
names[i] = FormatUtils.formatUnit(AlarmActivity.this, minutes[i]);
}
names[minutes.length] = getString(R.string.title_snooze_custom);
stopAnnoyingness();
new AlertDialog.Builder(AlarmActivity.this, isDark ? R.style.Theme_AppCompat_Dialog_Alert : R.style.Theme_AppCompat_Light_Dialog_Alert).setItems(names, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which < minutes.length) {
TimerData timer = alarmio.newTimer();
timer.setDuration(TimeUnit.MINUTES.toMillis(minutes[which]), alarmio);
timer.setVibrate(AlarmActivity.this, isVibrate);
timer.setSound(AlarmActivity.this, sound);
timer.set(alarmio, ((AlarmManager) AlarmActivity.this.getSystemService(Context.ALARM_SERVICE)));
alarmio.onTimerStarted();
finish();
} else {
TimeChooserDialog timerDialog = new TimeChooserDialog(AlarmActivity.this);
timerDialog.setListener(new TimeChooserDialog.OnTimeChosenListener() {
@Override
public void onTimeChosen(int hours, int minutes, int seconds) {
TimerData timer = alarmio.newTimer();
timer.setVibrate(AlarmActivity.this, isVibrate);
timer.setSound(AlarmActivity.this, sound);
timer.setDuration(TimeUnit.HOURS.toMillis(hours) + TimeUnit.MINUTES.toMillis(minutes) + TimeUnit.SECONDS.toMillis(seconds), alarmio);
timer.set(alarmio, ((AlarmManager) getSystemService(Context.ALARM_SERVICE)));
alarmio.onTimerStarted();
finish();
}
});
timerDialog.show();
}
}
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).show();
overlay.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
use of james.alarmio.dialogs.TimeChooserDialog in project Alarmio by TheAndroidMaster.
the class TimePreferenceData method onClick.
@Override
public void onClick(final ViewHolder holder) {
int minutes = preference.getValue(holder.getContext());
int hours = (int) TimeUnit.MINUTES.toHours(minutes);
minutes %= TimeUnit.HOURS.toMinutes(1);
TimeChooserDialog dialog = new TimeChooserDialog(holder.getContext());
dialog.setDefault(hours, minutes, 0);
dialog.setListener(new TimeChooserDialog.OnTimeChosenListener() {
@Override
public void onTimeChosen(int hours, int minutes, int seconds) {
minutes += TimeUnit.HOURS.toMinutes(hours);
preference.setValue(holder.getContext(), minutes);
bindViewHolder(holder);
}
});
dialog.show();
}
Aggregations