Search in sources :

Example 6 with TimePicker

use of android.widget.TimePicker in project cw-omnibus by commonsguy.

the class TimePickerDemoActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TimePicker picker = (TimePicker) findViewById(R.id.picker);
    picker.setOnTimeChangedListener(this);
}
Also used : TimePicker(android.widget.TimePicker)

Example 7 with TimePicker

use of android.widget.TimePicker in project Conversations by siacs.

the class TimePreference method onCreateDialogView.

@Override
protected View onCreateDialogView() {
    picker = new TimePicker(getContext());
    picker.setIs24HourView(android.text.format.DateFormat.is24HourFormat(getContext()));
    return picker;
}
Also used : TimePicker(android.widget.TimePicker)

Example 8 with TimePicker

use of android.widget.TimePicker in project WordPress-Android by wordpress-mobile.

the class EditPostSettingsFragment method showPostTimeSelectionDialog.

private void showPostTimeSelectionDialog() {
    final TimePicker timePicker = new TimePicker(getActivity());
    timePicker.setIs24HourView(DateFormat.is24HourFormat(getActivity()));
    timePicker.setCurrentHour(mHour);
    timePicker.setCurrentMinute(mMinute);
    new AlertDialog.Builder(getActivity()).setTitle(R.string.select_time).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mHour = timePicker.getCurrentHour();
            mMinute = timePicker.getCurrentMinute();
            Date javaDate = new Date(mYear - 1900, mMonth, mDay, mHour, mMinute);
            long javaTimestamp = javaDate.getTime();
            try {
                int flags = 0;
                flags |= DateUtils.FORMAT_SHOW_DATE;
                flags |= DateUtils.FORMAT_ABBREV_MONTH;
                flags |= DateUtils.FORMAT_SHOW_YEAR;
                flags |= DateUtils.FORMAT_SHOW_TIME;
                String formattedDate = DateUtils.formatDateTime(getActivity(), javaTimestamp, flags);
                mCustomPubDate = DateTimeUtils.iso8601FromDate(javaDate);
                mPubDateText.setText(formattedDate);
                mIsCustomPubDate = true;
                updatePostSettingsAndSaveButton();
            } catch (RuntimeException e) {
                AppLog.e(T.POSTS, e);
            }
        }
    }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    }).setView(timePicker).show();
}
Also used : AlertDialog(android.app.AlertDialog) TimePicker(android.widget.TimePicker) DialogInterface(android.content.DialogInterface) Date(java.util.Date)

Example 9 with TimePicker

use of android.widget.TimePicker 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 10 with TimePicker

use of android.widget.TimePicker in project IITB-App by wncc.

the class AddEventFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    container.removeAllViews();
    view = inflater.inflate(R.layout.fragment_add_event, container, false);
    ButterKnife.bind(this, view);
    eventPictureImageView = view.findViewById(R.id.ib_eventImage);
    progressDialog = new ProgressDialog(getContext());
    cb_permission.setVisibility(View.GONE);
    cb_public.setVisibility(View.GONE);
    et_mapLocation.setVisibility(View.GONE);
    close.setVisibility(View.GONE);
    open.setVisibility(View.VISIBLE);
    start.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            int mYear = calendar.get(Calendar.YEAR);
            int mMonth = calendar.get(Calendar.MONTH);
            int mDay = calendar.get(Calendar.DAY_OF_MONTH);
            final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
            final int mMin = calendar.get(Calendar.MINUTE);
            long millis = calendar.getTimeInMillis();
            DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
                    TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {

                        @Override
                        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                            start.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
                        }
                    }, mHour, mMin, true);
                    timePickerDialog.show();
                }
            }, mYear, mMonth, mDay);
            datePickerDialog.show();
            timestamp_start = new Timestamp(millis);
        }
    });
    end.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            int mYear = calendar.get(Calendar.YEAR);
            int mMonth = calendar.get(Calendar.MONTH);
            int mDay = calendar.get(Calendar.DAY_OF_MONTH);
            final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
            final int mMin = calendar.get(Calendar.MINUTE);
            long millis = calendar.getTimeInMillis();
            DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
                    TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {

                        @Override
                        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                            end.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
                        }
                    }, mHour, mMin, true);
                    timePickerDialog.show();
                }
            }, mYear, mMonth, mDay);
            datePickerDialog.show();
            timestamp_end = new Timestamp(millis);
        }
    });
    if (cb_permission.isChecked()) {
        publicStatus = 1;
    } else
        publicStatus = 0;
    advancedMenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (cb_public.getVisibility() == View.VISIBLE) {
                open.setVisibility(View.VISIBLE);
                close.setVisibility(View.GONE);
                cb_permission.setVisibility(View.GONE);
                cb_public.setVisibility(View.GONE);
                et_mapLocation.setVisibility(View.GONE);
            } else {
                close.setVisibility(View.VISIBLE);
                open.setVisibility(View.GONE);
                cb_permission.setVisibility(View.VISIBLE);
                cb_public.setVisibility(View.VISIBLE);
                et_mapLocation.setVisibility(View.VISIBLE);
            }
        }
    });
    imageButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                // Permission is not granted
                ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
                return;
            }
            Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(i, RESULT_LOAD_IMAGE);
        }
    });
    createEvent.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            progressDialog.setIndeterminate(true);
            progressDialog.setCancelable(false);
            progressDialog.show();
            sendImage();
        }
    });
    return view;
}
Also used : TimePicker(android.widget.TimePicker) DatePickerDialog(android.app.DatePickerDialog) Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog) Intent(android.content.Intent) ProgressDialog(android.app.ProgressDialog) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) Timestamp(java.sql.Timestamp) DatePicker(android.widget.DatePicker)

Aggregations

TimePicker (android.widget.TimePicker)10 TimePickerDialog (android.app.TimePickerDialog)4 DialogInterface (android.content.DialogInterface)2 Calendar (java.util.Calendar)2 AlertDialog (android.app.AlertDialog)1 DatePickerDialog (android.app.DatePickerDialog)1 ProgressDialog (android.app.ProgressDialog)1 OnTimeSetListener (android.app.TimePickerDialog.OnTimeSetListener)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ConstraintLayout (android.support.constraint.ConstraintLayout)1 View (android.view.View)1 DatePicker (android.widget.DatePicker)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 OnClick (butterknife.OnClick)1 NightDisplayController (com.android.internal.app.NightDisplayController)1 Timestamp (java.sql.Timestamp)1 SimpleDateFormat (java.text.SimpleDateFormat)1