Java Code Examples for android.widget.DatePicker

The following are top voted examples for showing how to use android.widget.DatePicker. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: godlibrary   File: DialogDate.java   Source Code and License 7 votes vote down vote up
public AlertDialog show(Context context) {
    dialog = new AlertDialog.Builder(context).create();
    dialog.show();
    Window window = dialog.getWindow();
    window.setContentView(R.layout.dialog_date_time);
    window.setGravity(Gravity.CENTER);// 此处可以设置dialog显示的位置
    //window.setWindowAnimations(R.style.in_left_out_right_style);
    window.setBackgroundDrawableResource(R.color.transparent);

    datePicker = (DatePicker) window
            .findViewById(R.id.date_time_datePicker1);
    datePicker.setCalendarViewShown(false);
    timePicker = (TimePicker) window.findViewById(R.id.date_time_timePicker);
    but_ok = (Button) window.findViewById(R.id.date_time_but_ok);
    but_ok.setOnClickListener(this);
    return dialog;
}
 
Example 2
Project: android-AutofillFramework   File: CreditCardExpirationDatePickerView.java   Source Code and License 7 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DatePickerDialog dialog = new DatePickerDialog(getActivity(),
            R.style.CustomDatePickerDialogTheme, this, mParent.mYear, mParent.mMonth, 1);

    DatePicker datePicker = dialog.getDatePicker();

    // Limit range.
    Calendar c = mParent.getCalendar();
    datePicker.setMinDate(c.getTimeInMillis());
    c.set(Calendar.YEAR, mParent.mYear + CC_EXP_YEARS_COUNT - 1);
    datePicker.setMaxDate(c.getTimeInMillis());

    // Remove day.
    datePicker.findViewById(getResources().getIdentifier("day", "id", "android"))
            .setVisibility(View.GONE);
    return dialog;
}
 
Example 3
Project: Crammer-HITN17   File: SelectDate.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_select_date);
    datePicker = (DatePicker) findViewById(R.id.datePicker);
    date = datePicker.getDayOfMonth();
    month = datePicker.getMonth() +1 ;
    year = datePicker.getYear();
    Log.d("date",date+" "+month+" "+year);
    next = (Button) findViewById(R.id.next);
    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            date = datePicker.getDayOfMonth();
            month = datePicker.getMonth() + 1;
            year = datePicker.getYear();
            Log.d("date",date+" "+month+" "+year);

            Intent i = new Intent(getApplicationContext(),Message.class);
            startActivity(i);
        }
    });


}
 
Example 4
Project: ChenYan   File: MyInfoActivity.java   Source Code and License 6 votes vote down vote up
private void showDateDialog(final TextView textView) {
    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    DatePickerDialog dialog =
            new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
                    //      birthday = new Date(i,i1,i2);
                    Date date = new Date(i - 1900, i1, i2);

                    textView.setText(formatDate(date));
                }
            }, year, month, day);
    dialog.show();

}
 
Example 5
Project: CIA   File: CreateHabitEventActivity.java   Source Code and License 6 votes vote down vote up
/** for the date selected
 * @param datePicker : the widget object for selecting a date
 * @param year : the year chosen
 * @param month : the month chosen
 * @param day : the day chosen
 * see: DatePickerFragment
 */
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
    final Calendar calendar = Calendar.getInstance();

    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.DAY_OF_MONTH, day);

    Date date = calendar.getTime();
    Date currentDate = new Date();

    // Prevent the event's date from being a date in the future
    if (currentDate.before(date))
        date = currentDate;

    eventDate = date;
    setDateText();
}
 
