List of usage examples for android.widget TimePicker getCurrentHour
@NonNull
@Deprecated
public Integer getCurrentHour()
From source file:Main.java
/** * @param timePicker/*from www . j a v a2 s . com*/ * @return time as milliseconds since 00:00:00:000 (midnight) */ public static long getTime(TimePicker timePicker) { int h = timePicker.getCurrentHour().intValue(); int m = timePicker.getCurrentMinute().intValue(); return (h * 3600 + m * 60) * 1000; }
From source file:Main.java
/** * Get time from TimePicker// w w w. j a v a 2 s.c o m * * @param timePicker * @return time string */ public static String getStringTimeFromTimePicker(TimePicker timePicker) { String time = ""; int hour = timePicker.getCurrentHour(); int minute = timePicker.getCurrentMinute(); time = getStringTimeFromTime(hour, minute); return time; }
From source file:Main.java
public static final long getValidTime(TimePicker timePicker) { Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour().intValue()); c.set(Calendar.MINUTE, timePicker.getCurrentMinute().intValue()); return c.getTimeInMillis(); }
From source file:net.czlee.debatekeeper.PrepTimeBellsEditActivity.java
private static Bundle createBellBundleFromAddOrEditDialog(final Dialog dialog) { final Spinner typeSpinner = (Spinner) dialog.findViewById(R.id.addPrepTimeBellDialog_typeSpinner); final TimePicker timePicker = (TimePicker) dialog.findViewById(R.id.addPrepTimeBellDialog_timePicker); final EditText editText = (EditText) dialog.findViewById(R.id.addPrepTimeBellDialog_editText); int typeSelected = typeSpinner.getSelectedItemPosition(); Bundle bundle = new Bundle(); switch (typeSelected) { case ADD_PREP_TIME_BELL_TYPE_START: case ADD_PREP_TIME_BELL_TYPE_FINISH: // We're using this in hours and minutes, not minutes and seconds int minutes = timePicker.getCurrentHour(); int seconds = timePicker.getCurrentMinute(); long time = minutes * 60 + seconds; if (typeSelected == ADD_PREP_TIME_BELL_TYPE_START) bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_START); else/* w ww .j a va2 s .c o m*/ bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_FINISH); bundle.putLong(PrepTimeBellsManager.KEY_TIME, time); break; case ADD_PREP_TIME_BELL_TYPE_PERCENTAGE: Editable text = editText.getText(); bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_PROPORTIONAL); Double percentage = Double.parseDouble(text.toString()); double value = percentage / 100; bundle.putDouble(PrepTimeBellsManager.KEY_PROPORTION, value); break; } return bundle; }
From source file:com.villetainio.travelcardreminder.fragments.SettingsFragment.java
private void saveValues(View view) { SharedPreferences.Editor editor = cardStorage.edit(); // Enable notifications editor.putBoolean(getString(R.string.settings_enable_notifications), ((CheckBox) view.findViewById(R.id.enable_notifications)).isChecked()); // Days before NumberPicker numberPicker = (NumberPicker) view.findViewById(R.id.days_pick); editor.putInt(getString(R.string.settings_days), numberPicker.getValue()); // Time to start TimePicker timePicker = (TimePicker) view.findViewById(R.id.time_pick); editor.putInt(getString(R.string.settings_hours), timePicker.getCurrentHour()); editor.putInt(getString(R.string.settings_minutes), timePicker.getCurrentMinute()); editor.apply();/* w w w.ja va 2s .co m*/ }
From source file:com.flowzr.activity.DateFilterActivity.java
private void setDialogResult(Dialog d, Calendar c) { DatePicker dp = (DatePicker) d.findViewById(R.id.date); c.set(Calendar.YEAR, dp.getYear()); c.set(Calendar.MONTH, dp.getMonth()); c.set(Calendar.DAY_OF_MONTH, dp.getDayOfMonth()); TimePicker tp = (TimePicker) d.findViewById(R.id.time); c.set(Calendar.HOUR_OF_DAY, tp.getCurrentHour()); c.set(Calendar.MINUTE, tp.getCurrentMinute()); updateDate();/*from w w w. j a va2s . c o m*/ }
From source file:tmnt.wheresyourcar.ParkActivity.java
public void onClick(View view) { EditText text = (EditText) findViewById(R.id.license_plate); TimePicker num = (TimePicker) findViewById(R.id.num_pick); Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, num.getCurrentHour()); c.set(Calendar.MINUTE, num.getCurrentMinute()); Calendar c2 = Calendar.getInstance(); long minutes = TimeUnit.MILLISECONDS.toMinutes(c.getTimeInMillis() - c2.getTimeInMillis()); String carID = ""; if (text.getText().toString().isEmpty()) { carID = "Your Car!"; } else {/*from w w w.j a v a2 s . c om*/ carID = text.getText().toString(); } Parking parking = new Parking((int) minutes, carID, getLocation()); parkCar(parking); if (parking.getEnd_time() >= 5) { new SendToServer().execute(parking); } globals.tabState = 1; Intent map = new Intent(getApplicationContext(), MainActivity.class); startActivity(map); finish(); }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * Recording time ASYNCHRONOUSLY/* www.jav a2s .c om*/ * * @param v */ public void onClickRecord(View v) { LinearLayout llTimePicker = (LinearLayout) v.getParent(); LinearLayout lllFrag = (LinearLayout) llTimePicker.getParent(); LinearLayout llTime = (LinearLayout) llTimePicker.findViewById(R.id.llTimePicker); TimePicker tp = (TimePicker) llTime.findViewById(R.id.tpTask); Integer oiHour = tp.getCurrentHour(); Integer oiMin = tp.getCurrentMinute(); DateUtils du = new DateUtils(); long lmills = du.toMills(oiHour, oiMin); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckIn = new Date().getTime(); long lCheckOut = lCheckIn + lmills; // Save data into both databases Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_ASYNCHRONOUS); recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT) .show(); }
From source file:pro.jariz.reisplanner.fragments.PlannerFragment.java
public Bundle BuildBundle() { //create bundle from views to pass to select activity Bundle bundle = new Bundle(); AutoCompleteTextView auto = (AutoCompleteTextView) thisView.findViewById(R.id.AutoCompleteTextView1); AutoCompleteTextView auto2 = (AutoCompleteTextView) thisView.findViewById(R.id.AutoCompleteTextView2); AutoCompleteTextView auto3 = (AutoCompleteTextView) thisView.findViewById(R.id.AutoCompleteTextView3); CheckBox check = (CheckBox) thisView.findViewById(R.id.extraOptions); DatePicker picker = (DatePicker) thisView.findViewById(R.id.datePicker1); TimePicker time = (TimePicker) thisView.findViewById(R.id.timePicker1); bundle.putString("from", auto.getText().toString()); bundle.putString("via", auto2.getText().toString()); bundle.putString("to", auto3.getText().toString()); if (check.isChecked()) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); bundle.putString("date", format.format(new Date(picker.getYear(), picker.getMonth(), picker.getDayOfMonth(), time.getCurrentHour(), time.getCurrentMinute(), 0))); }//from w ww .j a v a2 s . c o m return bundle; }
From source file:de.androvdr.activities.ChannelsActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_WHATS_ON: final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.extendedchannels_whats_on); dialog.setTitle(R.string.channels_whats_on); final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); final DatePicker dp = (DatePicker) dialog.findViewById(R.id.channels_datePicker); final TimePicker tp = (TimePicker) dialog.findViewById(R.id.channels_timePicker); tp.setIs24HourView(DateFormat.is24HourFormat(getApplicationContext())); if (sp.contains("whats_on_hour")) { tp.setCurrentHour(sp.getInt("whats_on_hour", 0)); tp.setCurrentMinute(sp.getInt("whats_on_minute", 0)); }//from w w w . jav a2s. c om Button button = (Button) dialog.findViewById(R.id.channels_cancel); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); button = (Button) dialog.findViewById(R.id.channels_search); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Editor editor = sp.edit(); editor.putInt("whats_on_hour", tp.getCurrentHour()); editor.putInt("whats_on_minute", tp.getCurrentMinute()); editor.commit(); SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy hh:mm"); try { long time = df.parse(dp.getDayOfMonth() + "." + (dp.getMonth() + 1) + "." + dp.getYear() + " " + tp.getCurrentHour() + ":" + tp.getCurrentMinute()).getTime() / 1000; getController().whatsOn(time); } catch (ParseException e) { logger.error("Couldn't get date from pickers", e); } dialog.dismiss(); } }); return dialog; default: return super.onCreateDialog(id); } }