Example usage for android.app DatePickerDialog show

List of usage examples for android.app DatePickerDialog show

Introduction

In this page you can find the example usage for android.app DatePickerDialog show.

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:net.niyonkuru.koodroid.ui.UsageFragment.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    int id = item.getItemId();

    switch (id) {
    case R.id.edit_billing_cycle:
        Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
        cal.setTime((Date) mPeriodFrom.getTag());

        DatePickerDialog dialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
            @Override//from   w w  w. j  a  v a2  s.  c  o  m
            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                ContentValues values = new ContentValues(1);
                values.put(Settings.BILLING_CYCLE, dayOfMonth);
                mContext.getContentResolver().insert(Settings.CONTENT_URI, values);
            }
        }, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE));

        dialog.setMessage(getResources().getString(R.string.billing_cycle_dialog));

        //                DatePicker datePicker = dialog.getDatePicker();
        //                datePicker.setMaxDate(System.currentTimeMillis());

        dialog.show();

        return true;
    case R.id.enable_airtime: {
        getLoaderManager().restartLoader(AIRTIME_TOKEN, null, this);
    }
    case R.id.disable_airtime:
        View airtimeContent = getView().findViewById(R.id.airtime_content);
        AnimUtils.show(airtimeContent);

        toggleService(Settings.AIRTIME_SERVICE, id == R.id.enable_airtime);

        /* refresh the widget to show or hide data */
        IntentUtils.updateWidget(mContext);

        return true;
    case R.id.refresh_airtime:
        sync(SyncService.AIRTIME);
        return true;
    case R.id.enable_data: {
        LoaderManager loaderManager = getLoaderManager();

        loaderManager.restartLoader(DATA_TOKEN, null, this);
        loaderManager.restartLoader(TEXT_TOKEN, null, this);
    }
    case R.id.disable_data:
        View dataContent = getView().findViewById(R.id.data_content);
        AnimUtils.show(dataContent);

        View textContent = getView().findViewById(R.id.text_content);
        AnimUtils.show(textContent);

        toggleService(Settings.USAGE_SERVICE, id == R.id.enable_data);

        /* refresh the widget to show or hide data */
        IntentUtils.updateWidget(mContext);

        return true;
    case R.id.refresh_data:
        sync(SyncService.USAGE);
        return true;
    case R.id.detail_data:
        mCallBack.onShowDataTransactions(getSubscriber());
        return true;
    }

    return false;
}

