Example usage for android.app TimePickerDialog setTitle

List of usage examples for android.app TimePickerDialog setTitle

Introduction

In this page you can find the example usage for android.app TimePickerDialog setTitle.

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:org.libreoffice.impressremote.fragment.TimerSettingDialog.java

@Override
public Dialog onCreateDialog(Bundle aSavedInstanceState) {
    TimePickerDialog aDialog = new TimePickerDialog(getActivity(), this, INITIAL_HOUR, INITIAL_MINUTE,
            IS_24_HOUR_VIEW);/*  w ww  .  j ava2  s. c  o m*/

    aDialog.setTitle(R.string.title_timer);

    aDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_start), this);

    return aDialog;
}

From source file:it.feio.android.omninotes.utils.date.TimePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    Calendar cal = DateUtils.getCalendar(defaultTime);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    boolean is24HourMode = DateUtils.is24HourMode(mActivity);
    TimePickerDialog tpd = new TimePickerDialog(mActivity, R.style.Theme_AppCompat_Dialog_NoBackgroundOrDim,
            mListener, hour, minute, is24HourMode);
    tpd.setTitle("");
    return tpd;/*from   w  ww  . j ava2 s  .co m*/
}

From source file:org.libreoffice.impressremote.fragment.TimerEditingDialog.java

@Override
public Dialog onCreateDialog(Bundle aSavedInstanceState) {
    TimePickerDialog aDialog = new TimePickerDialog(getActivity(), this, getHours(mMinutes),
            getMinutes(mMinutes), IS_24_HOUR_VIEW);

    aDialog.setTitle(R.string.title_timer);

    aDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_save), this);
    aDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.button_remove), this);

    return aDialog;
}

From source file:com.dycody.android.idealnote.utils.date.TimePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    Calendar cal = DateUtils.getCalendar(defaultTime);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    boolean is24HourMode = DateUtils.is24HourMode(mActivity);
    TimePickerDialog tpd = new TimePickerDialog(mActivity,
            com.dycody.android.idealnote.R.style.Theme_AppCompat_Dialog_NoBackgroundOrDim, mListener, hour,
            minute, is24HourMode);//from www . j a v  a 2s. co  m
    tpd.setTitle("");
    return tpd;
}

From source file:pl.bcichecki.rms.client.android.activities.EditEventActivity.java

private void showEndsOnTimeDialog() {
    Calendar endTimeCalendar = Calendar.getInstance();
    endTimeCalendar.setTime(endDate);/*from   w  w w  .  j ava  2 s  .com*/

    boolean is24HourFormat = android.text.format.DateFormat.is24HourFormat(context);

    OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() {

        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            endDate = DateUtils.setHours(endDate, hourOfDay);
            endDate = DateUtils.setMinutes(endDate, minute);
            updateEndDateButtons();
        }
    };

    TimePickerDialog timePickerDialog = new TimePickerDialog(context, onTimeSetListener,
            endTimeCalendar.get(Calendar.HOUR_OF_DAY), endTimeCalendar.get(Calendar.MINUTE), is24HourFormat);
    timePickerDialog.setTitle(R.string.activity_edit_event_pick_end_time);
    timePickerDialog.show();
}

From source file:pl.bcichecki.rms.client.android.activities.EditEventActivity.java

private void showStartsOnTimeDialog() {
    Calendar startTimeCalendar = Calendar.getInstance();
    startTimeCalendar.setTime(startDate);

    boolean is24HourFormat = android.text.format.DateFormat.is24HourFormat(context);

    OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() {

        @Override/*from w w w .  j a v  a2  s .co m*/
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            long diff = endDate.getTime() - startDate.getTime();

            startDate = DateUtils.setHours(startDate, hourOfDay);
            startDate = DateUtils.setMinutes(startDate, minute);
            updateStartDateButtons();

            endDate.setTime(startDate.getTime() + diff);
            updateEndDateButtons();
        }
    };

    TimePickerDialog timePickerDialog = new TimePickerDialog(context, onTimeSetListener,
            startTimeCalendar.get(Calendar.HOUR_OF_DAY), startTimeCalendar.get(Calendar.MINUTE),
            is24HourFormat);
    timePickerDialog.setTitle(R.string.activity_edit_event_pick_start_time);
    timePickerDialog.show();

}

From source file:info.rynkowski.hamsterclient.ui.view.activity.FactFormActivity.java

