Search in sources :

Example 36 with TimePickerDialog

use of android.app.TimePickerDialog in project UniPool by divya21raj.

the class NewEntryDialog method openTimePickerDialog.

private void openTimePickerDialog(boolean is24r) {
    Calendar calendar = Calendar.getInstance();
    timePickerDialog = new TimePickerDialog(getActivity(), onTimeSetListener, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), is24r);
    timePickerDialog.setTitle("Choose Time");
    timePickerDialog.show();
}
Also used : Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog)

Example 37 with TimePickerDialog

use of android.app.TimePickerDialog in project HAR-Android by linw7.

the class RemindPhoneActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_remind_phone);
    set_start = (CircularProgressButton) findViewById(R.id.set_start);
    time = (TextView) findViewById(R.id.time);
    activity = (TextView) findViewById(R.id.activity);
    progressView = (CircularProgressView) findViewById(R.id.progress_view);
    energy_step = (TextView) findViewById(R.id.energy_step);
    distance_step = (TextView) findViewById(R.id.distance_step);
    time_start = (TextView) findViewById(R.id.time_start);
    time_end = (TextView) findViewById(R.id.time_end);
    acc_sensor = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    sensor_type = Sensor.TYPE_ACCELEROMETER;
    acc_sensor.registerListener(acc_listener, acc_sensor.getDefaultSensor(sensor_type), SensorManager.SENSOR_DELAY_FASTEST);
    set_start.setIndeterminateProgressMode(true);
    activity.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            for (int i = 0; i < check.length; i++) check[i] = false;
            AlertDialog dialog = new AlertDialog.Builder(RemindPhoneActivity.this).setTitle("请选择监控行为").setIcon(R.drawable.logo_activity).setNegativeButton("取消", null).setPositiveButton("确定", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String str = set_activity();
                    choice_activity = 1;
                }
            }).setMultiChoiceItems(ACTIVITY, null, new DialogInterface.OnMultiChoiceClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                    check[which] = true;
                }
            }).create();
            dialog.show();
        }
    });
    time.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            TimePickerDialog timePickerDialog = new TimePickerDialog(RemindPhoneActivity.this, new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker view, int h, int m) {
                    hour = h;
                    minute = m;
                    // 此处为test
                    second = 10;
                    // second = h * 3600 + m * 60;
                    String time_length = "" + (h * 60 + minute);
                    choice_time = 1;
                }
            }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true);
            timePickerDialog.show();
        }
    });
    set_start.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            tag = 1;
            retag = 1;
            set_start.setProgress(60);
            progressView.startAnimation();
            if ((choice_time == 1) && (choice_activity == 1) && has_set()) {
                for (int i = 0; i < 6; i++) {
                    if (check[i] == true) {
                        set_time[i] = second;
                        Log.i("" + ACTIVITY[i], "" + set_time[i]);
                    }
                }
                alter_ok();
            } else
                alter_no(choice_time, choice_activity);
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) TimePicker(android.widget.TimePicker) DialogInterface(android.content.DialogInterface) Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog) CircularProgressView(com.github.rahatarmanahmed.cpv.CircularProgressView) View(android.view.View) TextView(android.widget.TextView)

Example 38 with TimePickerDialog

use of android.app.TimePickerDialog in project android_frameworks_base by DirtyUnicorns.

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);
}
Also used : Button(android.widget.Button) FrameLayout(android.widget.FrameLayout) TimePickerDialog(android.app.TimePickerDialog) View(android.view.View)

Example 39 with TimePickerDialog

use of android.app.TimePickerDialog in project android-app-common-tasks by multidots.

the class Common method showTimePickerDialog.

/**
     * show timepicker
     *
     * @param mContext
     * @param mTextView formar of the time
     * @return show timepicker
     */
