Example usage for android.widget DatePicker updateDate

List of usage examples for android.widget DatePicker updateDate

Introduction

In this page you can find the example usage for android.widget DatePicker updateDate.

Prototype

public void updateDate(int year, int month, int dayOfMonth) 

Source Link

Document

Update the current date.

Usage

From source file:com.kunze.androidlocaltodo.TaskActivityFragment.java

private void InitializeViewFields(View rootView, Task task) {
    final EditText nameEdit = (EditText) rootView.findViewById(R.id.task_name_edit);
    final TextView nameStatic = (TextView) rootView.findViewById(R.id.task_name_static);
    nameStatic.setText(task.mName);// w w  w  .  jav a 2s .  co m
    nameEdit.setText(task.mName);
    final TextView descriptionEdit = (TextView) rootView.findViewById(R.id.task_description_edit);
    descriptionEdit.setText(task.mDescription);
    final TextView dueDateView = (TextView) rootView.findViewById(R.id.due_date_text);
    SetFriendlyDueDateText(dueDateView, task.mDueDate);
    final Calendar dueDate = task.mDueDate;
    final DatePicker datePicker = (DatePicker) rootView.findViewById(R.id.due_date_calendar);
    datePicker.updateDate(dueDate.get(Calendar.YEAR), dueDate.get(Calendar.MONTH),
            dueDate.get(Calendar.DAY_OF_MONTH));
    final CheckBox repeatCheck = (CheckBox) rootView.findViewById(R.id.repeat);
    Boolean repeat = task.mRepeatUnit != Task.RepeatUnit.NONE;
    repeatCheck.setChecked(repeat);
    SetRepeatVisibility(rootView, repeat);
    final EditText repeatTimeEdit = (EditText) rootView.findViewById(R.id.repeat_time);
    repeatTimeEdit.setText(Integer.toString(task.mRepeatTime));
    final Spinner repeatUnitSpinner = (Spinner) rootView.findViewById(R.id.repeat_unit);
    int repeatUnitPos = 0;
    switch (task.mRepeatUnit) {
    case DAYS:
        repeatUnitPos = 0;
        break;
    case WEEKS:
        repeatUnitPos = 1;
        break;
    case MONTHS:
        repeatUnitPos = 2;
        break;
    case YEARS:
        repeatUnitPos = 3;
        break;
    case NONE:
        repeatUnitPos = 0;
    }
    repeatUnitSpinner.setSelection(repeatUnitPos);
    final RadioButton repeatFromComplete = (RadioButton) rootView.findViewById(R.id.repeat_from_complete);
    final RadioButton repeatFromDue = (RadioButton) rootView.findViewById(R.id.repeat_from_due);
    if (task.mRepeatFromComplete) {
        repeatFromComplete.setChecked(true);
    } else {
        repeatFromDue.setChecked(true);
    }
}

From source file:net.reichholf.dreamdroid.activities.TimerEditActivity.java

/**
 * Set the the values of the date and the time picker of the DateTimePicker
 * dialog//from   w w  w  .j a va 2  s  . c  o m
 * 
 * @param dialog
 *            The Dialog containing the date and the time picker
 * @param cal
 *            The calendar-object to set date and time from
 */
private void setDateAndTimePicker(final Dialog dialog, Calendar cal) {
    DatePicker dp = (DatePicker) dialog.findViewById(R.id.DatePicker);
    TimePicker tp = (TimePicker) dialog.findViewById(R.id.TimePicker);

    dp.updateDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
    tp.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
    tp.setCurrentMinute(cal.get(Calendar.MINUTE));
}

From source file:com.kunze.androidlocaltodo.TaskActivityFragment.java

