Java 类android.widget.TimePicker 实例源码

项目:godlibrary    文件:DialogDate.java   
public AlertDialog show(Context context) {
    dialog = new AlertDialog.Builder(context).create();
    dialog.show();
    Window window = dialog.getWindow();
    window.setContentView(R.layout.dialog_date_time);
    window.setGravity(Gravity.CENTER);// 此处可以设置dialog显示的位置
    //window.setWindowAnimations(R.style.in_left_out_right_style);
    window.setBackgroundDrawableResource(R.color.transparent);

    datePicker = (DatePicker) window
            .findViewById(R.id.date_time_datePicker1);
    datePicker.setCalendarViewShown(false);
    timePicker = (TimePicker) window.findViewById(R.id.date_time_timePicker);
    but_ok = (Button) window.findViewById(R.id.date_time_but_ok);
    but_ok.setOnClickListener(this);
    return dialog;
}
项目:android-study    文件:DateUI.java   
private void showTime() {

    Calendar c = Calendar.getInstance();
    int mYear = c.get(Calendar.YEAR);
    int mMonth = c.get(Calendar.MONTH);
    int mDay = c.get(Calendar.DAY_OF_MONTH);
    int mHour = c.get(Calendar.HOUR_OF_DAY);
    int mMinute = c.get(Calendar.MINUTE);
    TimePickerDialog dialog =
        new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
          @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

          }
        }, mHour, mMinute, true);
    dialog.show();
  }
项目:AndroidUtility    文件:AlertDialog.java   
@SuppressWarnings("WrongConstant")
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    int hour, min;
    Calendar datetime = Calendar.getInstance();
    String am_pm = "" ;
    datetime.set(Calendar.HOUR_OF_DAY, hourOfDay);
    datetime.set(Calendar.MINUTE, minute);

    if (datetime.get(Calendar.AM_PM) == Calendar.AM)
        am_pm = "AM";
    else if (datetime.get(Calendar.AM_PM) == Calendar.PM)
        am_pm = "PM";
    hourOfDay = hourOfDay > 12 ? hourOfDay - 12 : hourOfDay;
    hour = hourOfDay > 9 ? hourOfDay : hourOfDay;
    min = minute > 9 ? minute : minute;
    timeInterface.setTime(hour, min, am_pm);
}
项目:Sanxing    文件:OperateTaskActivityBase.java   
@OnClick(R.id.task_due_time_content)
void taskDueTimeOnClickBehavior() {
    TimePickerDialog.OnTimeSetListener time = new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int hourOfDay, int minuteOfHour) {
            dueCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            dueCalendar.set(Calendar.MINUTE, minuteOfHour);
            DateFormat sdf = android.text.format.DateFormat.getTimeFormat(getBaseContext());
            dueTimeContent.setText(sdf.format(dueCalendar.getTime()));
            setTime = true;
        }
    };
    new TimePickerDialog(this, time,
            dueCalendar.get(Calendar.HOUR_OF_DAY),
            dueCalendar.get(Calendar.MINUTE), true).show();
}
项目:quickhybrid-android    文件:UIApi.java   
/**
 * 弹出时间选择对话框
 * <p>
 * 参数:
 * title:标题
 * datetime 指定时间 yyyy-MM-dd HH:mm或者HH:mm
 * 返回:
 * time:格式:HH:mm
 */
public static void pickTime(IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        if (date.contains(" ")) {
            calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd HH:mm"));
        } else {
            calendar.setTime(DateUtil.convertString2Date(date, "HH:mm"));
        }
    }
    DialogUtil.pickTime(webLoader.getPageControl().getActivity(), title, calendar, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            calendar.set(Calendar.MINUTE, minute);
            String chooseTime = DateUtil.convertDate(calendar.getTime(), "HH:mm");
            Map<String, Object> map = new HashMap<>();
            map.put("time", chooseTime);
            callback.applySuccess(map);
        }
    });
}
项目:quickhybrid-android    文件:UIApi.java   
/**
 * 弹出日期时间选择对话框
 * <p>
 * 参数:
 * title:标题
 * datetime 指定时间 yyyy-MM-dd HH:mm
 * 返回:
 * datetime:格式:yyyy-MM-dd HH:mm
 */