Example 6
Project: Cash   File: frmManutencaoCompraPagamentos.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.frm_manutencao_compra_pagamentos);

    mOperacao = getIntent().getExtras().getString("Operacao");
    iCompra = getIntent().getExtras().getInt("Compra");

    if (mOperacao.matches("I"))
        setTitle(getString(R.string.i_026));

    if (mOperacao.matches("A")) {
        setTitle(getString(R.string.a_012));
    }

    edtDtPagamento = (EditText) findViewById(R.id.edtPagamento);
    edtValor = (EditText) findViewById(R.id.edtValor);
    edtObservacoes = (EditText) findViewById(R.id.edtObservacoes);

    edtDtPagamento.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            int iAno = Calendar.getInstance().get(Calendar.YEAR);
            int iMes = Calendar.getInstance().get(Calendar.MONTH);
            int iDia = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);

            if (edtDtPagamento.getText().toString().trim().length() != 0) {
                iDia = Integer.valueOf(edtDtPagamento.getText().toString().split("\\/")[0]);
                iMes = Integer.valueOf(edtDtPagamento.getText().toString().split("\\/")[1]) - 1;
                iAno = Integer.valueOf(edtDtPagamento.getText().toString().split("\\/")[2]);
            }

            DatePickerDialog datePickerDialog = new DatePickerDialog(frmManutencaoCompraPagamentos.this, new DatePickerDialog.OnDateSetListener() {
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    Calendar newDate = Calendar.getInstance();
                    newDate.set(year, monthOfYear, dayOfMonth);
                    edtDtPagamento.setText(Funcoes.dateFormat.format(newDate.getTime()));
                }
            }, iAno, iMes, iDia);

            datePickerDialog.show();
        }
    });

    leitura();
}
 
Example 7
Project: OpenHomeAnalysis   File: OhaEnergyUseBillFragment.java   Source Code and License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_energy_use_bill, container, false);
    this.radioButtonFromDate = (RadioButton) view.findViewById(R.id.radioButtonFromDate);
    this.radioButtonToDate = (RadioButton) view.findViewById(R.id.radioButtonToDate);
    this.editKwhCost = (EditText) view.findViewById(R.id.editKwhCost);
    this.datePicker = (DatePicker) view.findViewById(R.id.datePicker);
    this.toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    this.setTextRadioButtonDate(radioButtonFromDate, this.fromDate);
    this.setTextRadioButtonDate(radioButtonToDate, this.toDate);
    this.setCalendarView();
    this.editKwhCost.setText(OhaHelper.getEditable(this.kwhCost));
    this.radioButtonFromDate.setOnClickListener(this);
    this.radioButtonToDate.setOnClickListener(this);
    this.datePicker.setOnClickListener(this);
    //Remover o date_picker_header do datePicker se o mesmo existir
    View viewDayDatePicker = datePicker.findViewById(Resources.getSystem().getIdentifier("date_picker_header", "id", "android"));
    if (viewDayDatePicker != null) {
        viewDayDatePicker.setVisibility(View.GONE);
    }
    this.toolbar.inflateMenu(R.menu.fragment_energy_use_bill);
    this.toolbar.setOnMenuItemClickListener(this);
    return view;
}
 
Example 8
Project: react-native-double-date-picker   File: DoubleDatePickerDialog.java   Source Code and License 6 votes vote down vote up
/**
 * 隐藏DatePicker中的日期显示
 *
 * @param mDatePicker
 */
private void hidDay(DatePicker mDatePicker) {
    Field[] datePickerfFields = mDatePicker.getClass().getDeclaredFields();
    for (Field datePickerField : datePickerfFields) {
        if ("mDaySpinner".equals(datePickerField.getName())) {
            datePickerField.setAccessible(true);
            Object dayPicker = new Object();
            try {
                dayPicker = datePickerField.get(mDatePicker);
            } catch (Exception e) {
                mPromise.reject("-1", e);
            }
            ((View) dayPicker).setVisibility(View.GONE);
        }
    }
}
 
Example 9
Project: JKCloud   File: DateUtil.java   Source Code and License 6 votes vote down vote up
/**
 * 显示时间窗口
 *
 * @param textView
 */
