use of android.app.TimePickerDialog in project qksms by moezbhatti.
the class TimePickerFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (mPreference == null) {
Log.w(TAG, "No preference set");
return null;
}
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("H:mm");
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
try {
Date date = simpleDateFormat.parse(mPrefs.getString(mPreference.getKey(), "6:00"));
c.setTime(date);
} catch (ParseException e) {
e.printStackTrace();
}
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
boolean isUsing24HourTime = DateFormat.is24HourFormat(getActivity());
return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime);
}
use of android.app.TimePickerDialog in project android_frameworks_base by ParanoidAndroid.
the class TimeDialogActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout layout = new FrameLayout(this);
Button b = new Button(this);
b.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
b.setText("Show dialog");
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new TimePickerDialog(TimeDialogActivity.this, null, 12, 12, true).show();
}
});
layout.addView(b);
setContentView(layout);
}
use of android.app.TimePickerDialog in project Etar-Calendar by Etar-Group.
the class OtherPreferences method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
PreferenceManager manager = getPreferenceManager();
manager.setSharedPreferencesName(SHARED_PREFS_NAME);
SharedPreferences prefs = manager.getSharedPreferences();
addPreferencesFromResource(R.xml.other_preferences);
mCopyDb = findPreference(KEY_OTHER_COPY_DB);
mSkipReminders = (ListPreference) findPreference(KEY_OTHER_REMINDERS_RESPONDED);
String skipPreferencesValue = null;
if (mSkipReminders != null) {
skipPreferencesValue = mSkipReminders.getValue();
mSkipReminders.setOnPreferenceChangeListener(this);
}
updateSkipRemindersSummary(skipPreferencesValue);
Activity activity = getActivity();
if (activity == null) {
Log.d(TAG, "Activity was null");
}
mIs24HourMode = DateFormat.is24HourFormat(activity);
mQuietHours = (CheckBoxPreference) findPreference(KEY_OTHER_QUIET_HOURS);
int startHour = prefs.getInt(KEY_OTHER_QUIET_HOURS_START_HOUR, QUIET_HOURS_DEFAULT_START_HOUR);
int startMinute = prefs.getInt(KEY_OTHER_QUIET_HOURS_START_MINUTE, QUIET_HOURS_DEFAULT_START_MINUTE);
mQuietHoursStart = findPreference(KEY_OTHER_QUIET_HOURS_START);
mQuietHoursStartListener = new TimeSetListener(START_LISTENER);
mQuietHoursStartDialog = new TimePickerDialog(activity, mQuietHoursStartListener, startHour, startMinute, mIs24HourMode);
mQuietHoursStart.setSummary(formatTime(startHour, startMinute));
int endHour = prefs.getInt(KEY_OTHER_QUIET_HOURS_END_HOUR, QUIET_HOURS_DEFAULT_END_HOUR);
int endMinute = prefs.getInt(KEY_OTHER_QUIET_HOURS_END_MINUTE, QUIET_HOURS_DEFAULT_END_MINUTE);
mQuietHoursEnd = findPreference(KEY_OTHER_QUIET_HOURS_END);
mQuietHoursEndListener = new TimeSetListener(END_LISTENER);
mQuietHoursEndDialog = new TimePickerDialog(activity, mQuietHoursEndListener, endHour, endMinute, mIs24HourMode);
mQuietHoursEnd.setSummary(formatTime(endHour, endMinute));
}
use of android.app.TimePickerDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DateTimeSettings method onCreateDialog.
@Override
public Dialog onCreateDialog(int id) {
final Calendar calendar = Calendar.getInstance();
switch(id) {
case DIALOG_DATEPICKER:
DatePickerDialog d = new DatePickerDialog(getActivity(), this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
configureDatePicker(d.getDatePicker());
return d;
case DIALOG_TIMEPICKER:
return new TimePickerDialog(getActivity(), this, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(getActivity()));
default:
throw new IllegalArgumentException();
}
}
use of android.app.TimePickerDialog in project chromeview by pwnall.
the class InputDialogContainer method showDialog.
void showDialog(final int dialogType, int year, int month, int monthDay, int hour, int minute, int second) {
if (isDialogShowing())
mDialog.dismiss();
Time time = normalizeTime(year, month, monthDay, hour, minute, second);
if (dialogType == sTextInputTypeDate) {
mDialog = new DatePickerDialog(mContext, new DateListener(dialogType), time.year, time.month, time.monthDay);
mDialog.setTitle(mContext.getText(R.string.date_picker_dialog_title));
} else if (dialogType == sTextInputTypeTime) {
mDialog = new TimePickerDialog(mContext, new TimeListener(dialogType), time.hour, time.minute, DateFormat.is24HourFormat(mContext));
} else if (dialogType == sTextInputTypeDateTime || dialogType == sTextInputTypeDateTimeLocal) {
mDialog = new DateTimePickerDialog(mContext, new DateTimeListener(dialogType), time.year, time.month, time.monthDay, time.hour, time.minute, DateFormat.is24HourFormat(mContext));
} else if (dialogType == sTextInputTypeMonth) {
mDialog = new MonthPickerDialog(mContext, new MonthListener(dialogType), time.year, time.month);
}
mDialog.setButton(DialogInterface.BUTTON_POSITIVE, mContext.getText(R.string.date_picker_dialog_set), (DialogInterface.OnClickListener) mDialog);
mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mContext.getText(android.R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mDialogAlreadyDismissed = true;
mInputActionDelegate.cancelDateTimeDialog();
}
});
mDialog.setButton(DialogInterface.BUTTON_NEUTRAL, mContext.getText(R.string.date_picker_dialog_clear), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mDialogAlreadyDismissed = true;
mInputActionDelegate.replaceDateTime(dialogType, 0, 0, 0, 0, 0, 0);
}
});
mDialogAlreadyDismissed = false;
mDialog.show();
}
Aggregations