private void InitializeView(final View rootView) {
    final View activityView = rootView;
    TextWatcher textWatcher = new TextWatcher() {
        @Override/*from  w w  w . j ava 2  s.  co  m*/
        public void afterTextChanged(Editable s) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            TaskChanged(activityView);
        }
    };
    final EditText nameEdit = (EditText) rootView.findViewById(R.id.task_name_edit);
    final TextView nameStatic = (TextView) rootView.findViewById(R.id.task_name_static);
    nameStatic.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            nameEdit.setVisibility(View.VISIBLE);
            nameStatic.setVisibility(View.INVISIBLE);
        }
    });
    nameEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                nameEdit.setVisibility(View.INVISIBLE);
                nameStatic.setVisibility(View.VISIBLE);
            }
        }
    });
    nameEdit.addTextChangedListener(textWatcher);
    final TextView descriptionEdit = (TextView) rootView.findViewById(R.id.task_description_edit);
    descriptionEdit.addTextChangedListener(textWatcher);

    final TextView dueDateView = (TextView) rootView.findViewById(R.id.due_date_text);
    final DatePicker datePicker = (DatePicker) rootView.findViewById(R.id.due_date_calendar);
    datePicker.init(0, 0, 0, new DatePicker.OnDateChangedListener() {
        @Override
        public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(year, monthOfYear, dayOfMonth, 0, 0, 0);
            SetFriendlyDueDateText(dueDateView, calendar);
            TaskChanged(activityView);
        }
    });

    Button todayButton = (Button) rootView.findViewById(R.id.today_button);
    todayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar now = Calendar.getInstance();
            datePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
                    now.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, now);
        }
    });
    Button plusDayButton = (Button) rootView.findViewById(R.id.plus_day_button);
    plusDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
            calendar.add(Calendar.DATE, 1);
            datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, calendar);
        }
    });
    Button thisWeekendButton = (Button) rootView.findViewById(R.id.this_weekend_button);
    thisWeekendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar weekend = Calendar.getInstance();
            while (weekend.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
                weekend.add(Calendar.DATE, 1);
            }
            datePicker.updateDate(weekend.get(Calendar.YEAR), weekend.get(Calendar.MONTH),
                    weekend.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, weekend);
        }
    });
    Button plusWeekButton = (Button) rootView.findViewById(R.id.plus_week_button);
    plusWeekButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
            calendar.add(Calendar.DATE, 7);
            datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, calendar);
        }
    });

    final CheckBox repeatCheck = (CheckBox) rootView.findViewById(R.id.repeat);
    repeatCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            View dialog = (View) buttonView.getParent();
            SetRepeatVisibility(dialog, isChecked);
            TaskChanged(activityView);
        }
    });

    final EditText repeatTimeEdit = (EditText) rootView.findViewById(R.id.repeat_time);
    repeatTimeEdit.addTextChangedListener(textWatcher);

    final Spinner repeatUnitSpinner = (Spinner) rootView.findViewById(R.id.repeat_unit);
    String[] repeatUnits = { "Days", "Weeks", "Months", "Years" };
    repeatUnitSpinner.setAdapter(
            new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, repeatUnits));
    repeatUnitSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (mRow != -1 && mRow != id) {
                TaskChanged(activityView);
            }
            mRow = id;
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            TaskChanged(activityView);
        }

        private long mRow = -1;
    });

    final RadioButton repeatFromComplete = (RadioButton) rootView.findViewById(R.id.repeat_from_complete);
    final RadioButton repeatFromDue = (RadioButton) rootView.findViewById(R.id.repeat_from_due);
    Button revertButton = (Button) rootView.findViewById(R.id.revert_button);
    Button acceptButton = (Button) rootView.findViewById(R.id.accept_button);
    final Button doneButton = (Button) rootView.findViewById(R.id.done_button);
    Button deleteButton = (Button) rootView.findViewById(R.id.delete_button);
    revertButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNewTask = new Task(mOriginalTask);
            mProgrammaticChange = true;
            InitializeViewFields(activityView, mOriginalTask);
            mProgrammaticChange = false;
            TaskReverted(activityView);
        }
    });
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(doneButton.getContext());
            builder.setTitle("Done?");
            builder.setMessage("Mark task \"" + mNewTask.mName + "\" as done?");
            builder.setNegativeButton("No", null);
            builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mNewTask.Done();
                    TaskDatabase db = new TaskDatabase(getActivity());
                    db.SaveTask(mNewTask);
                    InitializeViewFields(rootView, mNewTask);
                }
            });
            builder.show();
        }
    });
}

From source file:com.kunze.androidlocaltodo.TaskListActivity.java

private void ShowDueDateDialog(Calendar dueDate, OnClickListener okListener) {
    LayoutInflater inflater = this.getLayoutInflater();
    View dlgView = inflater.inflate(R.layout.dialog_due_date, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setView(dlgView);//from   w w w.  ja va2  s  .  co m
    builder.setTitle("Due Date");
    builder.setNegativeButton("Cancel", null);
    builder.setPositiveButton("OK", okListener);

    final TextView dateText = (TextView) dlgView.findViewById(R.id.due_date_text);
    SetFriendlyDueDateText(dateText, dueDate);

    final DatePicker datePicker = (DatePicker) dlgView.findViewById(R.id.due_date_calendar);
    //datePicker.setMinDate(Math.min(now.getTimeInMillis(), dueDate.getTimeInMillis()));
    datePicker.init(dueDate.get(Calendar.YEAR), dueDate.get(Calendar.MONTH), dueDate.get(Calendar.DAY_OF_MONTH),
            new DatePicker.OnDateChangedListener() {
                @Override
                public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.set(year, monthOfYear, dayOfMonth, 0, 0, 0);
                    SetFriendlyDueDateText(dateText, calendar);

                }
            });
    datePicker.setCalendarViewShown(false);

    Button todayButton = (Button) dlgView.findViewById(R.id.today_button);
    todayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar now = Calendar.getInstance();
            datePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
                    now.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dateText, now);
        }
    });
    Button plusDayButton = (Button) dlgView.findViewById(R.id.plus_day_button);
    plusDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
            calendar.add(Calendar.DATE, 1);
            datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dateText, calendar);
        }
    });
    Button thisWeekendButton = (Button) dlgView.findViewById(R.id.this_weekend_button);
    thisWeekendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar weekend = Calendar.getInstance();
            while (weekend.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
                weekend.add(Calendar.DATE, 1);
            }
            datePicker.updateDate(weekend.get(Calendar.YEAR), weekend.get(Calendar.MONTH),
                    weekend.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dateText, weekend);
        }
    });
    Button plusWeekButton = (Button) dlgView.findViewById(R.id.plus_week_button);
    plusWeekButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
            calendar.add(Calendar.DATE, 7);
            datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dateText, calendar);
        }
    });

    builder.show();
}