public static void DateDialog(final Context mContext, final TextView textView) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    View v = inflater.inflate(R.layout.date_picker, null);
    final DatePicker dataPicker = (DatePicker) v.findViewById(R.id.datePicker);
    Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);
    dataPicker.init(mYear, mMonth, mDay, (datePicker, year, month, day) -> {
        mYear = year;
        mMonth = month;
        mDay = day;
    });

    new MaterialDialog.Builder(mContext)
            .customView(v, false)
            .positiveText(android.R.string.ok)
            .negativeText(android.R.string.cancel)
            .onPositive((dialog, which) -> {
                textView.setText(mYear + "-" + (mMonth + 1) + "-" + mDay);
            }).show();
}
 
Example 10
Project: Sanxing   File: OperateTimeLeftActivityBase.java   Source Code and License 6 votes vote down vote up
@OnClick(R.id.time_left_from_date_content)
void timeLeftStartDateOnClickBehavior() {
    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            startCalendar.set(Calendar.YEAR, year);
            startCalendar.set(Calendar.MONTH, monthOfYear);
            startCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            DateFormat sdf = android.text.format.DateFormat.getDateFormat(getBaseContext());
            startDateContent.setText(sdf.format(startCalendar.getTime()));
            setDate1 = true;
        }
    };
    new DatePickerDialog(this, date,
            startCalendar.get(Calendar.YEAR),
            startCalendar.get(Calendar.MONTH),
            startCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
Example 11
Project: Sanxing   File: OperateTimeLeftActivityBase.java   Source Code and License 6 votes vote down vote up
@OnClick(R.id.time_left_due_date_content)
void timeLeftDueDateOnClickBehavior() {
    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            dueCalendar.set(Calendar.YEAR, year);
            dueCalendar.set(Calendar.MONTH, monthOfYear);
            dueCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            DateFormat sdf = android.text.format.DateFormat.getDateFormat(getBaseContext());
            dueDateContent.setText(sdf.format(dueCalendar.getTime()));
            setDate2 = true;
        }
    };
    new DatePickerDialog(this, date,
            dueCalendar.get(Calendar.YEAR),
            dueCalendar.get(Calendar.MONTH),
            dueCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
Example 12
Project: Sanxing   File: OperateTaskActivityBase.java   Source Code and License 6 votes vote down vote up
@OnClick(R.id.task_due_date_content)
void taskDueDateOnClickBehavior() {
    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            dueCalendar.set(Calendar.YEAR, year);
            dueCalendar.set(Calendar.MONTH, monthOfYear);
            dueCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            DateFormat sdf = android.text.format.DateFormat.getDateFormat(getBaseContext());
            dueDateContent.setText(sdf.format(dueCalendar.getTime()));
            setDate = true;
        }
    };
    new DatePickerDialog(this, date,
            dueCalendar.get(Calendar.YEAR),
            dueCalendar.get(Calendar.MONTH),
            dueCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
Example 13
Project: Sanxing   File: HabitCalendarFragment.java   Source Code and License 6 votes vote down vote up
@OnClick(R.id.habit_calendar_year_month)
void habitCalendarYearMonthOnClickBehavior() {
    DatePickerDialog.OnDateSetListener dateListener = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            selectedCalendar.set(Calendar.YEAR, year);
            selectedCalendar.set(Calendar.MONTH, monthOfYear);
            selectedCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            habitCalendarView.setCurrentDate(selectedCalendar.getTime());
            updateHabitCalendarYearMonth();
            updateHabitDetails(selectedCalendar.getTime());
        }
    };
    new DatePickerDialog(this.getContext(), dateListener,
            selectedCalendar.get(Calendar.YEAR),
            selectedCalendar.get(Calendar.MONTH),
            selectedCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
Example 14
Project: quickhybrid-android   File: UIApi.java   Source Code and License 6 votes vote down vote up
/**
 * 弹出日期选择对话框
 * <p>
 * 参数:
 * title: 标题
 * datetime: 指定日期 yyyy-MM-dd
 * 返回:
 * date: 格式:yyyy-MM-dd
 */
public static void pickDate(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    final String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd"));
    }
    wv.post(new Runnable() {
        public void run() {
            DialogUtil.pickDate(webLoader.getPageControl().getActivity(), title, calendar, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, monthOfYear);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM-dd");
                    Map<String, Object> map = new HashMap<>();
                    map.put("date", chooseDate);
                    callback.applySuccess(map);
                }
            });
        }
    });
}
 