public static void pickDateTime(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title1 = param.optString("title1");
    String title2 = param.optString("title2");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd HH:mm"));
    }
    DialogUtil.pickDateTime(webLoader.getPageControl().getActivity(), title1, title2, calendar, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            calendar.set(Calendar.MINUTE, minute);
            String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM-dd HH:mm");
            Map<String, Object> map = new HashMap<>();
            map.put("datetime", chooseDate);
            callback.applySuccess(map);
        }
    });
}
项目:cleanhood    文件:CreateEventActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_event);
    mImageView = (ImageView) findViewById(R.id.imageView);
    mEventName  = (EditText) findViewById(R.id.enter_event_name);
    mEventDescription = (EditText) findViewById(R.id.enter_event_desc);
    mCreateEvent = (Button) findViewById(R.id.create_event);
    mdate = (DatePicker) findViewById(R.id.enter_event_date);
    mTime = (TimePicker) findViewById(R.id.enter_event_time);
    mCreateEvent.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            loading= ProgressDialog.show(CreateEventActivity.this,"Creating Event...","Please wait...",false,false);
            createEvent();
        }
    });

    if (isStoragePermissionGranted()){
        accessPic();
    }

}
项目:MyBP    文件:NotificationActivity.java   
@Override
public void onTimeSet(TimePicker timePicker, int hour, int minute) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, hour);
    calendar.set(Calendar.MINUTE, minute);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    editor.putLong("notificationPeriod", calendar.getTimeInMillis());
    editor.commit();

    Intent intent = new Intent(NotificationActivity.this, NotificationReceiver.class);
    intent.setAction(NotificationReceiver.ACTION_NOTIFICATION);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(NotificationActivity.this, 0, intent, 0);
    AlarmManager manager = (AlarmManager) NotificationActivity.this.getSystemService(Context.ALARM_SERVICE);
    manager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 60000, pendingIntent);

    Toast.makeText(NotificationActivity.this, DateUtils.formatDateTime(NotificationActivity.this, calendar.getTimeInMillis(), DateUtils.FORMAT_SHOW_TIME), Toast.LENGTH_LONG).show();
}
项目:puremadrid    文件:DatePickerFragment.java   
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    this.hour = hourOfDay;
    this.minute = minute;

    // Create calendar
    Calendar selectedCalendar = Calendar.getInstance(TimeZone.getTimeZone("CET"));
    selectedCalendar.set(Calendar.YEAR,year);
    selectedCalendar.set(Calendar.MONTH,month);
    selectedCalendar.set(Calendar.DAY_OF_MONTH,day);
    selectedCalendar.set(Calendar.HOUR_OF_DAY,hour);
    selectedCalendar.set(Calendar.MINUTE,0);
    selectedCalendar.set(Calendar.SECOND,0);
    selectedCalendar.set(Calendar.MILLISECOND,0);

    //
    Calendar now = Calendar.getInstance(TimeZone.getTimeZone("CET"));
    if (selectedCalendar.getTimeInMillis() > now.getTimeInMillis()){
        selectedCalendar.set(Calendar.HOUR_OF_DAY, now.get(Calendar.HOUR_OF_DAY));
    }
    if (listener != null) {
        listener.onDateTimeSet(selectedCalendar);
    } else {
        Log.w("DatePickerFragment","There is no listener");
    }
}
项目:orgzly-android    文件:NoteFragmentTest.java   
@Test
public void testSettingPmTimeDisplays24HourTime() {
    onListItem(1).perform(click());

    onView(withId(R.id.fragment_note_deadline_button)).check(matches(allOf(withText(R.string.deadline_button_hint), isDisplayed())));
    onView(withId(R.id.fragment_note_deadline_button)).perform(click());

    /* Set date. */
    onView(withId(R.id.dialog_timestamp_date_picker)).perform(click());
    onView(withClassName(equalTo(DatePicker.class.getName()))).perform(setDate(2014, 4, 1));
    onView(withText(R.string.ok)).perform(click());

    /* Set time. */
    onView(withId(R.id.dialog_timestamp_time_picker)).perform(scrollTo(), click());
    onView(withClassName(equalTo(TimePicker.class.getName()))).perform(setTime(15, 15));
    onView(withText(R.string.ok)).perform(click());

    onView(withText(R.string.set)).perform(click());

    onView(withId(R.id.fragment_note_deadline_button)).check(matches(allOf(withText(userDateTime("<2014-04-01 Tue 15:15>")), isDisplayed())));
}
项目:orgzly-android    文件:QueryFragmentTest.java   
@Test
public void testSchedulingNote() {
    defaultSetUp();

    onView(withId(R.id.drawer_layout)).perform(open());
    onView(withText("Scheduled")).perform(click());
    onView(allOf(withId(android.R.id.list), isDisplayed())).check(matches(listViewItemCount(2)));

    onView(allOf(withText(endsWith("Note C.")), isDisplayed())).perform(longClick());
    onView(withId(R.id.query_cab_edit)).perform(click());
    onView(withText(R.string.schedule)).perform(click());

    onView(withId(R.id.dialog_timestamp_date_picker)).perform(click());
    onView(withClassName(equalTo(DatePicker.class.getName()))).perform(setDate(2014, 4, 1));
    onView(withText(R.string.ok)).perform(click());
    onView(withId(R.id.dialog_timestamp_time_picker)).perform(scrollTo(), click());
    onView(withClassName(equalTo(TimePicker.class.getName()))).perform(setTime(9, 15));
    onView(withText(R.string.ok)).perform(click());
    onView(withText(R.string.set)).perform(click());

    onView(allOf(withId(android.R.id.list), isDisplayed())).check(matches(listViewItemCount(2)));
    onView(withText(userDateTime("<2014-04-01 Tue 09:15>"))).check(matches(isDisplayed()));
}
项目:Lazy-Switches    文件:BluetoothActivity.java   
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

    Calendar calNow = Calendar.getInstance();
    Calendar calSet = (Calendar) calNow.clone();

    calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
    calSet.set(Calendar.MINUTE, minute);
    calSet.set(Calendar.SECOND, 0);
    calSet.set(Calendar.MILLISECOND, 0);

    if (calSet.compareTo(calNow) <= 0) {
        // Today Set time passed, count to tomorrow
        calSet.add(Calendar.DATE, 1);
    }

    setAlarm(calSet);
}
项目:KTools    文件:KDialogActivity.java   
@OnClick(R.id.btn_choose_time_dialog)
public void onBtnChooseTimeDialogClicked() {
    final Calendar calendar = Calendar.getInstance();
    TimePickerDialog dialog = new TimePickerDialog(
            this,
            new TimePickerDialog.OnTimeSetListener() {
                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                    calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
                    calendar.set(Calendar.MINUTE, minute);
                    String time = DateFormat.getTimeInstance(DateFormat.SHORT).format(calendar.getTime());
                    ToastUtils.showShortToast(time);
                }
            },
            calendar.get(Calendar.HOUR_OF_DAY),
            calendar.get(Calendar.MINUTE),
            false
    );
    dialog.show();
}
项目:Toodoo    文件:ToodooNote.java   
public void reminderTimePickerDialog() {
    final Calendar calendar = Calendar.getInstance();
    int mHour = calendar.get(Calendar.HOUR_OF_DAY);
    int mMinute = calendar.get(Calendar.MINUTE);

    final SimpleDateFormat simpleTimeFormat = new SimpleDateFormat("hh:mm a", Locale.US);

    final ToodooTimePickerDialog timePickerDialog = new ToodooTimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int hour, int minute) {
            reminderCalendar.set(Calendar.HOUR_OF_DAY, hour);
            reminderCalendar.set(Calendar.MINUTE, minute);
            selectedReminderValue = reminderCalendar.getTime();
            reminderTimeValue = simpleTimeFormat.format(selectedReminderValue);

            selectedReminder = reminderDateValue + " @ " + reminderTimeValue;

            ToodooOptionsModel ToodooOptionsModel = toodooOptionsList.get(2);
            ToodooOptionsModel.setOptionValue(selectedReminder);
            mAdapter.notifyDataSetChanged();
        }
    }, mHour, mMinute, true);
    timePickerDialog.show();
}
项目:NightLight    文件:AutoFragment.java   
/**
 * Shows time picker dialog and handles the time selected by user
 * @param viewWhoIsCallingIt View whose time time needs to be updated after user selects time
 * @param prefKey Preference for the key needed to be updated after user selects time
 */