From source file:com.rsmsa.accapp.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_drawer);

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    gridView = (ListView) findViewById(R.id.headergridview);

    /**//from w ww  . j a  v  a2 s. c o m
     * Temporary header
     */

    if (!hasheader) {
        tempHeader = (View) getLayoutInflater().inflate(R.layout.temp, null);
        gridView.addHeaderView(tempHeader);
        gridView.setAdapter(new gridViewAdapter(MainActivity.this));
        hasheader = true;
        tempFlag = true;

    }

    imgPreview = (ImageView) tempHeader.findViewById(R.id.imgPreview);
    videoPreview = (VideoView) tempHeader.findViewById(R.id.videoPreview);
    btnCapturePicture = (ImageButton) tempHeader.findViewById(R.id.btnCapturePicture);
    btnRecordVideo = (ImageButton) tempHeader.findViewById(R.id.btnCaptureVideo);
    /**
     * Capture image button click event
     */
    btnCapturePicture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // capture picture
            captureImage();
        }
    });

    /**
     * Record video button click event
     */
    btnRecordVideo.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // record video
            recordVideo();
        }
    });

    // Checking camera availability
    if (!isDeviceSupportCamera()) {
        Toast.makeText(getApplicationContext(), "Sorry! Your device doesn't support camera", Toast.LENGTH_LONG)
                .show();
        // will close the app if the device does't have camera
        finish();
    }

    //get GPS location

    SetLocation = (Button) tempHeader.findViewById(R.id.btnLoc);

    SetLocation.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // create class object
            gps = new GPSTracker(MainActivity.this);

            // check if GPS enabled
            if (gps.canGetLocation()) {

                double latitude = gps.getLatitude();
                double longitude = gps.getLongitude();

                //location text view
                TextView location = (TextView) tempHeader.findViewById(R.id.loc);

                location.setText("Lat: " + latitude + "Long: " + longitude);

            } else {
                // can't get location
                // GPS or Network is not enabled
                // Ask user to enable GPS/network in settings
                gps.showSettingsAlert();
            }

        }
    });

    /**
     * header instance
     */
    header = (View) getLayoutInflater().inflate(R.layout.activity_accident, null);
    /**
     * Defining all layout items
     **/
    inputReg = (EditText) header.findViewById(R.id.reg_ref);

    inputFatal = (EditText) header.findViewById(R.id.fatal_edit);

    inputInjuries = (EditText) header.findViewById(R.id.injury_edit);

    inputSimple = (EditText) header.findViewById(R.id.simple_edit);

    damage = (EditText) header.findViewById(R.id.not_injured_edit);

    area_name = (EditText) header.findViewById(R.id.name);

    district = (EditText) header.findViewById(R.id.district);

    region = (EditText) header.findViewById(R.id.city);

    road_name = (EditText) header.findViewById(R.id.road_name);

    road_no = (EditText) header.findViewById(R.id.road_number);

    road_mark = (EditText) header.findViewById(R.id.road_mark);

    intersection_name = (EditText) header.findViewById(R.id.intersection_name);

    intersection_no = (EditText) header.findViewById(R.id.intersection_number);

    intersection_mark = (EditText) header.findViewById(R.id.intersection_mark);

    mDate = (EditText) header.findViewById(R.id.date);

    mTime = (EditText) header.findViewById(R.id.time);

    //Textchanges

    inputReg.addTextChangedListener(new EditTextWatcher(inputReg));

    inputFatal.addTextChangedListener(new EditTextWatcher(inputFatal));
    inputInjuries.addTextChangedListener(new EditTextWatcher(inputInjuries));
    inputSimple.addTextChangedListener(new EditTextWatcher(inputSimple));
    damage.addTextChangedListener(new EditTextWatcher(damage));

    area_name.addTextChangedListener(new EditTextWatcher(area_name));
    district.addTextChangedListener(new EditTextWatcher(district));
    region.addTextChangedListener(new EditTextWatcher(region));

    mDate.addTextChangedListener(new EditTextWatcher(mDate));
    mTime.addTextChangedListener(new EditTextWatcher(mTime));

    road_name.addTextChangedListener(new EditTextWatcher(road_name));
    road_no.addTextChangedListener(new EditTextWatcher(road_no));
    road_mark.addTextChangedListener(new EditTextWatcher(road_mark));
    intersection_name.addTextChangedListener(new EditTextWatcher(intersection_name));
    intersection_no.addTextChangedListener(new EditTextWatcher(intersection_no));
    intersection_mark.addTextChangedListener(new EditTextWatcher(intersection_mark));

    cal = Calendar.getInstance();

    day = cal.get(Calendar.DAY_OF_MONTH);

    month = cal.get(Calendar.MONTH);

    year = cal.get(Calendar.YEAR);

    hour = cal.get(Calendar.HOUR_OF_DAY);

    min = cal.get(Calendar.MINUTE);

    datePicker = (Button) header.findViewById(R.id.date_picker);
    datePicker.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DatePickerDialog datePickerDialog = new DatePickerDialog(MainActivity.this, datePickerListener,
                    year, month, day);
            datePickerDialog.show();

        }
    });

    timePicker = (Button) header.findViewById(R.id.time_picker);
    timePicker.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TimePickerDialog timePickerDialog = new TimePickerDialog(MainActivity.this, timePickerListener,
                    hour, min, true);
            timePickerDialog.show();
        }
    });

    // set a custom shadow that overlays the main content when the drawer
    // opens
    mDrawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    _initMenu();

    mDrawerToggle = new CustomActionBarDrawerToggle(this, mDrawer);

    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent passenger = new Intent(MainActivity.this, Passenger.class);
            startActivity(passenger);
        }
    });
    mDrawer.setDrawerListener(mDrawerToggle);

    /**
     * instantiate ViewPager
     */
    mPager = (AutoScrollViewPager) header.findViewById(R.id.pager);
    mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    mPager.setPageTransformer(true, new DepthPageTransformer());
    mPager.setAdapter(mPagerAdapter);

    PageListener pageListener = new PageListener();
    mPager.setOnPageChangeListener(pageListener);

}