Example 15
Project: quickhybrid-android   File: UIApi.java   Source Code and License 6 votes vote down vote up
/**
 * 弹出年月选择对话框
 * <p>
 * 参数:
 * title: 标题
 * datetime: 指定日期 yyyy-MM
 * 返回:
 * month: 格式:yyyy-MM
 */
public static void pickMonth(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM"));
    }
    DialogUtil.pickMonth(webLoader.getPageControl().getActivity(), title, calendar, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            calendar.set(Calendar.YEAR, year);
            calendar.set(Calendar.MONTH, monthOfYear);
            calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM");
            Map<String, Object> map = new HashMap<>();
            map.put("month", chooseDate);
            callback.applySuccess(map);
        }
    });
}
 
Example 16
Project: Veggietizer   File: DatePickerFragment.java   Source Code and License 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Uses the current date as the default date in the picker
    Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day);
    DatePicker datePicker = dialog.getDatePicker();

    datePicker.setCalendarViewShown(false);
    numOfCalls = 0;

    return dialog;
}
 
Example 17
Project: MobileAppForPatient   File: CalendarDialog.java   Source Code and License 6 votes vote down vote up
/**
 * Method to display the date picker
 */
public void showDatePicker(){
    Calendar mCalendar = Calendar.getInstance();
    int year = mCalendar.get(Calendar.YEAR);
    mCalendar.set(Calendar.ERA,1);
    int month = mCalendar.get(Calendar.MONTH);
    int day = mCalendar.get(Calendar.DAY_OF_MONTH);
    mCurrentDatePicker = new DatePickerDialog(mActivity,mDatePickerHandler, year, month, day);
    mCurrentDatePicker.setButton(DatePickerDialog.BUTTON_POSITIVE, mActivity.getString(R.string.ok),new DialogInterface.OnClickListener(){
        @Override
        public void onClick(DialogInterface dialog, int which) {
            DatePicker datePicker = mCurrentDatePicker.getDatePicker();
            mDatePickerHandler.onDateSet(datePicker, datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
        }
    });

    mCurrentDatePicker.show();
}
 
Example 18
Project: arrispwgen-android   File: DatePickerFragment.java   Source Code and License 6 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
    String tag = getTag();

    MainActivity activity = (MainActivity) getActivity();

    // threeten's LocalDate months are zero-indexed.
    month++;

    switch (tag) {
        case "start_date_picker":
            activity.set_start_date(year, month, dayOfMonth);
            DialogFragment end_date_fragment = new DatePickerFragment();
            end_date_fragment.show(getFragmentManager(), "end_date_picker");
            break;
        case "end_date_picker":
            activity.set_end_date(year, month, dayOfMonth);
            activity.generate_potd_list();
            break;
    }
}
 