From source file:com.instiwork.RegistrationFacebookActivity.java

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

    pDialogOut = new ProgressDialog(RegistrationFacebookActivity.this);
    pDialogOut.setMessage("Signing up...");

    appSharedPref = getSharedPreferences("INSTIWORD", Context.MODE_PRIVATE);

    Picasso.with(getApplicationContext()).load(R.drawable.registrationbg).fit().centerCrop()
            .into((ImageView) findViewById(R.id.regbg));

    dateOfBirth = (TextView) findViewById(R.id.dateofbirth);
    license = (RobotoLight) findViewById(R.id.license);
    ll_license = (LinearLayout) findViewById(R.id.ll_license);
    selecteddata = (RecyclerView) findViewById(R.id.selecteddat);
    selecteddata.setVisibility(View.GONE);
    gender = (RadioGroup) findViewById(R.id.gender_group);
    maleRadio = (RadioButton) findViewById(R.id.malehit);
    femaleRadio = (RadioButton) findViewById(R.id.frmalrhit);
    fstName = (EditText) findViewById(R.id.first_name);
    companyName = (EditText) findViewById(R.id.company_name);
    email = (EditText) findViewById(R.id.email);
    mobile = (EditText) findViewById(R.id.mobile);

    countryPbar = (ProgressBar) findViewById(R.id.countryPbar);
    country_spinner = (Spinner) findViewById(R.id.country_spinner);
    countryPbar.setVisibility(View.VISIBLE);
    country_spinner.setVisibility(View.GONE);
    txt_terms_conditions = (RobotoBold) findViewById(R.id.txt_terms_conditions);

    ll_image_selection = (LinearLayout) findViewById(R.id.ll_image_selection);
    pro_img = (ImageView) findViewById(R.id.pro_img);

    ll_image_selection.setOnClickListener(new View.OnClickListener() {
        @Override//from ww  w.  j  a va 2s .com
        public void onClick(View v) {
            Intent i = new Intent(RegistrationFacebookActivity.this, ImageTakerActivityCamera.class);
            startActivityForResult(i, 1);
        }
    });

    try {

        if (getIntent().getStringExtra("FB_NAME").equalsIgnoreCase("")) {
            fstName.setText("");
            fstName.setClickable(true);
            fstName.setEnabled(true);
        } else {
            fstName.setText(getIntent().getStringExtra("FB_NAME"));
            fstName.setClickable(false);
            fstName.setEnabled(false);
        }
        if (getIntent().getStringExtra("FB_EMAIL").equalsIgnoreCase("")) {
            email.setText("");
            email.setClickable(true);
            email.setEnabled(true);
        } else {
            email.setText(getIntent().getStringExtra("FB_EMAIL"));
            email.setClickable(false);
            email.setEnabled(false);
        }
        //            if (getIntent().getStringExtra("FB_BIRTHDAY").equalsIgnoreCase("")) {
        //                dateOfBirth.setText(dob);
        //                dateOfBirth.setClickable(true);
        //            } else {
        //                dateOfBirth.setText(getIntent().getStringExtra("FB_BIRTHDAY"));
        //                dateOfBirth.setClickable(false);
        //            }
        if (getIntent().getStringExtra("FB_GENDER").equalsIgnoreCase("")) {
            gender.setClickable(true);
            maleRadio.setClickable(true);
            femaleRadio.setClickable(true);
        } else {
            gender.setClickable(false);
            maleRadio.setClickable(false);
            femaleRadio.setClickable(false);
            if (getIntent().getStringExtra("FB_GENDER").equalsIgnoreCase("male")) {
                genderData = "" + 1;
                maleRadio.setChecked(true);
                femaleRadio.setChecked(false);
            } else if (getIntent().getStringExtra("FB_GENDER").equalsIgnoreCase("female")) {
                genderData = "" + 2;
                maleRadio.setChecked(false);
                femaleRadio.setChecked(true);
            }
        }
        if (getIntent().getStringExtra("FB_IMG").equalsIgnoreCase("")) {
            ll_image_selection.setClickable(true);
        } else {
            ll_image_selection.setClickable(false);
            imgPath = getIntent().getStringExtra("FB_IMG");
            Picasso.with(RegistrationFacebookActivity.this).load(getIntent().getStringExtra("FB_IMG"))
                    .transform(new CornerMoldTransformation(24, 0, CornerMoldTransformation.CornerType.ALL))
                    .fit().centerCrop().placeholder(R.mipmap.ic_launcher).fit().centerCrop().into(pro_img);
        }

    } catch (Exception e) {
        Logger.showMessage(TAG, "Data Exception : " + e.toString());
    }

    txt_terms_conditions.setText(Html.fromHtml("<u>Terms and Condition</u>"));
    txt_terms_conditions.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialogTermsUse();
        }
    });

    findViewById(R.id.help_dob).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder(
                    RegistrationFacebookActivity.this);
            alertDialogBuilder.setTitle("Date of Birth");
            alertDialogBuilder
                    .setMessage("We require date of birth to verify that no minors are bidding on the jobs.")
                    .setCancelable(false).setPositiveButton("ok", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
            android.app.AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        }
    });

    findViewById(R.id.help_license).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder(
                    RegistrationFacebookActivity.this);
            alertDialogBuilder.setTitle("License");
            alertDialogBuilder
                    .setMessage("Please select if you have any work licenses like electrician, plumber, etc...")
                    .setCancelable(false).setPositiveButton("ok", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
            android.app.AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        }
    });

    country_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            try {
                country_2_code = objectsCountry.get(position).getString("country_2_code");
                country_id = objectsCountry.get(position).getString("country_id");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    ll_license.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(RegistrationFacebookActivity.this, LicenseActivity.class);
            startActivityForResult(i, 420);
        }
    });

    dateOfBirth.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Calendar today = Calendar.getInstance();
            //                today.add(Calendar.YEAR, -14);

            View dialoglayout = LayoutInflater.from(getApplicationContext())
                    .inflate(R.layout.dialog_date_picker, null);
            final DatePicker dPicker = (DatePicker) dialoglayout.findViewById(R.id.date_picker);

            dPicker.setMaxDate(today.getTimeInMillis()); // set DatePicker MAX Date
            today.set(dPicker.getYear(), dPicker.getMonth() + 1, dPicker.getDayOfMonth());
            today.add(Calendar.YEAR, -14);
            dPicker.updateDate(today.get(Calendar.YEAR), today.get(Calendar.MONTH) - 1,
                    today.get(Calendar.DATE));

            AlertDialog.Builder builder = new AlertDialog.Builder(RegistrationFacebookActivity.this);
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    //                        dateOfBirth.setText("" + dPicker.getDayOfMonth() + "/" + (dPicker.getMonth() + 1) + "/" + dPicker.getYear());
                    try {
                        SimpleDateFormat changeFormat = new SimpleDateFormat("MM/dd/yyyy");
                        Calendar newDate = Calendar.getInstance();
                        newDate.set(dPicker.getYear(), dPicker.getMonth(), dPicker.getDayOfMonth());
                        dateOfBirth.setText(changeFormat.format(newDate.getTime()));
                        Logger.showMessage("DOBBBBB : ", changeFormat.format(newDate.getTime()));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dateOfBirth.setText(dob);
                }
            });
            builder.setView(dialoglayout);
            builder.show();
        }
    });

    gender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            int selectedId = gender.getCheckedRadioButtonId();
            if (selectedId == maleRadio.getId()) {
                genderData = "" + 1;
            } else if (selectedId == femaleRadio.getId()) {
                genderData = "" + 2;
            } else {
                genderData = "";
            }

        }
    });

    findViewById(R.id.loginBttn).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            license_ = "";
            if (fstName.getText().toString().trim().equalsIgnoreCase("")) {
                fstName.setError("Please enter name.");
                fstName.requestFocus();
            } else {
                if (email.getText().toString().trim().equalsIgnoreCase("")) {
                    email.setError("Please enter email.");
                    email.requestFocus();
                } else {
                    if (android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim())
                            .matches()) {
                        if (!android.util.Patterns.PHONE.matcher(mobile.getText().toString().trim())
                                .matches()) {
                            mobile.setError("Please enter valid mobile number.");
                            mobile.requestFocus();
                        } else {
                            if (dateOfBirth.getText().toString().trim().equalsIgnoreCase("Birth date")) {
                                Snackbar.make(findViewById(android.R.id.content), "Please select date of birth",
                                        Snackbar.LENGTH_LONG).setActionTextColor(Color.RED).show();
                            } else {
                                if (isValidDOB(dateOfBirth.getText().toString().trim())) {
                                    if (country_2_code.equalsIgnoreCase("0")) {
                                        Snackbar.make(findViewById(android.R.id.content),
                                                "Select Country From List", Snackbar.LENGTH_LONG)
                                                .setActionTextColor(Color.RED).show();
                                    } else {
                                        if (InstiworkApplication.getInstance()
                                                .getSelectedLicenseArray() != null) {
                                            for (int i = 0; i < InstiworkApplication.getInstance()
                                                    .getSelectedLicenseArray().size(); i++) {
                                                try {
                                                    if (i == 0) {
                                                        license_ = license_ + InstiworkApplication.getInstance()
                                                                .getSelectedLicenseArray().get(i)
                                                                .getString("id");
                                                    } else {
                                                        license_ = license_ + ","
                                                                + InstiworkApplication.getInstance()
                                                                        .getSelectedLicenseArray().get(i)
                                                                        .getString("id");
                                                    }
                                                } catch (Exception e) {
                                                    e.printStackTrace();
                                                }
                                            }
                                        }
                                        if (((CheckBox) findViewById(R.id.trmscondi)).isChecked()) {
                                            try {
                                                gcmToken = appSharedPref.getString("GCM_TOKEN", "");
                                                String date[] = dateOfBirth.getText().toString().trim()
                                                        .split("/");

                                                final String URL = InstiworkConstants.URL_DOMAIN
                                                        + "Login_ios/facebooksignup?name="
                                                        + URLEncoder.encode(
                                                                fstName.getText().toString().trim(), "UTF-8")
                                                        + "&companyname="
                                                        + URLEncoder.encode(
                                                                companyName.getText().toString().trim(),
                                                                "UTF-8")
                                                        + "&email="
                                                        + URLEncoder.encode(email.getText().toString().trim(),
                                                                "UTF-8")
                                                        + "&gender=" + genderData + "&year=" + date[2]
                                                        + "&month=" + date[0] + "&date=" + date[1] + "&license="
                                                        + license_ + "&facebook_id="
                                                        + getIntent().getStringExtra("FB_ID")
                                                        + "&facebook_token="
                                                        + getIntent().getStringExtra("FB_ACCESS_TOKEN")
                                                        + "&devicetoken="
                                                        + getIntent().getStringExtra("FB_DEVICE_TOKEN")
                                                        + "&devicetype=2" + "&contact="
                                                        + URLEncoder.encode(mobile.getText().toString().trim(),
                                                                "UTF-8")
                                                        + "&image=" + getIntent().getStringExtra("FB_IMG")
                                                        + "&lat=" + LOCATION_LATITUDE + "&lng="
                                                        + LOCATION_LONGITUDE + "&country2_code="
                                                        + country_2_code + "&country_id=" + country_id;
                                                Logger.showMessage(TAG, "FBREG  " + URL);

                                                pDialogOut.show();

                                                txt_terms_conditions.setClickable(false);
                                                findViewById(R.id.help_dob).setClickable(false);
                                                findViewById(R.id.help_license).setClickable(false);
                                                ll_license.setClickable(false);
                                                dateOfBirth.setClickable(false);
                                                findViewById(R.id.footer).setClickable(false);
                                                findViewById(R.id.loginBttn).setClickable(false);

                                                txt_terms_conditions.setEnabled(false);
                                                findViewById(R.id.help_dob).setEnabled(false);
                                                findViewById(R.id.help_license).setEnabled(false);
                                                ll_license.setEnabled(false);
                                                dateOfBirth.setEnabled(false);
                                                findViewById(R.id.footer).setEnabled(false);
                                                findViewById(R.id.loginBttn).setEnabled(false);

                                                login_User(URL);
                                            } catch (Exception e) {
                                                e.printStackTrace();
                                            }
                                        } else {
                                            Snackbar.make(findViewById(android.R.id.content),
                                                    "Please agree to Terms And Conditions.",
                                                    Snackbar.LENGTH_LONG).setActionTextColor(Color.RED).show();
                                        }
                                    }
                                } else {
                                    Snackbar.make(findViewById(android.R.id.content),
                                            "You are under 14 years old.", Snackbar.LENGTH_LONG)
                                            .setActionTextColor(Color.RED).show();
                                }
                            }
                        }
                    } else {
                        email.setError("Please enter valid email.");
                        email.requestFocus();
                    }
                }
            }
        }
    });

    findViewById(R.id.footer).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    buildGoogleApiClient();
    if (gMapOption == null) {
        gMapOption = new GoogleMapOptions();
        gMapOption.ambientEnabled(true);
        gMapOption.compassEnabled(true);
    }
}

