Example usage for android.widget TimePicker getCurrentMinute

List of usage examples for android.widget TimePicker getCurrentMinute

Introduction

In this page you can find the example usage for android.widget TimePicker getCurrentMinute.

Prototype

@NonNull
@Deprecated
public Integer getCurrentMinute() 

Source Link

Usage

From source file:Main.java

/**
 * @param timePicker/*from  www  . j a  va 2 s . c  om*/
 * @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//from  w  w  w .  j a  va2s  .c om
 * 
 * @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/*from www  .j  a v  a2 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 .j a v  a 2  s  . com
}

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();/*www  . j a va2 s. 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 {// w  ww.j  a v a2s  . co  m
        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/*from   w  w  w  .j  ava2 s. com*/
 * 
 * @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)));
    }/*w  w  w  .ja  v  a  2 s. c o  m*/

    return bundle;
}

From source file:net.reichholf.dreamdroid.activities.TimerEditActivity.java

/**
 * @param dialog//from ww  w .j a  v a 2  s  .  c o m
 *            The dialog containing the date and the time picker
 * @return <code>Calendar</code> container set to the date and time of the
 *         Date- and TimePicker
 */
private Calendar getCalendarFromPicker(final Dialog dialog) {
    Calendar cal = GregorianCalendar.getInstance();
    DatePicker dp = (DatePicker) dialog.findViewById(R.id.DatePicker);
    TimePicker tp = (TimePicker) dialog.findViewById(R.id.TimePicker);

    cal.set(Calendar.YEAR, dp.getYear());
    cal.set(Calendar.MONTH, dp.getMonth());
    cal.set(Calendar.DAY_OF_MONTH, dp.getDayOfMonth());
    cal.set(Calendar.HOUR_OF_DAY, tp.getCurrentHour());
    cal.set(Calendar.MINUTE, tp.getCurrentMinute());
    cal.set(Calendar.SECOND, 0);

    return cal;
}