Example 19
Project: GoalsAndHabits   File: NewHabitEventActivity.java   Source Code and License 6 votes vote down vote up
/**
 * Called on activity start. Generates layout and button functionality.
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_habit_event);
    Toolbar toolbar = (Toolbar) findViewById(R.id.actionbar);
    toolbar.setTitle("New Habit Event");
    toolbar.setNavigationIcon(R.drawable.ic_close_button);
    setSupportActionBar(toolbar);

    editPhoto = (ImageView) findViewById(R.id.editPhoto);
    editComment = (EditText) findViewById(R.id.editComment);
    editDate = (DatePicker) findViewById(R.id.editDate);
    photoEncoded = "";

    editPhoto.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dispatchTakePictureIntent();
        }
    });


}
 
Example 20
Project: orgzly-android   File: AgendaFragmentTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testShiftRepeaterTaskToTomorrow() {
    DateTime tomorrow = DateTime.now().withTimeAtStartOfDay().plusDays(1);

    defaultSetUp();
    openAgenda();
    onListItem(2).perform(swipeRight());
    onListItem(2).onChildView(withId(R.id.item_menu_schedule_btn)).perform(click());
    onView(withId(R.id.dialog_timestamp_date_picker)).perform(click());
    onView(withClassName(equalTo(DatePicker.class.getName())))
            .perform(PickerActions.setDate(
                    tomorrow.getYear(),
                    tomorrow.getMonthOfYear(),
                    tomorrow.getDayOfMonth()));
    onView(withText(R.string.ok)).perform(click());
    onView(withText(R.string.set)).perform(click());
    onView(allOf(withId(android.R.id.list), isDisplayed())).check(matches(listViewItemCount(21)));
}
 
Example 21
Project: KTools   File: KDialogActivity.java   Source Code and License 6 votes vote down vote up
@OnClick(R.id.btn_choose_date_dialog)
public void onBtnChooseDateDialogClicked() {
    final Calendar calendar = Calendar.getInstance();
    DatePickerDialog dialog = new DatePickerDialog(
            this,
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, month);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    String date = DateFormat.getDateInstance(DateFormat.FULL).format(calendar.getTime());
                    ToastUtils.showShortToast(date);
                }
            }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
    dialog.show();
}
 
Example 22
Project: GitHub   File: DynamicSettersActivity.java   Source Code and License 5 votes vote down vote up
@OnClick(R.id.button_min_date)
void onMinClicked() {
    showDatePickerDialog(this, widget.getMinimumDate(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            widget.state().edit()
                    .setMinimumDate(CalendarDay.from(year, monthOfYear, dayOfMonth))
                    .commit();
        }
    });
}
 
Example 23
Project: react-native-datepicker-component-android   File: RNDatePickerComponentViewManager.java   Source Code and License 5 votes vote down vote up
/**
 * Create a native date picker from layout file with spinner mode
 * @param reactContext
 * @return Native date picker
 */
@Override
protected DatePicker createViewInstance(ThemedReactContext reactContext) {
    View view = LayoutInflater.from(reactContext).inflate(R.layout.date_picker, null, false);
    DatePicker picker = (DatePicker) view.findViewById(R.id.datepicker);
    ViewGroup viewParent = (ViewGroup) picker.getParent();
    if (viewParent != null) {
        viewParent.removeView(picker);
    }
    return picker;
}
 
Example 24
Project: GitHub   File: DynamicSettersActivity.java   Source Code and License 5 votes vote down vote up
@OnClick(R.id.button_selected_date)
void onSelectedClicked() {
    showDatePickerDialog(this, widget.getSelectedDate(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            widget.setSelectedDate(CalendarDay.from(year, monthOfYear, dayOfMonth));
        }
    });
}
 
Example 25
Project: Tasks   File: CalenderFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstance){
    super.onCreate(savedInstance);
    ((App)getActivity().getApplication()).getComponent().inject(this);

    taskList = presenter.getNormalTasks();
    DatePicker picker = new DatePicker(getActivity());
    timeInMillSecs = picker.getMaxDate();
}
 
Example 26
Project: TrainPonctuality   File: DateSelectionActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_date_selection);

    Bundle extras = getIntent().getExtras();
    setTitle(extras.getInt("title"));
    //noinspection ConstantConditions
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, extras.getInt("color"))));

    dtpDate = (DatePicker) findViewById(R.id.datePicker);
    dateSelection = GregorianCalendar.getInstance();
    dateSelection.setTimeInMillis(extras.getLong("date"));
    dtpDate.updateDate(dateSelection.get(Calendar.YEAR), dateSelection.get(Calendar.MONTH), dateSelection.get(Calendar.DAY_OF_MONTH));
}
 
Example 27
Project: wirtualnaApteczka   File: MedicineDueDateSetListener.java   Source Code and License 5 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(year, month, dayOfMonth, 0, 0, 0);

    DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext());
    String formattedDate = dateFormat.format(calendar.getTime());

    medicineDueDate.setText(formattedDate);

    medicineForUpdate.setDueDate(calendar.getTime());
}
 