From source file:com.flowzr.activity.RecurActivity.java

private void addLayouts(LayoutInflater inflater, LinearLayout layout, Layoutable[] items) {
    for (Layoutable i : items) {
        int layoutId = i.getLayoutId();
        if (layoutId != 0) {
            final View v = inflater.inflate(layoutId, null);
            v.setTag(i);/*from  w  ww  .j  av a 2  s. c o m*/
            v.setVisibility(View.INVISIBLE);
            if (i == RecurPeriod.STOPS_ON_DATE) {
                Button b = (Button) v.findViewById(R.id.bStopsOnDate);
                final Calendar c = this.stopsOnDate;
                editStopsOnDate(v, c.getTimeInMillis());
                b.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(final View view) {
                        DatePickerDialog d = new DatePickerDialog(RecurActivity.this,
                                new DatePickerDialog.OnDateSetListener() {
                                    @Override
                                    public void onDateSet(DatePicker view, int year, int monthOfYear,
                                            int dayOfMonth) {
                                        c.set(Calendar.YEAR, year);
                                        c.set(Calendar.MONTH, monthOfYear);
                                        c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                                        DateUtils.endOfDay(c);
                                        editStopsOnDate(v, c.getTimeInMillis());
                                    }
                                }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
                        d.show();
                    }
                });
            }
            layout.addView(v, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
        }
    }
}

From source file:me.tipi.kiosk.ui.fragments.IdentityFragment.java

/**
 * Show dob dialog.//w w  w .  j a  va  2  s.c  o m
 */
private void showDobDialog() {
    DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(),
            android.R.style.Theme_Holo_Light_Dialog, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    birthdayLayout.setError(null);
                    Calendar calendar = Calendar.getInstance();
                    birthDayPickerView.setText(
                            String.format(Locale.US, "%d - %d - %d", dayOfMonth, monthOfYear + 1, year));
                    calendar.set(year, monthOfYear, dayOfMonth);
                    dob = calendar.getTime();
                }
            }, 1985, 6, 15);
    DatePicker datePicker = datePickerDialog.getDatePicker();
    datePickerDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    styleDatePicker(datePicker);
    datePickerDialog.show();
}

From source file:com.QuarkLabs.BTCeClient.fragments.HistoryFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mAdapter = new OrdersAdapter(getActivity(), mHistoryType);
    mListView = (ListView) getView().findViewById(R.id.HistoryContainer);
    final EditText startDate = (EditText) getView().findViewById(R.id.StartDateValue);
    final EditText endDate = (EditText) getView().findViewById(R.id.EndDateValue);
    startDate.setText(mDateFormat.format(mStartDateValue));
    endDate.setText(mDateFormat.format(mEndDateValue));
    Button makeQuery = (Button) getView().findViewById(R.id.MakeQueryButton);
    View.OnClickListener showDatePicker = new View.OnClickListener() {
        @Override/*from   ww  w .  j  a va  2  s.  co m*/
        public void onClick(View v) {
            final TextView dateValue = (TextView) v;
            Date date = null;
            try {
                date = mDateFormat.parse(dateValue.getText().toString());
            } catch (ParseException e) {
                e.printStackTrace();
            }
            int year = 1999;
            int month = 0;
            int day = 1;
            if (date != null) {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(date);
                year = calendar.get(Calendar.YEAR);
                month = calendar.get(Calendar.MONTH);
                day = calendar.get(Calendar.DAY_OF_MONTH);
            }

            DatePickerDialog datePickerDialog = new android.app.DatePickerDialog(getActivity(),
                    new DatePickerDialog.OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                            Calendar calendar = Calendar.getInstance();
                            if (dateValue.getId() == R.id.StartDateValue) {
                                calendar.setTime(mStartDateValue);
                                calendar.set(year, monthOfYear, dayOfMonth, 0, 0, 0);
                                mStartDateValue = calendar.getTime();
                            } else {
                                calendar.setTime(mEndDateValue);
                                calendar.set(year, monthOfYear, dayOfMonth, 23, 59, 59);
                                mEndDateValue = calendar.getTime();
                            }
                            dateValue.setText(mDateFormat.format(calendar.getTime()));
                        }
                    }, year, month, day);
            datePickerDialog.getDatePicker().setCalendarViewShown(false);
            datePickerDialog.show();
        }
    };
    startDate.setOnClickListener(showDatePicker);
    endDate.setOnClickListener(showDatePicker);
    makeQuery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Bundle bundle = new Bundle();
            bundle.putString("startDate", String.valueOf(mStartDateValue.getTime() / 1000));
            bundle.putString("endDate", String.valueOf(mEndDateValue.getTime() / 1000));
            getLoaderManager().restartLoader(mLoaderId, bundle, HistoryFragment.this);
            mListView.setAdapter(null);
            mNoItems.setVisibility(View.GONE);
            mListView.setEmptyView(mLoadingView);

        }
    });
    mLoadingView = (ProgressBar) getView().findViewById(R.id.Loading);
    mNoItems = (TextView) getView().findViewById(R.id.NoItems);
    mListView.setEmptyView(mLoadingView);
}

