Example usage for android.widget DatePicker getYear

List of usage examples for android.widget DatePicker getYear

Introduction

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

Prototype

public int getYear() 

Source Link

Usage

From source file:com.pgmacdesign.rsrtoolbox.InputSchedule.java

public void CreateEvent(String title, String address, String description, DatePicker dp) {
    //First run method that calculates all end times
    GetEndTimes();/*ww w  . j  a  v a 2s  .  c  om*/

    //Create an intent that will enter data into the calendar
    Intent calIntent = new Intent(Intent.ACTION_INSERT);
    calIntent.setType("vnd.android.cursor.item/event");

    //Put information in
    calIntent.putExtra(Events.TITLE, title);
    calIntent.putExtra(Events.EVENT_LOCATION, address);
    calIntent.putExtra(Events.DESCRIPTION, description);

    //Start and End Timing
    Calendar startTime = Calendar.getInstance();
    Calendar endTime = Calendar.getInstance();
    //Format: startTime.set(year, month, day, hourOfDay, minute)
    startTime.set(dp.getYear(), dp.getMonth(), dp.getDayOfMonth(), daily_hour_start, daily_min_start);
    endTime.set(dp.getYear(), dp.getMonth(), dp.getDayOfMonth(), daily_hour_end, daily_min_end);

    //Put the calculated start and end time into the calIntent Intent
    calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime.getTimeInMillis());
    calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis());

    //Puts event into calendar
    startActivity(calIntent);
}

From source file:com.medisa.myspacecal.MainActivity.java

@Override
public void onSideNavigationItemClick(int itemId) {
    switch (itemId) {
    case R.id.side_navigation_menu_calendario:
        range = 0;//  w  w w  . ja  va 2 s.co  m
        Intent i = new Intent(this, MainActivity.class);
        startActivity(i);
        break;
    case R.id.side_navigation_menu_date_range:
        // custom dialog
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.custom_range_date);
        dialog.setTitle("Data range");

        // set the custom dialog components - text, image and button
        final DatePicker dpStart = (DatePicker) dialog.findViewById(R.id.dpStart);
        final DatePicker dpEnd = (DatePicker) dialog.findViewById(R.id.dpEnd);
        Button btnSalva = (Button) dialog.findViewById(R.id.btnSalva);
        final CheckBox cbIntegralBox = (CheckBox) dialog.findViewById(R.id.cbIntegral);
        // if button is clicked, close the custom dialog
        btnSalva.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dateStart = Funzioni.addZero(dpStart.getDayOfMonth(), 2) + "-"
                        + Funzioni.addZero(dpStart.getMonth() + 1, 2) + "-" + dpStart.getYear();
                dateEnd = Funzioni.addZero(dpEnd.getDayOfMonth(), 2) + "-"
                        + Funzioni.addZero(dpEnd.getMonth() + 1, 2) + "-" + dpEnd.getYear();
                Log.e(dateStart, dateEnd);
                if (cbIntegralBox.isChecked()) {
                    //#########################JSON
                    AsyncHttpClient client = new AsyncHttpClient();
                    client.get("http://199.180.196.10/json/integral?startdate=" + dateStart + "&enddate="
                            + dateEnd, new AsyncHttpResponseHandler() {
                                @Override
                                public void onSuccess(String response) {
                                    Log.e("SCARICATO", response + "");
                                    JSONArray jObject;
                                    satellitiIntegral = new ArrayList<SatelliteIntegral>();
                                    try {
                                        jObject = new JSONArray(response);
                                        for (int i = 0; i < jObject.length(); i++) {
                                            JSONArray menuObject = jObject.getJSONArray(i);
                                            String dataStart = menuObject.getString(0);
                                            String dataEnd = menuObject.getString(1);
                                            String raj2000 = menuObject.getString(2);
                                            String decj2000 = menuObject.getString(3);
                                            String target = menuObject.getString(4);
                                            Log.e("", dataStart + " " + dataEnd + " " + raj2000 + " " + decj2000
                                                    + " " + target);
                                            satellitiIntegral.add(new SatelliteIntegral(dataStart, dataEnd,
                                                    raj2000, decj2000, target));
                                        }
                                        adapter = new GridCellAdapter(getApplicationContext(),
                                                R.id.day_gridcell, month, year);
                                        adapter.notifyDataSetChanged();
                                        calendarView.setAdapter(adapter);

                                    } catch (JSONException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                    }
                                }
                            });
                }

                dialog.dismiss();
                //###############################################
                //                   Intent mioIntent= new Intent(ctx, MainActivity.class);
                //                   startActivity(mioIntent);
            }

        });
        dialog.show();
        break;
    //            case R.id.side_navigation_menu_item3:
    //                invokeActivity(getString(R.string.title3), R.drawable.ic_android3);
    //                break;
    //
    //            case R.id.side_navigation_menu_item4:
    //                invokeActivity(getString(R.string.title4), R.drawable.ic_android4);
    //                break;
    //
    //            case R.id.side_navigation_menu_item5:
    //                invokeActivity(getString(R.string.title5), R.drawable.ic_android5);
    //                break;

    default:
        return;
    }
}