Example 28
Project: Toodoo   File: ToodooNote.java   Source Code and License 5 votes vote down vote up
public void showDatePickerDialog() {
    final 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 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM dd, yyyy", Locale.US);
    final SimpleDateFormat simpleDayFormat = new SimpleDateFormat("EEE", Locale.US);
    final String currentDate = simpleDateFormat.format(calendar.getTime());

    final ToodooDatePickerDialog datePickerDialog = new ToodooDatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker datePicker, int year, int month, int day) {
            Calendar newCalendar = Calendar.getInstance();
            newCalendar.set(year, month, day);
            selectedDueDateValue = newCalendar.getTime();
            String selectedDate = simpleDateFormat.format(selectedDueDateValue);
            selectedDueDate = simpleDayFormat.format(selectedDueDateValue) + ", " + selectedDate;

            calendar.add(Calendar.DATE, 1);
            if (selectedDate.equals(currentDate)) {
                selectedDueDate = "Today, " + selectedDate;
            } else if (selectedDate.equals(simpleDateFormat.format(calendar.getTime()))) {
                selectedDueDate = "Tomorrow, " + selectedDate;
            }

            ToodooOptionsModel ToodooOptionsModel = toodooOptionsList.get(1);
            ToodooOptionsModel.setOptionValue(selectedDueDate);
            mAdapter.notifyDataSetChanged();
        }
    }, mYear, mMonth, mDay);
    datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
    setTitle("Select a date");
    datePickerDialog.show();
}
 
Example 29
Project: hyperrail-for-android   File: DateTimePicker.java   Source Code and License 5 votes vote down vote up
/**
 * Callback from date dialog
 *
 * @inheritDoc
 */
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
    this.year = year;
    this.month = month;
    this.day = day;
    pickTime();
}
 
Example 30
Project: FamilyLibraryManager   File: InputFragment.java   Source Code and License 5 votes vote down vote up
/**
 * 显示时间捡取器
 */
private void showDatePickerDialog() {
    new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            showDate.set(Calendar.YEAR, year);
            showDate.set(Calendar.MONTH, monthOfYear);
            showDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            bookDateEditText.setText(DateFormat.format("yyyy-MM-dd", showDate));
        }
    }, showDate.get(Calendar.YEAR), showDate.get(Calendar.MONTH), showDate.get(Calendar.DAY_OF_MONTH)).show();
}
 
Example 31
Project: FamilyLibraryManager   File: SearchFragment.java   Source Code and License 5 votes vote down vote up
/**
 * 显示时间捡取器
 */
private void showDatePickerDialog() {
    new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            showDate.set(Calendar.YEAR, year);
            showDate.set(Calendar.MONTH, monthOfYear);
            showDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            bookDateEditText.setText(DateFormat.format("yyyy-MM-dd", showDate));
        }
    }, showDate.get(Calendar.YEAR), showDate.get(Calendar.MONTH), showDate.get(Calendar.DAY_OF_MONTH)).show();
}
 
Example 32
Project: MyFlightbookAndroid   File: DlgDatePicker.java   Source Code and License 5 votes vote down vote up
public void onDateChanged(DatePicker vw, int year, int monthOfYear, int dayOfMonth) {
    GregorianCalendar c = getCalendar();
    c.set(year, monthOfYear, dayOfMonth, tpTime.getCurrentHour(), tpTime.getCurrentMinute());

    this.m_Date = c.getTime();

    NotifyDelegate();
}
 
Example 33
Project: MoodSwings   File: EditMoodActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
                      int dayOfMonth) {
    myCalendar.set(Calendar.YEAR, year);
    myCalendar.set(Calendar.MONTH, monthOfYear);
    myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
    moodEvent.setDate(SIMPLE_DATE_FORMAT.format(myCalendar.getTime()));

    new TimePickerDialog(EditMoodActivity.this, time, myCalendar
            .get(Calendar.HOUR_OF_DAY), myCalendar.get(Calendar.MINUTE), false).show();
}
 