public static void showTimePickerDialog(final Context mContext, final TextView mTextView) {
    new TimePickerDialog(mContext, new OnTimeSetListener() {

        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            SimpleDateFormat timeFormatter = new SimpleDateFormat("hh:mm a");
            dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
            dateTime.set(Calendar.MINUTE, minute);
            mTextView.setText(timeFormatter.format(dateTime.getTime()));
        }
    }, dateTime.get(Calendar.HOUR_OF_DAY), dateTime.get(Calendar.MINUTE), false).show();
}
Also used : TimePicker(android.widget.TimePicker) OnTimeSetListener(android.app.TimePickerDialog.OnTimeSetListener) TimePickerDialog(android.app.TimePickerDialog) SimpleDateFormat(java.text.SimpleDateFormat)

Example 40 with TimePickerDialog

use of android.app.TimePickerDialog in project AntennaPod by AntennaPod.

the class PreferenceController method showUpdateIntervalTimePreferencesDialog.

// UPDATE TIME/INTERVAL DIALOG
private void showUpdateIntervalTimePreferencesDialog() {
    final Context context = ui.getActivity();
    MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
    builder.title(R.string.pref_autoUpdateIntervallOrTime_title);
    builder.content(R.string.pref_autoUpdateIntervallOrTime_message);
    builder.positiveText(R.string.pref_autoUpdateIntervallOrTime_Interval);
    builder.negativeText(R.string.pref_autoUpdateIntervallOrTime_TimeOfDay);
    builder.neutralText(R.string.pref_autoUpdateIntervallOrTime_Disable);
    builder.onPositive((dialog, which) -> {
        AlertDialog.Builder builder1 = new AlertDialog.Builder(context);
        builder1.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_Interval));
        final String[] values = context.getResources().getStringArray(R.array.update_intervall_values);
        final String[] entries = getUpdateIntervalEntries(values);
        long currInterval = UserPreferences.getUpdateInterval();
        int checkedItem = -1;
        if (currInterval > 0) {
            String currIntervalStr = String.valueOf(TimeUnit.MILLISECONDS.toHours(currInterval));
            checkedItem = ArrayUtils.indexOf(values, currIntervalStr);
        }
        builder1.setSingleChoiceItems(entries, checkedItem, (dialog1, which1) -> {
            int hours = Integer.parseInt(values[which1]);
            UserPreferences.setUpdateInterval(hours);
            dialog1.dismiss();
            setUpdateIntervalText();
        });
        builder1.setNegativeButton(context.getString(R.string.cancel_label), null);
        builder1.show();
    });
    builder.onNegative((dialog, which) -> {
        int hourOfDay = 7, minute = 0;
        int[] updateTime = UserPreferences.getUpdateTimeOfDay();
        if (updateTime.length == 2) {
            hourOfDay = updateTime[0];
            minute = updateTime[1];
        }
        TimePickerDialog timePickerDialog = new TimePickerDialog(context, (view, selectedHourOfDay, selectedMinute) -> {
            if (view.getTag() == null) {
                // onTimeSet() may get called twice!
                view.setTag("TAGGED");
                UserPreferences.setUpdateTimeOfDay(selectedHourOfDay, selectedMinute);
                setUpdateIntervalText();
            }
        }, hourOfDay, minute, DateFormat.is24HourFormat(context));
        timePickerDialog.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_TimeOfDay));
        timePickerDialog.show();
    });
    builder.onNeutral((dialog, which) -> {
        UserPreferences.setUpdateInterval(0);
        setUpdateIntervalText();
    });
    builder.show();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) TimePickerDialog(android.app.TimePickerDialog) SuppressLint(android.annotation.SuppressLint)

Aggregations

TimePickerDialog (android.app.TimePickerDialog)64 TimePicker (android.widget.TimePicker)27 Calendar (java.util.Calendar)25 View (android.view.View)20 DatePickerDialog (android.app.DatePickerDialog)15 TextView (android.widget.TextView)14 Context (android.content.Context)11 DialogInterface (android.content.DialogInterface)11 AlertDialog (android.app.AlertDialog)9 Button (android.widget.Button)8 CompoundButton (android.widget.CompoundButton)7 Bundle (android.os.Bundle)6 DatePicker (android.widget.DatePicker)6 LocalTime (java.time.LocalTime)6 FrameLayout (android.widget.FrameLayout)5 SuppressLint (android.annotation.SuppressLint)4 Intent (android.content.Intent)4 LinearLayout (android.widget.LinearLayout)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Date (java.util.Date)4