private void showTimePickerDialog(final KeyValueView viewWhoIsCallingIt, final String prefKey) {
    int time[] = TimeUtils.getCurrentTimeAsHourAndMinutes();
    TimePickerDialog timePickerDialog = new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int i, int i1) {
            String selectedHour = i < 10 ? "0" + i: "" + i;
            String selectedMinute = i1 < 10 ? "0" +i1: "" + i1;
            String timeString = selectedHour + ":" + selectedMinute;

            PreferenceHelper.putString(context, prefKey, timeString);
            // We also backup the time here
            // To get the prefKey for backup, its "last_" + prefKey
            PreferenceHelper.putString(context, "last_" + prefKey, timeString);

            viewWhoIsCallingIt.setValue(timeString);

            addNextDayIfNecessary();

            doCurrentAutoFunctions(true);
        }
    }, time[0], time[1], false);
    timePickerDialog.show();
}
项目:FormMaster    文件:FormElementPickerTimeViewHolder.java   
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    mCalendarCurrentTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
    mCalendarCurrentTime.set(Calendar.MINUTE, minute);

    String myFormatTime = ((FormElementPickerTime) mFormElement).getTimeFormat(); // custom format
    SimpleDateFormat sdfTime = new SimpleDateFormat(myFormatTime, Locale.US);

    String currentValue = mFormElement.getValue();
    String newValue = sdfTime.format(mCalendarCurrentTime.getTime());

    // trigger event only if the value is changed
    if (!currentValue.equals(newValue)) {
        mReloadListener.updateValue(mPosition, newValue);
    }
}
项目:Beach-Android    文件:PollActivity.java   
private void openTimePicker(){
    final Calendar c = Calendar.getInstance();
    int mHour = c.get(Calendar.HOUR_OF_DAY);
    int mMinute = c.get(Calendar.MINUTE);
    TimePickerDialog timePickerDialog = new TimePickerDialog(this,
            new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker view, int hourOfDay,
                                      int minute) {
                    String date = btnPollExpiryTime.getText().toString();
                    btnPollExpiryTime.setText(date+" "+ hourOfDay + ":" + minute);
                }
            }, mHour, mMinute, false);
    timePickerDialog.show();
}
项目:wisebite_android    文件:Utils.java   
@SuppressWarnings("deprecation")
public static String parseStartEndDate(TimePicker firstTimePicker, TimePicker secondTimePicker) {
    int firstHour, firstMinute, secondHour, secondMinute;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        firstHour = firstTimePicker.getHour();
        firstMinute = firstTimePicker.getMinute();
        secondHour = secondTimePicker.getHour();
        secondMinute = secondTimePicker.getMinute();
    } else {
        firstHour = firstTimePicker.getCurrentHour();
        firstMinute = firstTimePicker.getCurrentMinute();
        secondHour = secondTimePicker.getCurrentHour();
        secondMinute = secondTimePicker.getCurrentMinute();
    }

    return datesToString(firstHour, firstMinute, secondHour, secondMinute);
}
项目:JavaIsFun    文件:Notificacoes.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notificacoes);
    setTitle("Notificações");
    timePicker = (TimePicker) findViewById(R.id.timePicker);
    timePicker.setIs24HourView(true);
    findViewById(R.id.setAlarmButton).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            h = timePicker.getCurrentHour();
            m = timePicker.getCurrentMinute();
            startAlarm();
        }
    });
    findViewById(R.id.cancelAlarm).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            cancelAlarm();
        }
    });
}
项目:TrainPonctuality    文件:TimeSelectionActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_time_selection);

    Bundle extras = getIntent().getExtras();
    setTitle(extras.getInt("title"));
    //noinspection ConstantConditions
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, extras.getInt("color"))));

    dtpTime = (TimePicker) findViewById(R.id.timePicker);
    dtpTime.setIs24HourView(true);
    timeSelection = GregorianCalendar.getInstance();
    timeSelection.setTimeInMillis(extras.getLong("date"));
    //noinspection deprecation
    dtpTime.setCurrentHour(timeSelection.get(Calendar.HOUR_OF_DAY));
    //noinspection deprecation
    dtpTime.setCurrentMinute(timeSelection.get(Calendar.MINUTE));
}
项目:TherapyGuide    文件:SettingsScreenTest.java   
@Test
public void backOnReminderTimeDialogDoesNotRecordTime() {
    // Click on settings
    onView(withId(R.id.settings)).perform(click());

    // Enable the diary alert
    onData(PreferenceMatchers.withKey("pref_diary_alert")).perform(click());

    // Click on reminder time setting
    onData(PreferenceMatchers.withKey("pref_diary_alert_time")).perform(click());

    // Set the time
    onView(withClassName(equalTo(TimePicker.class.getName()))).perform(SettingsActions.setTime(5, 30));

    // Rotate the view
    rotateScreen();

    // Click back
    onView(withClassName(equalTo(TimePicker.class.getName()))).perform(pressBack());

    // Verify old time is still displayed
    onData(PreferenceMatchers.withKey("pref_diary_alert_time"))
            .onChildView(withText("16:00")).check(matches(isDisplayed()));
}
项目:TherapyGuide    文件:SettingsScreenTest.java   
@Test
public void cancelReminderTimeDialogDoesNotRecordTime() {
    // Click on settings
    onView(withId(R.id.settings)).perform(click());

    // Enable the diary alert
    onData(PreferenceMatchers.withKey("pref_diary_alert")).perform(click());

    // Click on reminder time setting
    onData(PreferenceMatchers.withKey("pref_diary_alert_time")).perform(click());

    // Set the time
    onView(withClassName(equalTo(TimePicker.class.getName()))).perform(SettingsActions.setTime(5, 30));

    // Rotate the view
    rotateScreen();

    // Click cancel
    onView(withText("Cancel")).perform(click());

    // Verify old time is still displayed
    onData(PreferenceMatchers.withKey("pref_diary_alert_time"))
            .onChildView(withText("16:00")).check(matches(isDisplayed()));
}
项目:A.scribe    文件:MinTimePickerDialog.java   
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
    boolean validTime = true;

    if (hourOfDay < minHour) {
        validTime = false;
    } else if (hourOfDay == minHour) {
        if (minute < minMinute) {
            if (hourOfDay != currentHour) {
                currentHour = hourOfDay;
                currentMinute = minMinute;
            }
            validTime = false;
        }
    }

    if (validTime) {
        currentHour = hourOfDay;
        currentMinute = minute;
    } else {
        updateTime(currentHour, currentMinute);
    }
}
项目:SERC-ENERYGY-METERING-MOBILE-APP    文件:GraphTabbed.java   
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    // Show Chosen Time in TextView
    String timeText = String.valueOf(hourOfDay) + ":" + String.valueOf(minute) + " hrs";
    TextView startTimeText = (TextView) getActivity().findViewById(R.id.textview_set_start_time);
    startTimeText.setText(timeText);

    // Get Date from Activity
    int day = ((GraphTabbed)getActivity()).day_start;
    int month = ((GraphTabbed)getActivity()).month_start;
    int year = ((GraphTabbed)getActivity()).year_start;
    // Setting the UNIX timestamp that will be sent in the link for startTime
    Calendar chosenStart = Calendar.getInstance();
    chosenStart.set(year, month, day, hourOfDay, minute);
    ((GraphTabbed)getActivity()).startTime = String.valueOf(chosenStart.getTimeInMillis());
    //setLink();

    // Set the global variable to time chosen
    ((GraphTabbed)getActivity()).hour_start = hourOfDay;
    ((GraphTabbed)getActivity()).minute_start = minute;

}
项目:SERC-ENERYGY-METERING-MOBILE-APP    文件:GraphTabbed.java   
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    // Show Chosen Time in TextView
    String timeText = String.valueOf(hourOfDay) + ":" + String.valueOf(minute) + " hrs";
    TextView endTimeText = (TextView) getActivity().findViewById(R.id.textview_set_end_time);
    endTimeText.setText(timeText);

    // Get Date from Activity
    int day = ((GraphTabbed)getActivity()).day_end;
    int month = ((GraphTabbed)getActivity()).month_end;
    int year = ((GraphTabbed)getActivity()).year_end;
    // Setting the UNIX timestamp that will be sent in the link for endTime
    Calendar chosenStart = Calendar.getInstance();
    chosenStart.set(year, month, day, hourOfDay, minute);
    ((GraphTabbed)getActivity()).endTime = String.valueOf(chosenStart.getTimeInMillis());
    //setLink();

    // Set the global variable to time chosen
    ((GraphTabbed)getActivity()).hour_end = hourOfDay;
    ((GraphTabbed)getActivity()).minute_end = minute;

}
项目:SERC-ENERYGY-METERING-MOBILE-APP    文件:GraphActivity.java   
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    // Sets the value chosen to the global variable (so as to update the link to be sent)
    hour_start = hourOfDay;
    minute_start = minute;

    // Set TextView textview_set_start_time to show the current chosen start time
    startTimeTextView.setText(hour_start+":"+minute_start+"hrs");

    // Setting the UNIX timestamp that will be sent in the link for startTime
    Calendar chosenStart = Calendar.getInstance();
    chosenStart.set(year_start, month_start, day_start, hour_start, minute_start);
    startTime = String.valueOf(chosenStart.getTimeInMillis());
    setLink();
    Log.i("Chosen Start Time", startTime);
    Log.i("Start and End Time", "Start: " + hour_start+":"+minute_start+"hrs" + " End:" + hour_end+":"+minute_end+"hrs");
}
项目:SERC-ENERYGY-METERING-MOBILE-APP    文件:GraphActivity.java   
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    // Sets the value chosen to the global variable (so as to update the link to be sent)
    hour_end = hourOfDay;
    minute_end = minute;

    // Set TextView textview_set_end_time to show the current chosen end time
    endTimeTextView.setText(hour_end+":"+minute_end+"hrs");

    // Setting the UNIX timestamp that will be sent in the link for endTime
    Calendar chosenEnd = Calendar.getInstance();
    chosenEnd.set(year_end, month_end, day_end, hour_end, minute_end);
    endTime = String.valueOf(chosenEnd.getTimeInMillis());
    setLink();
    Log.i("Chosen End Time", endTime);
    Log.i("Start and End Time", "Start: " + hour_start+":"+minute_start+"hrs" + " End:" + hour_end+":"+minute_end+"hrs");
}
项目:q-mail    文件:TimePickerPreference.java   
@Override
protected View onCreateDialogView() {

    TimePicker tp = new TimePicker(getContext());
    tp.setIs24HourView(DateFormat.is24HourFormat(getContext()));
    tp.setOnTimeChangedListener(this);
    originalHour = getHour();
    originalMinute = getMinute();
    if (originalHour >= 0 && originalMinute >= 0) {
        tp.setCurrentHour(originalHour);
        tp.setCurrentMinute(originalMinute);
    }

    return tp;
}
项目:q-mail    文件:TimePickerPreference.java   
/**
 * @see
 * android.widget.TimePicker.OnTimeChangedListener#onTimeChanged(android
 * .widget.TimePicker, int, int)
 */