Example 34
Project: calendarview2   File: DynamicSettersActivity.java   Source Code and License 5 votes vote down vote up
@OnClick(R.id.button_min_date)
void onMinClicked() {
    showDatePickerDialog(this, widget.getMinimumDate(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            widget.state().edit()
                    .setMinimumDate(CalendarDay.from(year, monthOfYear, dayOfMonth))
                    .commit();
        }
    });
}
 
Example 35
Project: decoy   File: UserProfileEditItemActivity.java   Source Code and License 5 votes vote down vote up
private void openTimePicker() {
    MyDatePickerDialog datePickerDialog = new MyDatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            birthYear = year;
            birthMonth = monthOfYear;
            birthDay = dayOfMonth;
            updateDate();

        }
    }, birthYear, birthMonth, birthDay);
    datePickerDialog.show();
}
 
Example 36
Project: MyCalendar   File: AddEditWeekLessonDialogFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
    if (mActiveCal != null) {
        mActiveCal.set(Calendar.YEAR, year);
        mActiveCal.set(Calendar.MONTH, month);
        mActiveCal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
        onUpdateDate(mViewId, mActiveCal);
        onAfterShowDatePicker();
    }
}
 
Example 37
Project: MyCalendar   File: AddEditDetailSubjectActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day, int id_view) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month);
    cal.set(Calendar.DAY_OF_MONTH, day);
    DateTimeHelper.clearTime(cal);
    onUpdateDate(id_view, cal);
}
 
Example 38
Project: GCSApp   File: AddCaseActivity.java   Source Code and License 5 votes vote down vote up
public void showDialogDatePicker(){
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DialogTransBackGround);
    final AlertDialog dialog_date = builder.create();
    dialog_date.show();
    View view_dialog = LayoutInflater.from(context).inflate(R.layout.item_dialog_datepicker, null);
    dialog_date.setContentView(view_dialog);
    DatePicker picker = (DatePicker) view_dialog.findViewById(R.id.date_picker);
    Button bt_yes = (Button) view_dialog.findViewById(R.id.bt_yes);
    Button bt_no = (Button) view_dialog.findViewById(R.id.bt_no);

    Calendar calendar = Calendar.getInstance();
    int int_Year = calendar.get(Calendar.YEAR);
    int int_Month = calendar.get(Calendar.MONTH);
    int int_Day = calendar.get(Calendar.DAY_OF_MONTH);

    time = int_Year + "-" + String.format("%02d", (int_Month + 1)) + "-" + String.format("%02d", int_Day);
    picker.init(int_Year, int_Month, int_Day, new DatePicker.OnDateChangedListener() {
        @Override
        public void onDateChanged(DatePicker datePicker, int i, int i1, int i2) {
            Log.e("aaa", "" + i2);
            time = i + "-" + String.format("%02d", (i1 + 1)) + "-" + String.format("%02d", i2);
        }
    });
    bt_yes.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            et_add_time.setText(time);
            dialog_date.dismiss();
        }
    });
    bt_no.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog_date.dismiss();
        }
    });
}
 
Example 39
Project: Moodr   File: EditMoodActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
    yearFinal = year;
    monthFinal = month + 1;
    dayFinal = day;

    hour = editDate_copy.getHours();
    minute = editDate_copy.getMinutes();

    TimePickerDialog timePickerDialog = new TimePickerDialog(EditMoodActivity.this, EditMoodActivity.this, hour, minute, DateFormat.is24HourFormat(this));
    timePickerDialog.show();
}
 
Example 40
Project: Chore-Manager-App   File: NewChoreActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int monthofYear, int dayOfMonth) {
dateTime.set(Calendar.YEAR,year);
dateTime.set(Calendar.MONTH,monthofYear);
dateTime.set(Calendar.DAY_OF_MONTH,dayOfMonth);
updateDeadLineText();
updateTime();
}