From source file:com.uoit.freeroomfinder.FreeRoom.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    // Add the root view container.
    rootView = inflater.inflate(R.layout.activity_free_room, container, false);

    // Load the shared preferences.
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity().getBaseContext());

    // Get the current date and time.
    curDate = new Date();

    // Set up default values for the display elements in the fragment.

    // Default campus selection.
    Spinner campus = (Spinner) rootView.findViewById(R.id.campus);
    campus.setSelection(Integer.valueOf(sharedPrefs.getString("default_campus", "0")) - 1);

    // Default booking duration.
    Spinner duration = (Spinner) rootView.findViewById(R.id.duration);
    duration.setSelection(Integer.valueOf(sharedPrefs.getString("default_duration", "0")) - 1);

    // Default time selection.
    timeSpinner = (Spinner) rootView.findViewById(R.id.time);
    // Set the current date to show as Today.
    TextView date = (TextView) rootView.findViewById(R.id.date);
    date.setText(DateTimeUtility.formatDate(curDate) + " (Today)");

    datePicked = DateTimeUtility.formatDate(curDate);

    // Instantiate the list of available rooms.
    availableRooms = new ArrayList<Rooms>();

    // Logic for when a date is clicked on. This initiates the custom date spinner control.
    date.setOnClickListener(new OnClickListener() {
        /*//from  ww  w .j ava  2 s. c  o m
         * (non-Javadoc)
         * 
         * @see android.view.View.OnClickListener#onClick(android.view.View)
         */
        @Override
        public void onClick(View v) {
            // parse the date that's currently in there.
            Date d = null;
            try {
                d = DateTimeUtility.parseDate(datePicked);
            } catch (ParseException e) {
                e.printStackTrace();
            }

            Calendar c = Calendar.getInstance();
            // Grab the year, month, and day from the spinners.
            if (d != null) {
                c.setTime(d);
            }
            int yy = c.get(Calendar.YEAR);
            int mm = c.get(Calendar.MONTH);
            int dd = c.get(Calendar.DAY_OF_MONTH);

            DatePickerDialog alert = new DatePickerDialog(rootView.getContext(),

                    /**
                     * Set up the listener for when the date is set from the custom spinner alert
                     * dialog.
                     */
                    new DatePickerDialog.OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                            // Parse the date - year, month, day.
                            datePicked = year + "-" + (monthOfYear + 1) + "-" + dayOfMonth;
                            TextView date = (TextView) rootView.findViewById(R.id.date);

                            // If the date is today's date, set it to Today.
                            date.setText(datePicked);
                            if (datePicked.contains(DateTimeUtility.formatDate(curDate))) {
                                date.setText(datePicked + " (Today)");
                            }
                        }
                    }, yy, mm, dd);

            alert.show();
        }
    });

    // Add the search buttom.
    Button search = (Button) rootView.findViewById(R.id.search);
    search.setOnClickListener(new OnClickListener() {
        /*
         * (non-Javadoc)
         * 
         * @see android.view.View.OnClickListener#onClick(android.view.View)
         */
        @Override
        public void onClick(View v) {
            // When the search button is pressed, fetch the results.
            Date curDate = new Date();

            Spinner timeSpinner = (Spinner) rootView.findViewById(R.id.time);
            Spinner durationSpinner = (Spinner) rootView.findViewById(R.id.duration);
            Spinner campusSpinner = (Spinner) rootView.findViewById(R.id.campus);

            try {
                // Formulate a query based on the time. If we're using the current time, make
                // sure we use the actual current time rather than "Now" because that's invalid.
                if (timeSpinner.getSelectedItem().toString().compareTo("Now") == 0) {
                    timePicked = DateTimeUtility.formatFullTime(DateTimeUtility.formatTime(curDate));
                } else {
                    timePicked = DateTimeUtility.formatFullTime(timeSpinner.getSelectedItem().toString());
                }

                // Add the campus we've selected to the query.
                campusPicked = rootView.getResources().getStringArray(R.array.campus_names)[campusSpinner
                        .getSelectedItemPosition()];

                // Add the duration of the search to the query.
                durationPicked = Integer.valueOf(durationSpinner.getSelectedItem().toString());

                // Formulate the search task.
                ((MainActivity) FreeRoom.this.getActivity()).showProgress(true);
                searchTask = new SearchTask();
                searchTask
                        .setOnFinshedTaskListener((Results) MainActivity.switchTabs(MainActivity.RESULTS_TAB));
                searchTask.execute();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    return rootView;
}

From source file:nl.mpcjanssen.simpletask.AddTask.java

private void insertDate(final int dateType) {
    Dialog d = Util.createDeferDialog(this, dateType, false, new Util.InputDialogListener() {
        @Override//  w ww  .ja  v a2s. c o m
        public void onClick(@NotNull String selected) {
            if (selected.equals("pick")) {
                /* Note on some Android versions the OnDateSetListener can fire twice
                 * https://code.google.com/p/android/issues/detail?id=34860
                 * With the current implementation which replaces the dates this is not an
                 * issue. The date is just replaced twice
                 */
                final DateTime today = DateTime.today(TimeZone.getDefault());
                DatePickerDialog dialog = new DatePickerDialog(AddTask.this,
                        new DatePickerDialog.OnDateSetListener() {
                            @Override
                            public void onDateSet(DatePicker datePicker, int year, int month, int day) {
                                month++;

                                DateTime date = DateTime.forDateOnly(year, month, day);
                                insertDateAtSelection(dateType, date);
                            }
                        }, today.getYear(), today.getMonth() - 1, today.getDay());

                boolean showCalendar = m_app.showCalendar();

                dialog.getDatePicker().setCalendarViewShown(showCalendar);
                dialog.getDatePicker().setSpinnersShown(!showCalendar);
                dialog.show();
            } else {
                insertDateAtSelection(dateType,
                        Util.addInterval(DateTime.today(TimeZone.getDefault()), selected));
            }
        }
    });
    d.show();
}

From source file:org.openmrs.mobile.activities.addeditpatient.AddEditPatientFragment.java

private void addListeners() {
    gen.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup rGroup, int checkedId) {
            gendererror.setVisibility(View.GONE);
        }//from  ww  w. j  a  va 2 s.  co  m
    });

    edcountry.setThreshold(2);
    edcountry.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (edcountry.getText().length() >= edcountry.getThreshold()) {
                edcountry.showDropDown();
            }
            if (Arrays.asList(countries).contains(edcountry.getText().toString())) {
                edcountry.dismissDropDown();
            }
        }
    });
    edstate.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            addSuggestionsToCities();
        }
    });
    if (eddob != null) {
        eddob.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int cYear;
                int cMonth;
                int cDay;

                if (bdt == null) {
                    Calendar currentDate = Calendar.getInstance();
                    cYear = currentDate.get(Calendar.YEAR);
                    cMonth = currentDate.get(Calendar.MONTH);
                    cDay = currentDate.get(Calendar.DAY_OF_MONTH);
                } else {
                    cYear = bdt.getYear();
                    cMonth = bdt.getMonthOfYear() - 1;
                    cDay = bdt.getDayOfMonth();
                }

                edmonth.getText().clear();
                edyr.getText().clear();

                DatePickerDialog mDatePicker = new DatePickerDialog(AddEditPatientFragment.this.getActivity(),
                        new DatePickerDialog.OnDateSetListener() {
                            public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth,
                                    int selectedday) {
                                int adjustedMonth = selectedmonth + 1;
                                eddob.setText(selectedday + "/" + adjustedMonth + "/" + selectedyear);
                                birthdate = new LocalDate(selectedyear, adjustedMonth, selectedday);
                                bdt = birthdate.toDateTimeAtStartOfDay().toDateTime();
                            }
                        }, cYear, cMonth, cDay);
                mDatePicker.getDatePicker().setMaxDate(System.currentTimeMillis());
                mDatePicker.setTitle("Select Date");
                mDatePicker.show();
            }
        });
    }

    capturePhoto.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AddEditPatientFragmentPermissionsDispatcher.capturePhotoWithCheck(AddEditPatientFragment.this);
        }
    });

    submitConfirm.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPresenter.confirmRegister(createPatient());
        }
    });

    patientImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (output != null) {
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setDataAndType(Uri.fromFile(output), "image/jpeg");
                startActivity(i);
            } else if (patientPhoto != null) {
                Intent intent = new Intent(getContext(), PatientPhotoActivity.class);
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                patientPhoto.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
                intent.putExtra("photo", byteArrayOutputStream.toByteArray());
                intent.putExtra("name", patientName);
                startActivity(intent);
            }
        }
    });

    TextWatcher textWatcher = new PatientBirthdateValidatorWatcher(eddob, edmonth, edyr);
    edmonth.addTextChangedListener(textWatcher);
    edyr.addTextChangedListener(textWatcher);
}