From source file:com.nanostuffs.yurdriver.fragment.RegisterFragment.java

private void datepicker() {

    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setContentView(R.layout.datepicker_layout);
    final DatePicker date = (DatePicker) dialog.findViewById(R.id.datePicker1);
    final Calendar c = Calendar.getInstance();
    c.add(Calendar.DAY_OF_YEAR, -1 * (16 * 365));
    date.setMaxDate(c.getTimeInMillis());

    Button text = (Button) dialog.findViewById(R.id.ok);
    text.setOnClickListener(new OnClickListener() {
        @Override/*from www  .  ja  va  2  s  .  c  o  m*/
        public void onClick(View v) {
            v.bringToFront();

            String dateString = String
                    .valueOf(date.getYear() + "-" + (date.getMonth() + 1) + "-" + date.getDayOfMonth());
            etDOB.setText(dateString);

            dialog.dismiss();
        }
    });
    Button cancel = (Button) dialog.findViewById(R.id.cancel);
    cancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            v.bringToFront();
            dialog.dismiss();
        }
    });
    dialog.show();

}

From source file:de.androvdr.activities.ChannelsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_WHATS_ON:
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.extendedchannels_whats_on);
        dialog.setTitle(R.string.channels_whats_on);

        final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        final DatePicker dp = (DatePicker) dialog.findViewById(R.id.channels_datePicker);
        final TimePicker tp = (TimePicker) dialog.findViewById(R.id.channels_timePicker);
        tp.setIs24HourView(DateFormat.is24HourFormat(getApplicationContext()));
        if (sp.contains("whats_on_hour")) {
            tp.setCurrentHour(sp.getInt("whats_on_hour", 0));
            tp.setCurrentMinute(sp.getInt("whats_on_minute", 0));
        }/*from   w w w. j a  va  2 s .  co  m*/

        Button button = (Button) dialog.findViewById(R.id.channels_cancel);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        button = (Button) dialog.findViewById(R.id.channels_search);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Editor editor = sp.edit();
                editor.putInt("whats_on_hour", tp.getCurrentHour());
                editor.putInt("whats_on_minute", tp.getCurrentMinute());
                editor.commit();

                SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy hh:mm");
                try {
                    long time = df.parse(dp.getDayOfMonth() + "." + (dp.getMonth() + 1) + "." + dp.getYear()
                            + " " + tp.getCurrentHour() + ":" + tp.getCurrentMinute()).getTime() / 1000;
                    getController().whatsOn(time);
                } catch (ParseException e) {
                    logger.error("Couldn't get date from pickers", e);
                }
                dialog.dismiss();
            }
        });
        return dialog;
    default:
        return super.onCreateDialog(id);
    }
}

From source file:reportsas.com.formulapp.Formulario.java