@OnClick({ R.id.et_start_time, R.id.et_end_time })
public void onTimeClicked(final View view) {
    int hour, minutes;

    switch (view.getId()) {
    case R.id.et_start_time:
        hour = selectedStartTime.get(Calendar.HOUR_OF_DAY);
        minutes = selectedStartTime.get(Calendar.MINUTE);
        break;//from  ww w  .  j  a v a  2  s .c om
    case R.id.et_end_time:
        hour = selectedEndTime.get(Calendar.HOUR_OF_DAY);
        minutes = selectedEndTime.get(Calendar.MINUTE);
        break;
    default:
        throw new AssertionError("Unknown view id");
    }

    TimePickerDialog timePicker = new TimePickerDialog(FactFormActivity.this,
            (timePickerView, selectedHour, selectedMinutes) -> {
                switch (view.getId()) {
                case R.id.et_start_time:
                    selectedStartTime.set(Calendar.HOUR_OF_DAY, selectedHour);
                    selectedStartTime.set(Calendar.MINUTE, selectedMinutes);
                    editTextStartTime.setText(TimeConverter.toString(selectedStartTime, "HH:mm"));
                    break;
                case R.id.et_end_time:
                    selectedEndTime.set(Calendar.HOUR_OF_DAY, selectedHour);
                    selectedEndTime.set(Calendar.MINUTE, selectedMinutes);
                    editTextEndTime.setText(TimeConverter.toString(selectedEndTime, "HH:mm"));
                    break;
                }
            }, hour, minutes, true);

    timePicker.setTitle("Select Time");
    timePicker.show();
}

