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);
}
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;
}
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();
}
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();
}
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;
}
Aggregations