From source file:shetye.prathamesh.notifyme.Utilities.java

public void createWhenDialog(final Context context, final Activity parentActivity, final Notif note,
        final boolean back) {
    mDialog = new Dialog(context);
    mDialog.setContentView(R.layout.datetimepicker_dialog);
    mDialog.setTitle("When to Notify??");
    mDialogOKBtn = (Button) mDialog.findViewById(R.id.btn_ok);
    mDialogOKBtn.setOnClickListener(new View.OnClickListener() {
        @Override// w  w w.jav a2  s  . co m
        public void onClick(View v) {
            note.setNotification_when(getSelectedTime());
            DatabaseHelper.getInstance(context).addNotif(note);
            setZoneInTimer(context, note);
            mDialog.dismiss();
            if (parentActivity != null) {
                if (back) {
                    parentActivity.finishAfterTransition();
                } else {
                    ((Notifications) parentActivity).refreshNotifications();
                }
            }
        }
    });
    mDialogOKBtn.setEnabled(false);
    mDialogCancelBtn = (Button) mDialog.findViewById(R.id.btn_cancel);
    mDialogCancelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mDialog.dismiss();
            if (parentActivity != null) {
                parentActivity.finishAfterTransition();
            }
        }
    });
    mTimeBtn = (Button) mDialog.findViewById(R.id.btntimeset);
    mDateBtn = (Button) mDialog.findViewById(R.id.btndateset);
    final Time dtNow = new Time();
    dtNow.setToNow();
    mSelectedHours = dtNow.hour;
    mSelectedMinutes = dtNow.minute;
    mSelectedYear = dtNow.year;
    mSelectedMonth = dtNow.month;
    mSelectedDay = dtNow.monthDay;
    updateBtnText(dtNow, false, context);
    Time selectedTime = new Time();
    selectedTime.set(0, mSelectedMinutes, mSelectedHours, mSelectedDay, mSelectedMonth, mSelectedYear);
    mPastDateSelected = true;
    mTimeBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            TimePickerDialog timePickerDialog = new TimePickerDialog(context,
                    new TimePickerDialog.OnTimeSetListener() {
                        @Override
                        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                            Time selectedTime = new Time();
                            mSelectedHours = hourOfDay;
                            mSelectedMinutes = minute;
                            selectedTime.set(0, mSelectedMinutes, mSelectedHours, mSelectedDay, mSelectedMonth,
                                    mSelectedYear);
                            if (Time.compare(selectedTime, dtNow) <= 0) {
                                mPastDateSelected = true;
                            } else {
                                mPastDateSelected = false;
                            }
                            updateBtnText(selectedTime, true, context);
                        }
                    }, mSelectedHours, mSelectedMinutes, false);
            timePickerDialog.show();
        }
    });
    mDateBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DatePickerDialog datePickerDialog = new DatePickerDialog(context,
                    new DatePickerDialog.OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePicker view, int yy, int mm, int dd) {
                            Time selectedTime = new Time();
                            mSelectedYear = yy;
                            mSelectedMonth = mm;
                            mSelectedDay = dd;
                            selectedTime.set(0, mSelectedMinutes, mSelectedHours, mSelectedDay, mSelectedMonth,
                                    mSelectedYear);
                            if (Time.compare(selectedTime, dtNow) <= 0) {
                                mPastDateSelected = true;
                            } else {
                                mPastDateSelected = false;
                            }
                            updateBtnText(selectedTime, false, context);
                        }
                    }, mSelectedYear, mSelectedMonth, mSelectedDay);
            datePickerDialog.show();
        }
    });
    mDialog.show();
}