From source file:za.co.neilson.alarm.preferences.AlarmPreferencesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    setContentView(R.layout.alarm_preferences);

    pref = getSharedPreferences("AppPref", MODE_PRIVATE);
    email = getIntent().getStringExtra("email");
    Log.d("? ???!!! ", "" + email);

    Bundle bundle = getIntent().getExtras();
    if (bundle != null && bundle.containsKey("alarm")) {
        setMathAlarm((Alarm) bundle.getSerializable("alarm"));
    } else {/* ww w. j  av  a2s .c  om*/
        setMathAlarm(new Alarm());
    }
    if (bundle != null && bundle.containsKey("adapter")) {
        setListAdapter((AlarmPreferenceListAdapter) bundle.getSerializable("adapter"));
    } else {
        setListAdapter(new AlarmPreferenceListAdapter(this, getMathAlarm()));
    }

    getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> l, View v, int position, long id) {
            final AlarmPreferenceListAdapter alarmPreferenceListAdapter = (AlarmPreferenceListAdapter) getListAdapter();
            final AlarmPreference alarmPreference = (AlarmPreference) alarmPreferenceListAdapter
                    .getItem(position);

            AlertDialog.Builder alert;
            v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
            switch (alarmPreference.getType()) {
            case BOOLEAN:
                CheckedTextView checkedTextView = (CheckedTextView) v;
                boolean checked = !checkedTextView.isChecked();
                ((CheckedTextView) v).setChecked(checked);
                switch (alarmPreference.getKey()) {
                case ALARM_ACTIVE:
                    alarm.setAlarmActive(checked);
                    break;
                case ALARM_VIBRATE:
                    alarm.setVibrate(checked);
                    if (checked) {
                        Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
                        vibrator.vibrate(1000);
                    }
                    break;
                }
                alarmPreference.setValue(checked);
                break;
            case STRING:

                alert = new AlertDialog.Builder(AlarmPreferencesActivity.this);

                alert.setTitle(alarmPreference.getTitle());
                // alert.setMessage(message);

                // Set an EditText view to get user input
                final EditText input = new EditText(AlarmPreferencesActivity.this);

                input.setText(alarmPreference.getValue().toString());

                alert.setView(input);
                alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                        alarmPreference.setValue(input.getText().toString());

                        if (alarmPreference.getKey() == Key.ALARM_NAME) {
                            alarm.setAlarmName(alarmPreference.getValue().toString());
                        }

                        alarmPreferenceListAdapter.setMathAlarm(getMathAlarm());
                        alarmPreferenceListAdapter.notifyDataSetChanged();
                    }
                });
                alert.show();
                break;
            case LIST:
                alert = new AlertDialog.Builder(AlarmPreferencesActivity.this);

                alert.setTitle(alarmPreference.getTitle());
                // alert.setMessage(message);

                CharSequence[] items = new CharSequence[alarmPreference.getOptions().length];
                for (int i = 0; i < items.length; i++)
                    items[i] = alarmPreference.getOptions()[i];

                alert.setItems(items, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (alarmPreference.getKey()) {
                        case ALARM_DIFFICULTY:
                            Alarm.Difficulty d = Alarm.Difficulty.values()[which];
                            alarm.setDifficulty(d);
                            break;
                        case ALARM_TONE:
                            alarm.setAlarmTonePath(alarmPreferenceListAdapter.getAlarmTonePaths()[which]);
                            if (alarm.getAlarmTonePath() != null) {
                                if (mediaPlayer == null) {
                                    mediaPlayer = new MediaPlayer();
                                } else {
                                    if (mediaPlayer.isPlaying())
                                        mediaPlayer.stop();
                                    mediaPlayer.reset();
                                }
                                try {
                                    // mediaPlayer.setVolume(1.0f, 1.0f);
                                    mediaPlayer.setVolume(0.2f, 0.2f);
                                    mediaPlayer.setDataSource(AlarmPreferencesActivity.this,
                                            Uri.parse(alarm.getAlarmTonePath()));
                                    mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
                                    mediaPlayer.setLooping(false);
                                    mediaPlayer.prepare();
                                    mediaPlayer.start();

                                    // Force the mediaPlayer to stop after 3
                                    // seconds...
                                    if (alarmToneTimer != null)
                                        alarmToneTimer.cancel();
                                    alarmToneTimer = new CountDownTimer(3000, 3000) {
                                        @Override
                                        public void onTick(long millisUntilFinished) {

                                        }

                                        @Override
                                        public void onFinish() {
                                            try {
                                                if (mediaPlayer.isPlaying())
                                                    mediaPlayer.stop();
                                            } catch (Exception e) {

                                            }
                                        }
                                    };
                                    alarmToneTimer.start();
                                } catch (Exception e) {
                                    try {
                                        if (mediaPlayer.isPlaying())
                                            mediaPlayer.stop();
                                    } catch (Exception e2) {

                                    }
                                }
                            }
                            break;
                        default:
                            break;
                        }
                        alarmPreferenceListAdapter.setMathAlarm(getMathAlarm());
                        alarmPreferenceListAdapter.notifyDataSetChanged();
                    }

                });

                alert.show();
                break;
            case MULTIPLE_LIST:
                alert = new AlertDialog.Builder(AlarmPreferencesActivity.this);

                alert.setTitle(alarmPreference.getTitle());
                // alert.setMessage(message);

                CharSequence[] multiListItems = new CharSequence[alarmPreference.getOptions().length];
                for (int i = 0; i < multiListItems.length; i++)
                    multiListItems[i] = alarmPreference.getOptions()[i];

                boolean[] checkedItems = new boolean[multiListItems.length];
                for (Alarm.Day day : getMathAlarm().getDays()) {
                    checkedItems[day.ordinal()] = true;
                }
                alert.setMultiChoiceItems(multiListItems, checkedItems, new OnMultiChoiceClickListener() {

                    @Override
                    public void onClick(final DialogInterface dialog, int which, boolean isChecked) {

                        Alarm.Day thisDay = Alarm.Day.values()[which];

                        if (isChecked) {
                            alarm.addDay(thisDay);
                        } else {
                            // Only remove the day if there are more than 1
                            // selected
                            if (alarm.getDays().length > 1) {
                                alarm.removeDay(thisDay);
                            } else {
                                // If the last day was unchecked, re-check
                                // it
                                ((AlertDialog) dialog).getListView().setItemChecked(which, true);
                            }
                        }

                    }
                });
                alert.setOnCancelListener(new OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        alarmPreferenceListAdapter.setMathAlarm(getMathAlarm());
                        alarmPreferenceListAdapter.notifyDataSetChanged();

                    }
                });
                alert.show();
                break;
            case TIME:
                TimePickerDialog timePickerDialog = new TimePickerDialog(AlarmPreferencesActivity.this,
                        new OnTimeSetListener() {

                            @Override
                            public void onTimeSet(TimePicker timePicker, int hours, int minutes) {
                                Calendar newAlarmTime = Calendar.getInstance();
                                newAlarmTime.set(Calendar.HOUR_OF_DAY, hours);
                                newAlarmTime.set(Calendar.MINUTE, minutes);
                                newAlarmTime.set(Calendar.SECOND, 0);
                                alarm.setAlarmTime(newAlarmTime);
                                alarmPreferenceListAdapter.setMathAlarm(getMathAlarm());
                                alarmPreferenceListAdapter.notifyDataSetChanged();
                            }
                        }, alarm.getAlarmTime().get(Calendar.HOUR_OF_DAY),
                        alarm.getAlarmTime().get(Calendar.MINUTE), true);
                timePickerDialog.setTitle(alarmPreference.getTitle());
                timePickerDialog.show();
            default:
                break;
            }
        }
    });
}