@Override
public void onTimeChanged(final TimePicker view, final int hour, final int minute) {

    persistString(String.format(Locale.US, "%02d:%02d", hour, minute));
    callChangeListener(String.format(Locale.US, "%02d:%02d", hour, minute));
}
项目:Moodr    文件:EditMoodActivity.java   
@Override
public void onTimeSet(TimePicker timePicker, int hour, int minute) {
    hourFinal = hour;
    minuteFinal = minute;

    editDate_copy = new Date(yearFinal - 1900, monthFinal - 1, dayFinal, hourFinal, minuteFinal);

    java.text.DateFormat dateFormat = new SimpleDateFormat("MMM dd yyyy HH:mm", Locale.US);
    editDate.setText(dateFormat.format(editDate_copy));

}
项目:quickhybrid-android    文件:DialogUtil.java   
/**
 * 时间选择对话框
 *
 * @param con      上下文
 * @param title    标题
 * @param listener 选择事件
 * @param cal      默认时间
 */
public static void pickTime(Context con, String title, Calendar cal, final OnTimeSetListener listener) {
    LinearLayout ll = new LinearLayout(con);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    ll.setLayoutParams(layoutParams);
    ll.setOrientation(LinearLayout.VERTICAL);
    //添加一条线
    LinearLayout line = new LinearLayout(con);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1);
    line.setBackgroundColor(con.getResources().getColor(R.color.line));
    line.setLayoutParams(lp);
    ll.addView(line);
    //添加选择器控件
    final TimePicker timePicker = new TimePicker(con, null, themeId);
    timePicker.setLayoutParams(layoutParams);
    timePicker.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(cal.get(Calendar.MINUTE));
    timePicker.setIs24HourView(true);
    ll.addView(timePicker);
    QuickDialog.Builder builder = new QuickDialog.Builder(con);
    builder.setContentView(ll);
    builder.setTitle(title);
    builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            listener.onTimeSet(timePicker, timePicker.getCurrentHour(), timePicker.getCurrentMinute());
        }
    });
    builder.create().show();
}
项目:orgzly-android    文件:MiscTest.java   
@Test
public void testSchedulingMultipleNotes() {
    shelfTestUtils.setupBook("book-name",
            "Sample book used for tests\n" +
            "* Note #1.\n" +
            "* Note #2.\n" +
            "** TODO Note #3.\n" +
            "** Note #4.\n" +
            "*** DONE Note #5.\n" +
            "CLOSED: [2014-06-03 Tue 13:34]\n" +
            "");
    activityRule.launchActivity(null);

    onView(allOf(withText("book-name"), isDisplayed())).perform(click());

    onListItem(1).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(not(isDisplayed())));
    onListItem(2).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(not(isDisplayed())));
    onListItem(3).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(not(isDisplayed())));
    onListItem(4).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(not(isDisplayed())));
    onListItem(5).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(not(isDisplayed())));

    onListItem(1).perform(longClick());
    onListItem(2).perform(click());
    onListItem(3).perform(click());
    openContextualActionModeOverflowMenu();
    onView(withText(R.string.schedule)).perform(click());
    onView(withId(R.id.dialog_timestamp_date_picker)).perform(click());
    onView(withClassName(equalTo(DatePicker.class.getName()))).perform(setDate(2014, 4, 1));
    onView(withText(R.string.ok)).perform(click());
    onView(withId(R.id.dialog_timestamp_time_picker)).perform(scrollTo(), click());
    onView(withClassName(equalTo(TimePicker.class.getName()))).perform(setTime(9, 15));
    onView(withText(R.string.ok)).perform(click());
    onView(withText(R.string.set)).perform(click());

    onListItem(1).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(allOf(isDisplayed(), withText(userDateTime("<2014-04-01 Tue 09:15>")))));
    onListItem(2).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(allOf(isDisplayed(), withText(userDateTime("<2014-04-01 Tue 09:15>")))));
    onListItem(3).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(allOf(isDisplayed(), withText(userDateTime("<2014-04-01 Tue 09:15>")))));
    onListItem(4).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(not(isDisplayed())));
    onListItem(5).onChildView(withId(R.id.item_head_scheduled_text)).check(matches(not(isDisplayed())));
}
项目:orgzly-android    文件:NoteFragmentTest.java   
@Test
public void testDateTimePickerKeepsValuesAfterRotation() {
    onListItem(1).perform(click());

    onView(withId(R.id.fragment_note_deadline_button)).check(matches(allOf(withText(R.string.deadline_button_hint), isDisplayed())));

    toPortrait(activityRule);

    onView(withText(R.string.deadline_button_hint)).perform(click());

    /* Set date. */
    onView(withId(R.id.dialog_timestamp_date_picker)).perform(click());
    onView(withClassName(equalTo(DatePicker.class.getName()))).perform(setDate(2014, 4, 1));
    onView(withText(R.string.ok)).perform(click());

    /* Set time. */
    onView(withId(R.id.dialog_timestamp_time_picker)).perform(scrollTo(), click());
    onView(withClassName(equalTo(TimePicker.class.getName()))).perform(setTime(9, 15));
    onView(withText(R.string.ok)).perform(click());

    /* Rotate screen. */
    toLandscape(activityRule);

    /* Set time. */
    onView(withText(R.string.set)).perform(click());

    onView(withId(R.id.fragment_note_deadline_button)).check(matches(allOf(withText(userDateTime("<2014-04-01 Tue 09:15>")), isDisplayed())));
}
项目:Bee-Analyzer    文件:DateField.java   
@Override
public void onTimeSet(TimePicker timePicker, int hourOfDay, int minute) {
    if(choiceTime == 0){
        Start.set(Calendar.HOUR_OF_DAY, hourOfDay);
        Start.set(Calendar.MINUTE, minute);
        choiceTime = 1;
        new TimePickerDialog(ctx, this, Start.get(Calendar.HOUR_OF_DAY),Start.get(Calendar.MINUTE),true).show();
    }
    else if(choiceTime == 1){
        Stop.set(Calendar.HOUR_OF_DAY, hourOfDay);
        Stop.set(Calendar.MINUTE, minute);
        choiceTime = 0;
    }
    setTextField();
}
项目:MyFlightbookAndroid    文件:DlgDatePicker.java   
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
    GregorianCalendar c = getCalendar();

    c.set(dpDate.getYear(), dpDate.getMonth(), dpDate.getDayOfMonth(), hourOfDay, minute);
    this.m_Date = c.getTime();

    if (m_Mode == datePickMode.UTCDATETIME)
        NotifyDelegate();
}
项目:JPush    文件:SettingActivity.java   
private void init(){
    startTime = (TimePicker) findViewById(R.id.start_time);
    endTime = (TimePicker) findViewById(R.id.end_time);
    startTime.setIs24HourView(DateFormat.is24HourFormat(this));
    endTime.setIs24HourView(DateFormat.is24HourFormat(this));
    mSetTime = (Button)findViewById(R.id.bu_setTime);
    mMonday = (CheckBox)findViewById(R.id.cb_monday);
    mTuesday = (CheckBox)findViewById(R.id.cb_tuesday);
    mWednesday = (CheckBox)findViewById(R.id.cb_wednesday);
    mThursday = (CheckBox)findViewById(R.id.cb_thursday);
    mFriday = (CheckBox)findViewById(R.id.cb_friday);
    mSaturday = (CheckBox)findViewById(R.id.cb_saturday);
    mSunday = (CheckBox)findViewById(R.id.cb_sunday);
}
项目:WeatherAlarmClock    文件:AddAlarmActivity.java   
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    String min = String.valueOf(minute);
    String hour = String.valueOf(hourOfDay);

    tvHours.setText(hour);
    tvMin.setText(min);
    alarmClockLab.setMinute(minute);
    alarmClockLab.setHour(hourOfDay);


}
项目:WeatherAlarmClock    文件:EditAlarmActivity.java   
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    String min = String.valueOf(minute);
    String hour = String.valueOf(hourOfDay);

    tvHours.setText(hour);
    tvMin.setText(min);
    alarmClockLab.setMinute(minute);
    alarmClockLab.setHour(hourOfDay);


}
项目:SimpleDialogFragments    文件:SimpleTimeDialog.java   
@SuppressWarnings("deprecation")
@Override
protected View onCreateContentView(Bundle savedInstanceState) {

    picker = new TimePicker(getContext());

    if (savedInstanceState != null){
        picker.setCurrentHour(savedInstanceState.getInt(HOUR));
        picker.setCurrentMinute(savedInstanceState.getInt(MINUTE));

    } else {
        if (getArguments().containsKey(HOUR)) {
            picker.setCurrentHour(getArguments().getInt(HOUR));
        }
        if (getArguments().containsKey(MINUTE)) {
            picker.setCurrentMinute(getArguments().getInt(MINUTE));
        }
    }

    if (getArguments().containsKey(VIEW_24_HOUR)) {
        picker.setIs24HourView(getArguments().getBoolean(VIEW_24_HOUR));
    } else {
        picker.setIs24HourView(DateFormat.is24HourFormat(getContext())); // system default
    }
    picker.setOnTimeChangedListener(this);

    return picker;
}
项目:CouponsTracker    文件:SettingsFragment.java   
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    DebugLog.logMethod();
    SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putInt(KEY_NOTIFICATION_TIME, hourOfDay * 100 + minute);
    editor.apply();
}