From source file:com.zira.registration.BackgroundCheckActivity.java

@Override
public void onClick(View v) {

    switch (v.getId()) {

    case R.id.dob:
        int mYear, mMonth, mDay;
        // Process to get Current Date
        final Calendar c = Calendar.getInstance();
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);

        // Launch Date Picker Dialog
        DatePickerDialog dpd = new DatePickerDialog(BackgroundCheckActivity.this,
                new DatePickerDialog.OnDateSetListener() {

                    @Override/* w w  w  . j a  va  2s .c  o m*/
                    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

                        c.set(year, monthOfYear, dayOfMonth);
                        String selectedDate = mDateFormat.format(c.getTime());
                        String dateTosend = dateFormatToSend.format(c.getTime());
                        System.err.println("selectdate" + dateTosend);
                        DOB = dateTosend;//+String.valueOf(hours)+String.valueOf(minute)+String.valueOf(00);

                        dobTextView.setText(selectedDate);
                        /*   editor.putString("dob", selectedDate);
                           editor.commit();*/
                    }
                }, mYear, mMonth, mDay);
        dpd.show();

        break;
    case R.id.licenceExpiration:
        int Year, Month, Day;
        // Process to get Current Date
        final Calendar c1 = Calendar.getInstance();
        Year = c1.get(Calendar.YEAR);
        Month = c1.get(Calendar.MONTH);
        Day = c1.get(Calendar.DAY_OF_MONTH);

        // Launch Date Picker Dialog
        DatePickerDialog dpd1 = new DatePickerDialog(BackgroundCheckActivity.this,
                new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

                        c1.set(year, monthOfYear, dayOfMonth);
                        String selectedDate = mDateFormat.format(c1.getTime());
                        String dateTosend = dateFormatToSend.format(c1.getTime());
                        System.err.println("selectdate" + dateTosend);
                        licenceExpirationDate = dateTosend;//+String.valueOf(hours)+String.valueOf(minute)+String.valueOf(00);

                        licenceExpirationTextView.setText(selectedDate);
                        /*editor.putString("licenceExpirationDate", selectedDate);
                        editor.commit();*/

                    }
                }, Year, Month, Day);
        dpd1.show();

        break;

    case R.id.SaveAndCuntinue:

        emptyFieldCheck();
        //forwardToNextScreen();      
        break;

    default:

        break;
    }
}