From source file:com.karmick.android.citizenalert.alarm.AlarmAddActivity.java

protected void eventCalls() {
    alarm_add.setOnClickListener(new OnClickListener() {

        @Override//from  w ww.ja  va 2  s . c  om
        public void onClick(View v) {

            validateAndSaveAlarm();
        }
    });

    alarm_contacts_add.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent nint = new Intent(AlarmAddActivity.this, ContactListActivity.class);
            nint.putExtra("for_result", true);
            startActivityForResult(nint, GETCONTACTS);

        }
    });

    alarm_time.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TimePickerDialog timePickerDialog = new TimePickerDialog(AlarmAddActivity.this,
                    new OnTimeSetListener() {

                        @Override
                        public void onTimeSet(TimePicker timePicker, int hours, int minutes) {
                            newAlarmTime.set(Calendar.HOUR_OF_DAY, hours);
                            newAlarmTime.set(Calendar.MINUTE, minutes);
                            newAlarmTime.set(Calendar.SECOND, 0);

                            newAlarmTime2.set(Calendar.HOUR_OF_DAY, hours);
                            newAlarmTime2.set(Calendar.MINUTE, minutes);
                            newAlarmTime2.set(Calendar.SECOND, 0);

                            newAlarmTime3.set(Calendar.HOUR_OF_DAY, hours);
                            newAlarmTime3.set(Calendar.MINUTE, minutes);
                            newAlarmTime3.set(Calendar.SECOND, 0);

                            alarm_time.setText(getAlarmTimeAsString(newAlarmTime));

                        }
                    }, alarm.getAlarmTime().get(Calendar.HOUR_OF_DAY),
                    alarm.getAlarmTime().get(Calendar.MINUTE), true);
            timePickerDialog.setTitle("SetTime");
            timePickerDialog.show();
        }
    });
}

From source file:com.bigpigs.fragments.SearchFragment.java

@Override
public void onClick(View v) {
    int id = v.getId();
    switch (id) {
    case R.id.bt_clear: {
        for (Polyline line : polylines) {
            line.remove();//from   w  ww  .j a  v  a 2 s .c  o m
        }
        polylines.clear();
        map.clear();

        Log.d("size", polylines.size() + "");

        reDrawMarker();
        bt_clear.setVisibility(View.GONE);
    }
    case R.id.bt_currentLocation: {
        double lat = Double.parseDouble(
                getContext().getSharedPreferences("data", Context.MODE_PRIVATE).getString("lat", "0.0"));
        double lng = Double.parseDouble(
                getContext().getSharedPreferences("data", Context.MODE_PRIVATE).getString("lng", "0.0"));
        Log.d("latlng", lat + ":" + lng);
        currentLatLng = new LatLng(lat, lng);
        if (lat != 0.0 && lng != 0.0) {
            Utils.moveCamera(new LatLng(lat, lng), "Bn ang  y", 13, map);
        }
        break;
    }
    case R.id.tv_time: {
        mHour = 0;
        mMinute = 0;
        TimePickerDialog dialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
            @Override
            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                mHour = hourOfDay;
                mMinute = minute;
                sHour = mHour + "";
                sMinute = mMinute + "";
                if (mHour < 10 && mMinute < 10) {
                    tv_time.setText("0" + mHour + ":" + "0" + mMinute);
                }
                if (mHour < 10 && mMinute > 10) {
                    tv_time.setText("0" + mHour + ":" + "" + mMinute);
                }
                if (mHour > 10 && mMinute < 10) {
                    tv_time.setText("" + mHour + ":" + "0" + mMinute);
                }
                currentTime = tv_time.getText().toString();
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("day",
                        Calendar.getInstance().get(Calendar.YEAR) + "-"
                                + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-"
                                + Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
                map.put("time_start", currentTime);
                map.put("textlocation", search_box.getSelectedItem().toString());

                new SearchSystemPitch(map).execute();
            }
        }, 7, 00, true);
        dialog.setTitle("Ch?n gi? bt u bn mun");
        dialog.show();
        break;
    }
    //            case R.id.bt_search :
    //            {
    //                map.clear();
    //                map.addMarker(new MarkerOptions().position(currentLatLng).title("Bn  y"));
    //                dateofweek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
    //                HashMap<String,String> body = new HashMap<>();
    //                body.put("time_start",tv_time.getText().toString()+":00");
    //                body.put("day", "2017-01-01");
    //                body.put("textlocation",search_box.getSelectedItem().toString());
    //                new SearchSystemPitch(body);
    //                break;
    //
    //
    //            }
    }
}