public int ObtenerRespuesta(LinearLayout contenedor, Pregunta Pregunta,
        ArrayList<PreguntaRespuesta> respuestaList) {
    PreguntaRespuesta result = new PreguntaRespuesta();
    int numRespuesta = 0;
    result.setIdPregunta(Pregunta.getIdPregunta());
    EditText resp;//from   ww  w .ja  v  a2s.  c  o  m
    TextView selectio;
    switch (Pregunta.getTipoPregunta()) {
    case 1:
        resp = (EditText) contenedor.findViewById(R.id.edtTexto);
        result.setItem(1);
        result.setRespuesta(resp.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 2:
        resp = (EditText) contenedor.findViewById(R.id.mtxtEdit);
        result.setItem(1);
        result.setRespuesta(resp.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 3:
        selectio = (TextView) contenedor.findViewById(R.id.respuestaGruop);
        result.setItem(1);
        result.setRespuesta(selectio.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 4:

        String resp_opcio = "";
        for (int j = 0; j < contenedor.getChildCount(); j++) {
            View child = contenedor.getChildAt(j);
            if (child instanceof CheckBox) {
                CheckBox hijo = (CheckBox) child;
                if (hijo.isChecked()) {
                    if (resp_opcio.length() == 0) {
                        if (Pregunta.isOpcionEditble(hijo.getText().toString())) {
                            EditText otrosR = (EditText) contenedor.findViewById(R.id.edtTexto);
                            resp_opcio = otrosR.getText().toString();
                        } else {
                            resp_opcio = hijo.getText().toString();
                        }
                    } else {
                        if (Pregunta.isOpcionEditble(hijo.getText().toString())) {
                            EditText otrosR = (EditText) contenedor.findViewById(R.id.edtTexto);
                            resp_opcio += " , " + otrosR.getText().toString() + " ";
                        } else {
                            resp_opcio = resp_opcio + " , " + hijo.getText() + " ";
                        }

                    }
                }
            }

        }
        result.setItem(1);
        result.setRespuesta(resp_opcio);
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 5:
        selectio = (TextView) contenedor.findViewById(R.id.seleEscala);
        result.setItem(1);
        result.setRespuesta(selectio.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 6:
        Spinner lista = (Spinner) contenedor.findViewById(R.id.opcionesListado);
        result.setItem(1);
        result.setRespuesta(lista.getSelectedItem().toString() + "");
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 7:
        TableLayout tabla = (TableLayout) contenedor.findViewById(R.id.tablaOpciones);
        for (int i = 0; i < tabla.getChildCount(); i++) {
            TableRow registro = (TableRow) tabla.getChildAt(i);
            TextView etiq = (TextView) registro.findViewById(R.id.textoRow);
            RadioGroup selector = (RadioGroup) registro.findViewById(R.id.valoresRow);
            PreguntaRespuesta itemA = new PreguntaRespuesta();
            itemA.setIdPregunta(Pregunta.getIdPregunta());
            itemA.setItem(i + 1);
            itemA.setRespuesta(etiq.getText().toString());
            if (selector.getCheckedRadioButtonId() > 0) {
                RadioButton rb = (RadioButton) selector.findViewById(selector.getCheckedRadioButtonId());
                itemA.setOpcion(rb.getText() + "");
            }

            respuestaList.add(itemA);
            numRespuesta++;
        }

        break;
    case 8:
        DatePicker dp = (DatePicker) contenedor.findViewById(R.id.Fecha_resutl);
        result.setItem(1);
        result.setRespuesta(dp.getYear() + "-" + dp.getMonth() + "-" + dp.getDayOfMonth());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 9:
        TimePicker tp = (TimePicker) contenedor.findViewById(R.id.hora_result);
        result.setItem(1);
        result.setRespuesta(tp.getCurrentHour() + ":" + tp.getCurrentMinute());
        respuestaList.add(result);
        numRespuesta = 1;
        break;

    default:
        result.setItem(1);
        result.setRespuesta("Proceso");
        break;

    }

    return numRespuesta;

}

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/*w  ww  .j a  va 2  s .  c  o m*/
        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.kunze.androidlocaltodo.TaskActivityFragment.java

private void InitializeView(final View rootView) {
    final View activityView = rootView;
    TextWatcher textWatcher = new TextWatcher() {
        @Override/*from w w w .  j  av  a2s.  com*/
        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:dev.memento.MainActivity.java

public void showDatePicker(View v) {

    // Date picker's months range from 0-11
    final DatePickerDialog dateDialog = new DatePickerDialog(this, null, mDateChosen.getYear(),
            mDateChosen.getMonth() - 1, mDateChosen.getDay());

    // Have to set positive and negative buttons because only a positive button
    // will be displayed by default, and there is a bug in Android that causes
    // the Back button (which should normally be used to cancel) to cause
    // the onDateTime event handler to be triggered.  
    // http://stackoverflow.com/questions/11444238/jelly-bean-datepickerdialog-is-there-a-way-to-cancel

    // If either of the buttons are set with .setButton(), the OnDateSetListener is 
    // not triggered on my Galaxy Tab (Android 4.0.4), so implement listening here instead.

    dateDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_set),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    DatePicker dp = dateDialog.getDatePicker();
                    dateSelected(dp.getDayOfMonth(), dp.getMonth(), dp.getYear());
                }//from  ww w .  j a  va2s . c  o m
            });

    dateDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // Nothing to do
                    if (Log.LOG)
                        Log.d(LOG_TAG, "Cancel was pressed");
                }
            });

    dateDialog.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 ww .  j a v a  2 s  .c  om
    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.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  a2 s  .  com*/
    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);
    }
}