From source file:com.instiwork.RegistrationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);
    callbackManager = CallbackManager.Factory.create();

    pDialogOut = new ProgressDialog(RegistrationActivity.this);
    pDialogOut.setMessage("Signing up...");
    pDialogOut.setCancelable(false);//from w  w w.  j a v a2s .  c o  m
    pDialogOut.setCanceledOnTouchOutside(false);

    appSharedPref = getSharedPreferences("INSTIWORD", Context.MODE_PRIVATE);

    Picasso.with(getApplicationContext()).load(R.drawable.registrationbg).fit().centerCrop()
            .into((ImageView) findViewById(R.id.regbg));

    dateOfBirth = (TextView) findViewById(R.id.dateofbirth);
    license = (RobotoLight) findViewById(R.id.license);
    ll_license = (LinearLayout) findViewById(R.id.ll_license);
    selecteddata = (RecyclerView) findViewById(R.id.selecteddat);
    selecteddata.setVisibility(View.GONE);
    gender = (RadioGroup) findViewById(R.id.gender_group);

    fstName = (EditText) findViewById(R.id.first_name);
    lastname = (EditText) findViewById(R.id.last_name);
    email = (EditText) findViewById(R.id.email);
    email_confirm = (EditText) findViewById(R.id.email_confirm);
    password = (EditText) findViewById(R.id.password);
    conformPassword = (EditText) findViewById(R.id.con_password);
    mobile = (EditText) findViewById(R.id.mobile);

    ll_image_selection = (LinearLayout) findViewById(R.id.ll_image_selection);
    pro_img = (ImageView) findViewById(R.id.pro_img);

    countryPbar = (ProgressBar) findViewById(R.id.countryPbar);
    country_spinner = (Spinner) findViewById(R.id.country_spinner);
    countryPbar.setVisibility(View.VISIBLE);
    country_spinner.setVisibility(View.GONE);

    txt_terms_conditions = (RobotoBold) findViewById(R.id.txt_terms_conditions);

    country_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            try {
                country_2_code = objectsCountry.get(position).getString("country_2_code");
                country_id = objectsCountry.get(position).getString("country_id");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    ll_image_selection.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(RegistrationActivity.this, ImageTakerActivityCamera.class);
            startActivityForResult(i, 1);
        }
    });

    txt_terms_conditions.setText(Html.fromHtml("<u>Terms and Condition</u>"));
    txt_terms_conditions.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialogTermsUse();
        }
    });

    findViewById(R.id.footer).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    findViewById(R.id.help_password).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder(
                    RegistrationActivity.this);
            alertDialogBuilder.setTitle("Password Requirements");
            alertDialogBuilder.setMessage(
                    "Please Ensure that Password should have at least 6 characters (Maximum 20) long and it contains at least one lowercase letter, one uppercase letter, one number and one special character.")
                    .setCancelable(false).setPositiveButton("ok", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
            android.app.AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        }
    });

    findViewById(R.id.help_dob).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder(
                    RegistrationActivity.this);
            alertDialogBuilder.setTitle("Date of Birth");
            alertDialogBuilder
                    .setMessage("We require date of birth to verify that no minors are bidding on the jobs.")
                    .setCancelable(false).setPositiveButton("ok", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
            android.app.AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        }
    });
    findViewById(R.id.help_license).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder(
                    RegistrationActivity.this);
            alertDialogBuilder.setTitle("License");
            alertDialogBuilder
                    .setMessage("Please select if you have any work licenses like electrician, plumber, etc...")
                    .setCancelable(false).setPositiveButton("ok", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
            android.app.AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        }
    });

    gender.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            //Logger.showMessage("Geder : ", "" + checkedId);
            if (("" + checkedId).equalsIgnoreCase("2131558563")) {//female
                genderData = "" + 2;
            } else {
                genderData = "" + 1;
            }
        }
    });

    ll_license.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(RegistrationActivity.this, LicenseActivity.class);
            startActivityForResult(i, 420);
        }
    });

    findViewById(R.id.loginBttn).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            license_ = "";
            if (fstName.getText().toString().trim().equalsIgnoreCase("")) {
                fstName.setError("Please enter name.");
                fstName.requestFocus();
            } else {
                if (email.getText().toString().trim().equalsIgnoreCase("")) {
                    email.setError("Please enter email.");
                    email.requestFocus();
                } else {
                    if (android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim())
                            .matches()) {
                        if (email_confirm.getText().toString().trim().equalsIgnoreCase("")) {
                            email_confirm.setError("Please enter email again.");
                            email_confirm.requestFocus();
                        } else {
                            if (android.util.Patterns.EMAIL_ADDRESS
                                    .matcher(email_confirm.getText().toString().trim()).matches()) {
                                if (email.getText().toString().trim()
                                        .equalsIgnoreCase(email_confirm.getText().toString().trim())) {
                                    if (!android.util.Patterns.PHONE.matcher(mobile.getText().toString().trim())
                                            .matches()) {
                                        mobile.setError("Please enter valid mobile number.");
                                        mobile.requestFocus();
                                    } else {
                                        //                                            if (password.getText().toString().trim().equalsIgnoreCase("")) {
                                        if (!isValidPassword(password.getText().toString().trim())) {
                                            password.setError(
                                                    "Please Ensure that Password should have at least 6 characters (Maximum 20) long and it contains at least one lowercase letter, one uppercase letter, one number and one special character.");
                                            password.requestFocus();
                                        } else {
                                            if (conformPassword.getText().toString().trim()
                                                    .equalsIgnoreCase("")) {
                                                conformPassword.setError("Please enter password again.");
                                                conformPassword.requestFocus();
                                            } else {
                                                if (conformPassword.getText().toString().trim()
                                                        .equals(password.getText().toString().trim())) {
                                                    if (dateOfBirth.getText().toString().trim()
                                                            .equalsIgnoreCase("Birth date")) {
                                                        Snackbar.make(findViewById(android.R.id.content),
                                                                "Please select date of birth",
                                                                Snackbar.LENGTH_LONG)
                                                                .setActionTextColor(Color.RED).show();
                                                    } else {
                                                        if (isValidDOB(
                                                                dateOfBirth.getText().toString().trim())) {
                                                            if (country_2_code.equalsIgnoreCase("0")) {
                                                                Snackbar.make(
                                                                        findViewById(android.R.id.content),
                                                                        "Select Country From List",
                                                                        Snackbar.LENGTH_LONG)
                                                                        .setActionTextColor(Color.RED).show();
                                                            } else {
                                                                if (InstiworkApplication.getInstance()
                                                                        .getSelectedLicenseArray() != null) {
                                                                    for (int i = 0; i < InstiworkApplication
                                                                            .getInstance()
                                                                            .getSelectedLicenseArray()
                                                                            .size(); i++) {
                                                                        try {
                                                                            if (i == 0) {
                                                                                license_ = license_
                                                                                        + InstiworkApplication
                                                                                                .getInstance()
                                                                                                .getSelectedLicenseArray()
                                                                                                .get(i)
                                                                                                .getString(
                                                                                                        "id");
                                                                            } else {
                                                                                license_ = license_ + ","
                                                                                        + InstiworkApplication
                                                                                                .getInstance()
                                                                                                .getSelectedLicenseArray()
                                                                                                .get(i)
                                                                                                .getString(
                                                                                                        "id");
                                                                            }
                                                                        } catch (Exception e) {
                                                                            e.printStackTrace();
                                                                        }
                                                                    }
                                                                }
                                                                if (((CheckBox) findViewById(R.id.trmscondi))
                                                                        .isChecked()) {

                                                                    ll_image_selection.setEnabled(false);
                                                                    txt_terms_conditions.setEnabled(false);
                                                                    findViewById(R.id.footer).setEnabled(false);
                                                                    findViewById(R.id.help_password)
                                                                            .setEnabled(false);
                                                                    findViewById(R.id.help_dob)
                                                                            .setEnabled(false);
                                                                    findViewById(R.id.help_license)
                                                                            .setEnabled(false);

                                                                    ll_license.setEnabled(false);
                                                                    findViewById(R.id.loginBttn)
                                                                            .setEnabled(false);
                                                                    findViewById(R.id.fb_log).setEnabled(false);
                                                                    dateOfBirth.setEnabled(false);
                                                                    ll_image_selection.setClickable(false);
                                                                    txt_terms_conditions.setClickable(false);
                                                                    findViewById(R.id.footer)
                                                                            .setClickable(false);
                                                                    findViewById(R.id.help_password)
                                                                            .setClickable(false);
                                                                    findViewById(R.id.help_dob)
                                                                            .setClickable(false);
                                                                    findViewById(R.id.help_license)
                                                                            .setClickable(false);

                                                                    ll_license.setClickable(false);
                                                                    findViewById(R.id.loginBttn)
                                                                            .setClickable(false);
                                                                    findViewById(R.id.fb_log)
                                                                            .setClickable(false);
                                                                    dateOfBirth.setClickable(false);

                                                                    try {
                                                                        if (appSharedPref
                                                                                .getString("GCM_TOKEN", "")
                                                                                .equalsIgnoreCase("")) {
                                                                            String date[] = dateOfBirth
                                                                                    .getText().toString().trim()
                                                                                    .split("/");
                                                                            final String URL = InstiworkConstants.URL_DOMAIN
                                                                                    + "Signup_ios?name="
                                                                                    + URLEncoder.encode(
                                                                                            fstName.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&contact="
                                                                                    + URLEncoder.encode(
                                                                                            mobile.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&companyname="
                                                                                    + URLEncoder.encode(
                                                                                            lastname.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&email="
                                                                                    + URLEncoder.encode(
                                                                                            email.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&password="
                                                                                    + URLEncoder.encode(
                                                                                            password.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&gender=" + genderData
                                                                                    + "&year=" + date[2]
                                                                                    + "&month=" + date[0]
                                                                                    + "&date=" + date[1]
                                                                                    + "&license="
                                                                                    + URLEncoder.encode(
                                                                                            license_, "UTF-8")
                                                                                    + "&device_type=2" + "&lat="
                                                                                    + LOCATION_LATITUDE
                                                                                    + "&lng="
                                                                                    + LOCATION_LONGITUDE
                                                                                    + "&country2_code="
                                                                                    + country_2_code
                                                                                    + "&country_id="
                                                                                    + country_id
                                                                                    + "&device_token=";
                                                                            (new RegistrationGCM(URL))
                                                                                    .executeOnExecutor(
                                                                                            AsyncTask.THREAD_POOL_EXECUTOR);
                                                                        } else {
                                                                            gcmToken = appSharedPref
                                                                                    .getString("GCM_TOKEN", "");
                                                                            String date[] = dateOfBirth
                                                                                    .getText().toString().trim()
                                                                                    .split("/");
                                                                            final String URL = InstiworkConstants.URL_DOMAIN
                                                                                    + "Signup_ios?name="
                                                                                    + URLEncoder.encode(
                                                                                            fstName.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&contact="
                                                                                    + URLEncoder.encode(
                                                                                            mobile.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&companyname="
                                                                                    + URLEncoder.encode(
                                                                                            lastname.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&email="
                                                                                    + URLEncoder.encode(
                                                                                            email.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&password="
                                                                                    + URLEncoder.encode(
                                                                                            password.getText()
                                                                                                    .toString()
                                                                                                    .trim(),
                                                                                            "UTF-8")
                                                                                    + "&gender=" + genderData
                                                                                    + "&year=" + date[2]
                                                                                    + "&month=" + date[0]
                                                                                    + "&date=" + date[1]
                                                                                    + "&license=" + license_
                                                                                    + "&device_type=2&device_token="
                                                                                    + URLEncoder.encode(
                                                                                            gcmToken, "UTF-8")
                                                                                    + "&lat="
                                                                                    + LOCATION_LATITUDE
                                                                                    + "&lng="
                                                                                    + LOCATION_LONGITUDE
                                                                                    + "&country2_code="
                                                                                    + country_2_code
                                                                                    + "&country_id="
                                                                                    + country_id;
                                                                            //
                                                                            login_User(URL);
                                                                        }
                                                                    } catch (Exception e) {
                                                                        e.printStackTrace();
                                                                    }
                                                                } else {
                                                                    Snackbar.make(
                                                                            findViewById(android.R.id.content),
                                                                            "Please agree to Terms And Conditions.",
                                                                            Snackbar.LENGTH_LONG)
                                                                            .setActionTextColor(Color.RED)
                                                                            .show();
                                                                }
                                                            }
                                                        } else {
                                                            Snackbar.make(findViewById(android.R.id.content),
                                                                    "You are under 14 years old.",
                                                                    Snackbar.LENGTH_LONG)
                                                                    .setActionTextColor(Color.RED).show(); //soutrik
                                                        }
                                                    }
                                                } else {
                                                    conformPassword.setError(
                                                            "Password amd confirm password should be same.");
                                                    conformPassword.requestFocus();
                                                }
                                            }
                                        }
                                    }
                                } else {
                                    email_confirm.setError("Email amd confirm email should be same.");
                                    email_confirm.requestFocus();
                                }
                            } else {
                                email_confirm.setError("Please enter valid email.");
                                email_confirm.requestFocus();
                            }
                        }
                    } else {
                        email.setError("Please enter valid email.");
                        email.requestFocus();
                    }
                }
            }
        }
    });

    findViewById(R.id.fb_log).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (appSharedPref.getString("GCM_TOKEN", "").equalsIgnoreCase("")) {
                (new RegistrationGCMFB()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            } else {
                gcmToken = appSharedPref.getString("GCM_TOKEN", "");
                LoginManager.getInstance().logInWithReadPermissions(RegistrationActivity.this,
                        Arrays.asList("public_profile", "email"));
            }
        }
    });

    //---------Facebook
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            // App code
            fbAccessToken = loginResult.getAccessToken().getToken();
            GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback() {
                        @Override
                        public void onCompleted(JSONObject object, GraphResponse response) {
                            //                                        Log.i("FBRESULT", object.toString());
                            pDialogOut.setMessage("Authenticate Facebook User.");
                            pDialogOut.show();
                            try {
                                final String URL = InstiworkConstants.URL_DOMAIN
                                        + "Login_ios/checkfacebooksignup?facebook_id=" + object.getString("id")
                                        + "&device_token=" + URLEncoder.encode(gcmToken, "UTF-8")
                                        + "&device_type=2";
                                FB_ChkUser(URL, object);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
            Bundle parameters = new Bundle();
            parameters.putString("fields", "id,name,email,birthday,first_name,last_name,gender");
            request.setParameters(parameters);
            request.executeAsync();
        }

        @Override
        public void onCancel() {
            // App code
            pDialogOut.dismiss();
        }

        @Override
        public void onError(FacebookException exception) {
            // App code
            pDialogOut.dismiss();
            if (exception instanceof FacebookAuthorizationException) {
                if (AccessToken.getCurrentAccessToken() != null) {
                    LoginManager.getInstance().logOut();
                    LoginManager.getInstance().logInWithReadPermissions(RegistrationActivity.this,
                            Arrays.asList("public_profile", "email"));
                } else {
                    //                                Toast.makeText(RegistrationActivity.this, "Facebook Exception : " + exception.toString(), Toast.LENGTH_SHORT).show();
                }
            } else {
                //                            Toast.makeText(RegistrationActivity.this, "Facebook Exception : " + exception.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    dateOfBirth.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {//soutrik

            Calendar today = Calendar.getInstance();

            View dialoglayout = LayoutInflater.from(getApplicationContext())
                    .inflate(R.layout.dialog_date_picker, null);
            final DatePicker dPicker = (DatePicker) dialoglayout.findViewById(R.id.date_picker);

            dPicker.setMaxDate(today.getTimeInMillis()); // set DatePicker MAX Date
            today.set(dPicker.getYear(), dPicker.getMonth() + 1, dPicker.getDayOfMonth());
            today.add(Calendar.YEAR, -14);
            dPicker.updateDate(today.get(Calendar.YEAR), today.get(Calendar.MONTH) - 1,
                    today.get(Calendar.DATE));

            AlertDialog.Builder builder = new AlertDialog.Builder(RegistrationActivity.this);
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    try {
                        SimpleDateFormat changeFormat = new SimpleDateFormat("MM/dd/yyyy");
                        Calendar newDate = Calendar.getInstance();
                        newDate.set(dPicker.getYear(), dPicker.getMonth(), dPicker.getDayOfMonth());
                        dateOfBirth.setText(changeFormat.format(newDate.getTime()));
                        Logger.showMessage("DOBBBBB : ", changeFormat.format(newDate.getTime()));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dateOfBirth.setText("Birth date");
                }
            });
            builder.setView(dialoglayout);
            builder.show();
        }
    });

    //        getCountryList();
    buildGoogleApiClient();
    if (gMapOption == null) {
        gMapOption = new GoogleMapOptions();
        gMapOption.ambientEnabled(true);
        gMapOption.compassEnabled(true);
    }
}