Example usage for android.text InputType TYPE_CLASS_TEXT

List of usage examples for android.text InputType TYPE_CLASS_TEXT

Introduction

In this page you can find the example usage for android.text InputType TYPE_CLASS_TEXT.

Prototype

int TYPE_CLASS_TEXT

To view the source code for android.text InputType TYPE_CLASS_TEXT.

Click Source Link

Document

Class for normal text.

Usage

From source file:com.brq.wallet.activity.modern.AccountsFragment.java

private void setCoinapultMail() {

    AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
    b.setTitle(getString(R.string.coinapult_mail_question));
    View diaView = getActivity().getLayoutInflater().inflate(R.layout.ext_coinapult_mail, null);
    final EditText mailField = (EditText) diaView.findViewById(R.id.mail);
    mailField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    String email = _mbwManager.getMetadataStorage().getCoinapultMail();
    if (!email.isEmpty()) {
        mailField.setText(email);//w  w w. j  av  a2  s.  c om
    }
    b.setView(diaView);
    b.setPositiveButton(getString(R.string.button_done), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String mailText = mailField.getText().toString();
            if (Utils.isValidEmailAddress(mailText)) {
                Optional<String> mail;
                if (mailText.isEmpty()) {
                    mail = Optional.absent();
                } else {
                    mail = Optional.of(mailText);
                }
                _progress.setCancelable(false);
                _progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                _progress.setMessage(getString(R.string.coinapult_setting_email));
                _progress.show();
                _mbwManager.getMetadataStorage().setCoinapultMail(mailText);
                new SetCoinapultMailAsyncTask(mail).execute();
                dialog.dismiss();
            } else {
                new Toaster(AccountsFragment.this).toast("Email address not valid", false);
            }
        }
    });
    b.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    AlertDialog dialog = b.create();
    dialog.show();
}

From source file:com.example.carsharing.CommuteActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    photouri = Uri//  w w  w. j  av  a2  s .  c o  m
            .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_commute);

    activity_drawer = new Drawer(this, R.id.commute_layout);
    mDrawerToggle = activity_drawer.newdrawer();
    mDrawerLayout = activity_drawer.setDrawerLayout();

    // 
    standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE);
    primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE);
    standard_time = new SimpleDateFormat("HH:mm:ss", Locale.SIMPLIFIED_CHINESE);
    primary_time = new SimpleDateFormat("HHmmss", Locale.SIMPLIFIED_CHINESE);

    drawername = (TextView) findViewById(R.id.drawer_name);
    drawernum = (TextView) findViewById(R.id.drawer_phone);
    queue = Volley.newRequestQueue(this);
    exchange = (ImageView) findViewById(R.id.commute_exchange);
    exchange.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            String temp = startplace.getText().toString();
            if (!temp.equals("") && !endplace.getText().toString().equals("")) {
                startplace.setText(endplace.getText().toString());
                endplace.setText(temp);
                float a, b;
                a = startplace_longitude;
                b = startplace_latitude;
                startplace_longitude = destination_longitude;
                startplace_latitude = destination_latitude;
                destination_longitude = a;
                destination_latitude = b;

            }
        }
    });

    bdriver = true;
    bmon = true;
    btue = true;
    bwed = true;
    bthu = true;
    bfri = true;

    startdate = (Button) findViewById(R.id.commute_startdate);
    earlystarttime = (Button) findViewById(R.id.commute_earliest_start_time);
    enddate = (Button) findViewById(R.id.commute_enddate);
    latestarttime = (Button) findViewById(R.id.commute_latest_start_time);
    increase = (Button) findViewById(R.id.commute_increase);
    decrease = (Button) findViewById(R.id.commute_decrease);
    s1 = (TextView) findViewById(R.id.commute_count);
    drawericon = (ImageView) findViewById(R.id.drawer_icon);
    startplace = (Button) findViewById(R.id.commute_startplace);
    endplace = (Button) findViewById(R.id.commute_endplace);
    sure = (Button) findViewById(R.id.commute_sure);
    sure.setEnabled(false);

    carbrand = (EditText) findViewById(R.id.commute_CarBrand);
    model = (EditText) findViewById(R.id.commute_CarModel);
    color = (EditText) findViewById(R.id.commute_color);
    licensenum = (EditText) findViewById(R.id.commute_Num);

    licensenum.addTextChangedListener(numTextWatcher);
    carbrand.addTextChangedListener(detTextWatcher);
    color.addTextChangedListener(coTextWatcher);
    model.addTextChangedListener(moTextWatcher);

    final TextView content = (TextView) findViewById(R.id.commute_content);

    commute_group = (RadioGroup) findViewById(R.id.commute_radiobutton);
    mRadio1 = (RadioButton) findViewById(R.id.commute_radioButton1);
    mRadio2 = (RadioButton) findViewById(R.id.commute_radioButton2);// RadioGroup

    mon = (CheckBox) findViewById(R.id.commute_checkBox1);
    tue = (CheckBox) findViewById(R.id.commute_checkBox2);
    wed = (CheckBox) findViewById(R.id.commute_checkBox3);
    thu = (CheckBox) findViewById(R.id.commute_checkBox4);
    fri = (CheckBox) findViewById(R.id.commute_checkBox5);
    sat = (CheckBox) findViewById(R.id.commute_checkBox6);
    sun = (CheckBox) findViewById(R.id.commute_checkBox7);

    commute = findViewById(R.id.drawer_commute);
    shortway = findViewById(R.id.drawer_shortway);
    longway = findViewById(R.id.drawer_longway);
    setting = findViewById(R.id.drawer_setting);
    personalcenter = findViewById(R.id.drawer_personalcenter);
    taxi = findViewById(R.id.drawer_taxi);

    star1 = (ImageView) findViewById(R.id.cummute_star);
    star2 = (ImageView) findViewById(R.id.commute_star01);

    // 
    SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName),
            Context.MODE_PRIVATE);
    UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0");

    // judge the value of "pre_page"
    Bundle bundle = this.getIntent().getExtras();
    String PRE_PAGE = bundle.getString("pre_page");
    if (PRE_PAGE.compareTo("ReOrder") == 0) { // 
        startplace.setText(bundle.getString("stpusername") + "," + bundle.getString("stpmapname"));
        bstart = true;
        endplace.setText(bundle.getString("epusername") + "," + bundle.getString("epmapname"));
        bend = true;
        startplace_longitude = bundle.getFloat("stpx");
        Log.e("startplace_longitude", String.valueOf(startplace_longitude));
        startplace_latitude = bundle.getFloat("stpy");
        Log.e("startplace_latitude", String.valueOf(startplace_latitude));
        destination_longitude = bundle.getFloat("epx");
        Log.e("destination_longitude", String.valueOf(destination_longitude));
        destination_latitude = bundle.getFloat("epy");
        Log.e("destination_latitude", String.valueOf(destination_latitude));
        startdate.setText(bundle.getString("re_commute_startdate"));
        bstartdate = true;
        enddate.setText(bundle.getString("re_commute_enddate"));
        benddate = true;
        weekrepeat = bundle.getString("weekrepeat");
        earlystarttime.setText(bundle.getString("re_commute_starttime"));
        bearlystarttime = true;
        latestarttime.setText(bundle.getString("re_commute_endtime"));
        blatestarttime = true;

        // weekrepeatcheckbox
        int len = weekrepeat.length();
        for (int i = 0; i < len; i++) {
            if (weekrepeat.charAt(i) == '1') {
                mon.setChecked(true);
                bmon = true;
            }
            if (weekrepeat.charAt(i) == '2') {
                tue.setChecked(true);
                btue = true;
            }
            if (weekrepeat.charAt(i) == '3') {
                wed.setChecked(true);
                bwed = true;
            }
            if (weekrepeat.charAt(i) == '4') {
                thu.setChecked(true);
                bthu = true;
            }
            if (weekrepeat.charAt(i) == '5') {
                fri.setChecked(true);
                bfri = true;
            }
            if (weekrepeat.charAt(i) == '6') {
                sat.setChecked(true);
                bsat = true;
            }
            if (weekrepeat.charAt(i) == '7') {
                sun.setChecked(true);
                bsun = true;
            }
        }
        // end
    }
    // judge the value of "pre_page"

    // database
    db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1);
    db1 = db.getWritableDatabase();
    about = findViewById(R.id.drawer_respond);
    about.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent about = new Intent(CommuteActivity.this, AboutActivity.class);
            startActivity(about);
        }
    });
    setting.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent setting = new Intent(CommuteActivity.this, SettingActivity.class);
            startActivity(setting);
        }
    });

    // database end

    star1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            if (bstart) {
                if (Pointisliked(StartPointMapName)) {
                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { StartPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs);
                    star1.setImageResource(R.drawable.ic_action_not_important);

                } else {
                    ContentValues content = new ContentValues();
                    content.put(getString(R.string.dbstring_PlaceUserName), StartPointUserName);
                    content.put(getString(R.string.dbstring_PlaceMapName), StartPointMapName);
                    content.put(getString(R.string.dbstring_longitude), startplace_longitude);
                    content.put(getString(R.string.dbstring_latitude), startplace_latitude);
                    db1.insert(getString(R.string.dbtable_placeliked), null, content);

                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { StartPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs);
                    star1.setImageResource(R.drawable.ic_action_important);
                }

            }

        }
    });

    star2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            if (bend) {
                if (Pointisliked(EndPointMapName)) {
                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { EndPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs);
                    star2.setImageResource(R.drawable.ic_action_not_important);

                } else {
                    ContentValues content = new ContentValues();
                    content.put(getString(R.string.dbstring_PlaceUserName), EndPointUserName);
                    content.put(getString(R.string.dbstring_PlaceMapName), EndPointMapName);
                    content.put(getString(R.string.dbstring_longitude), destination_longitude);
                    content.put(getString(R.string.dbstring_latitude), destination_latitude);
                    db1.insert(getString(R.string.dbtable_placeliked), null, content);

                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { EndPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs);
                    star2.setImageResource(R.drawable.ic_action_important);
                }

            }

        }
    });

    taxi.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
        }
    });

    personalcenter.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent personalcenter = new Intent(CommuteActivity.this, PersonalCenterActivity.class);
            startActivity(personalcenter);
        }
    });

    shortway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent shortway = new Intent(CommuteActivity.this, ShortWayActivity.class);
            shortway.putExtra("pre_page", "Drawer");
            startActivity(shortway);
        }
    });

    longway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent longway = new Intent(CommuteActivity.this, MainActivity.class);
            startActivity(longway);
        }
    });

    commute.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));

        }
    });

    mon.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bmon = true;
            } else {
                bmon = false;
            }
            confirm();
        }
    });
    tue.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                btue = true;
            } else {
                btue = false;
            }
            confirm();
        }
    });
    wed.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bwed = true;
            } else {
                bwed = false;
            }
            confirm();
        }
    });
    thu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bthu = true;
            } else {
                bthu = false;
            }
            confirm();
        }
    });
    fri.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bfri = true;
            } else {
                bfri = false;
            }
            confirm();
        }
    });
    sat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bsat = true;
            } else {
                bsat = false;
            }
            confirm();
        }
    });
    sun.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bsun = true;
            } else {
                bsun = false;
            }
            confirm();
        }
    });

    commute_group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup arg0, int checkedId) {
            // TODO Auto-generated method stub18
            // ID

            // """"textView
            if (checkedId == mRadio2.getId()) {

                bpassenager = true;
                bdriver = false;

                licensenum.setEnabled(false);
                carbrand.setEnabled(false);
                color.setEnabled(false);
                model.setEnabled(false);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatNeed));
                licensenum.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                carbrand.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                color.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                model.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                licensenum.setInputType(InputType.TYPE_NULL);
                carbrand.setInputType(InputType.TYPE_NULL);
                color.setInputType(InputType.TYPE_NULL);
                model.setInputType(InputType.TYPE_NULL);
            } else {

                bpassenager = false;
                bdriver = true;

                licensenum.setEnabled(true);
                carbrand.setEnabled(true);
                color.setEnabled(true);
                model.setEnabled(true);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return null;
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatOffer));
                licensenum.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                carbrand.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                color.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                model.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                // licensenum.setText("");
                // carbrand.setText("");
                // color.setText("");
                // model.setText("");
                licensenum.setInputType(InputType.TYPE_CLASS_TEXT);
                carbrand.setInputType(InputType.TYPE_CLASS_TEXT);
                color.setInputType(InputType.TYPE_CLASS_TEXT);
                model.setInputType(InputType.TYPE_CLASS_TEXT);

                // start!
                selectcarinfo(UserPhoneNumber);
                // end!
            }
            confirm();
        }

        private void selectcarinfo(final String phonenum) {
            // TODO Auto-generated method stub
            String carinfo_selectrequest_baseurl = getString(R.string.uri_base)
                    + getString(R.string.uri_CarInfo) + getString(R.string.uri_selectcarinfo_action);

            Log.d("carinfo_selectrequest_baseurl", carinfo_selectrequest_baseurl);
            StringRequest stringRequest = new StringRequest(Request.Method.POST, carinfo_selectrequest_baseurl,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            // TODO Auto-generated method stub
                            Log.d("carinfo_select", response);
                            String jas_id = null;
                            JSONObject json1 = null;
                            try {
                                json1 = new JSONObject(response);
                                JSONObject json = json1.getJSONObject("result");
                                jas_id = json.getString("id");

                                if (jas_id.compareTo("") != 0) { // 

                                    carinfochoosing_type = 2;
                                    carbrand.setText(json.getString("carBrand"));
                                    model.setText(json.getString("carModel"));
                                    licensenum.setText(json.getString("carNum"));
                                    color.setText(json.getString("carColor"));

                                } else {
                                    carinfochoosing_type = 1;
                                }
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                    }, new Response.ErrorListener() {

                        @Override
                        public void onErrorResponse(VolleyError error) {
                            // TODO Auto-generated method stub
                            Log.e("carinfo_selectresult_result", error.getMessage(), error);
                        }
                    }) {
                protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("phonenum", phonenum);
                    return params;
                }
            };

            queue.add(stringRequest);
        }

    });

    sure.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            if (commute_group.getCheckedRadioButtonId() == mRadio1.getId()) {
                supplycar = "y";
            } else
                supplycar = "n";

            // start!
            Context phonenumber = CommuteActivity.this;
            SharedPreferences filename = phonenumber
                    .getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE);
            username = filename.getString("refreshfilename", "0");
            commute_request(username, startdate.getText().toString(), enddate.getText().toString(),
                    earlystarttime.getText().toString(), latestarttime.getText().toString());
            // end!

        }

        private void commute_request(final String commute_phonenum, final String commute_startdate,
                final String commute_enddate, final String commute_starttime, final String commute_endtime) {
            // TODO Auto-generated method stub

            weekrepeat = "";
            if (bmon)
                weekrepeat += "1";
            if (btue)
                weekrepeat += "2";
            if (bwed)
                weekrepeat += "3";
            if (bthu)
                weekrepeat += "4";
            if (bfri)
                weekrepeat += "5";
            if (bsat)
                weekrepeat += "6";
            if (bsun)
                weekrepeat += "7";

            // start
            try {
                test_date = primary_date.parse(commute_startdate);
                standard_commute_startdate = standard_date.format(test_date);
                test_date = primary_date.parse(commute_enddate);
                standard_commute_enddate = standard_date.format(test_date);
                test_date = primary_time.parse(commute_starttime);
                standard_commute_starttime = standard_time.format(test_date);
                test_date = primary_time.parse(commute_endtime);
                standard_commute_endtime = standard_time.format(test_date);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            // end!

            String commute_baseurl = getString(R.string.uri_base) + getString(R.string.uri_CommuteRequest)
                    + getString(R.string.uri_addrequest_action);
            // + "phonenum=" + commute_phonenum + "&startplacex=" +
            // String.valueOf(startplace_longitude) +
            // "&startplacey=" + String.valueOf(startplace_latitude) +
            // "&destinationx=" + String.valueOf(destination_longitude) +
            // "&destinationy=" + String.valueOf(destination_latitude) +
            // "&startdate=" + standard_commute_startdate
            // + "&enddate=" + standard_commute_enddate
            // + "&starttime=" + standard_commute_starttime
            // + "&endtime=" + standard_commute_endtime + "&weekrepeat=" +
            // weekrepeat + "&supplycar=" + supplycar;

            Log.e("commute_URL", commute_baseurl);
            // Instantiate the RequestQueue.
            // Request a string response from the provided URL.
            StringRequest stringRequest = new StringRequest(Request.Method.POST, commute_baseurl,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            Log.d("commute_result", response);
                            JSONObject json1 = null;
                            try {
                                json1 = new JSONObject(response);
                                requestok = json1.getBoolean("result");
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }

                            if (requestok == true) {

                                if (carinfochoosing_type == 1) {
                                    // add
                                    // start!
                                    carinfo(commute_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 1);
                                    // end!
                                } else {
                                    // update
                                    // start!
                                    carinfo(commute_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 2);
                                    // end!
                                }

                                Intent sure = new Intent(CommuteActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "true");
                                sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(sure);
                            } else {
                                // Toast errorinfo =
                                // Toast.makeText(getApplicationContext(),
                                // "", Toast.LENGTH_LONG);
                                // errorinfo.show();
                                Intent sure = new Intent(CommuteActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "false");
                                sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(sure);
                            }
                        }
                    }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            Log.e("commute_result", error.getMessage(), error);
                            commute_result = null;
                            // Toast errorinfo = Toast.makeText(null,
                            // "", Toast.LENGTH_LONG);
                            // errorinfo.show();
                            Intent sure = new Intent(CommuteActivity.this, OrderResponseActivity.class);
                            sure.putExtra(getString(R.string.request_response), "false");
                            sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(sure);
                        }
                    }) {
                protected Map<String, String> getParams() {
                    // POSTgetParams

                    // start
                    try {
                        test_date = primary_date.parse(commute_startdate);
                        standard_commute_startdate = standard_date.format(test_date);
                        test_date = primary_date.parse(commute_enddate);
                        standard_commute_enddate = standard_date.format(test_date);
                        test_date = primary_time.parse(commute_starttime);
                        standard_commute_starttime = standard_time.format(test_date);
                        test_date = primary_time.parse(commute_endtime);
                        standard_commute_endtime = standard_time.format(test_date);
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    // end!

                    Map<String, String> params = new HashMap<String, String>();
                    params.put(getString(R.string.uri_phonenum), commute_phonenum);
                    params.put(getString(R.string.uri_startplacex), String.valueOf(startplace_longitude));
                    params.put(getString(R.string.uri_startplacey), String.valueOf(startplace_latitude));
                    params.put(getString(R.string.uri_startplace), startplace.getText().toString());
                    params.put(getString(R.string.uri_destinationx), String.valueOf(destination_longitude));
                    params.put(getString(R.string.uri_destinationy), String.valueOf(destination_latitude));
                    params.put(getString(R.string.uri_destination), endplace.getText().toString());
                    params.put(getString(R.string.uri_startdate), standard_commute_startdate);
                    params.put(getString(R.string.uri_enddate), standard_commute_enddate);
                    params.put(getString(R.string.uri_starttime), standard_commute_starttime);
                    params.put(getString(R.string.uri_endtime), standard_commute_endtime);
                    params.put(getString(R.string.uri_weekrepeat), weekrepeat);
                    params.put(getString(R.string.uri_supplycar), supplycar);
                    // Log.w("phonemum", commute_phonenum);
                    // Log.w("startplacex",
                    // String.valueOf(startplace_longitude));
                    // Log.w("startdate", standard_commute_startdate);
                    // Log.w("starttime", standard_commute_starttime);
                    // Log.w("weekrepeat",weekrepeat );
                    // Log.w("supplycar",supplycar );
                    // Log.w("enddate",standard_commute_enddate );

                    return params;
                }
            };

            queue.add(stringRequest);

        }
    });

    startplace.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            startActivityForResult(new Intent(CommuteActivity.this, ChooseAddressActivity.class), 1);
        }
    });

    endplace.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            startActivityForResult(new Intent(CommuteActivity.this, ChooseArrivalActivity.class), 2);
        }
    });

    increase.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum++;
            s1.setText("" + sum);
            confirm();
        }
    });

    decrease.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum--;
            if (sum < 0) {
                sum = 0;
            }
            s1.setText("" + sum);
            confirm();
        }
    });

    startdate.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(DATE_DIALOG);
        }

    });

    enddate.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(DATE_DIALOG01);

        }
    });

    earlystarttime.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(TIME_DIALOG);
        }
    });

    latestarttime.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(TIME_DIALOG01);

        }
    });
}

From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.TrafficMapActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    mTracker = ((WsdotApplication) getApplication()).getDefaultTracker();

    switch (item.getItemId()) {
    case R.id.best_times_to_travel:
        Intent chartsIntent = new Intent(this, TravelChartsActivity.class);
        chartsIntent.putExtra("title", bestTimesTitle);
        startActivity(chartsIntent);// www . j a va2s  . c o  m
        break;
    case R.id.set_favorite:
        AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.WSDOT_popup);

        final EditText textEntryView = new EditText(this);
        textEntryView.setInputType(InputType.TYPE_CLASS_TEXT);
        builder.setView(textEntryView);
        builder.setMessage(R.string.add_location_dialog);
        builder.setNegativeButton(R.string.cancel, (dialog, whichButton) -> dialog.dismiss());
        builder.setPositiveButton(R.string.submit, (dialog, whichButton) -> {
            String value = textEntryView.getText().toString();
            dialog.dismiss();

            MapLocationEntity location = new MapLocationEntity();

            location.setTitle(value);

            location.setLatitude(mMap.getProjection().getVisibleRegion().latLngBounds.getCenter().latitude);
            location.setLongitude(mMap.getProjection().getVisibleRegion().latLngBounds.getCenter().longitude);
            location.setZoom((int) mMap.getCameraPosition().zoom);

            favoriteMapLocationViewModel.addMapLocation(location);

        });
        AlertDialog alertDialog = builder.create();
        alertDialog.show();
        return true;
    case R.id.refresh:
        refreshOverlays(item);
        return true;
    case R.id.alerts_in_area:
        if (mMap != null) {
            LatLngBounds mBounds = mMap.getProjection().getVisibleRegion().latLngBounds;
            Intent alertsIntent = new Intent(this, HighwayAlertListActivity.class);
            alertsIntent.putExtra("nelat", mBounds.northeast.latitude);
            alertsIntent.putExtra("nelong", mBounds.northeast.longitude);
            alertsIntent.putExtra("swlat", mBounds.southwest.latitude);
            alertsIntent.putExtra("swlong", mBounds.southwest.longitude);
            startActivity(alertsIntent);
        }
        return true;
    case R.id.express_lanes:
        Intent expressIntent = new Intent(this, SeattleExpressLanesActivity.class);
        startActivity(expressIntent);
        return true;
    case android.R.id.home:
        finish();
        return true;
    case R.id.social_media:
        Intent socialIntent = new Intent(this, SocialMediaTabActivity.class);
        startActivity(socialIntent);
        return true;
    case R.id.travel_times:
        Intent timesIntent = new Intent(this, TravelTimesActivity.class);
        startActivity(timesIntent);
        return true;
    case R.id.news:
        Intent newsIntent = new Intent(this, NewsActivity.class);
        startActivity(newsIntent);
        return true;
    case R.id.goto_bellingham:
        mTracker.setScreenName("/Traffic Map/Go To Location/Bellingham");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(48.756302, -122.46151, 12);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_chehalis:
        mTracker.setScreenName("/Traffic Map/Go To Location/Chehalis");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(46.635529, -122.937698, 11);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_everett:
        mTracker.setScreenName("/Traffic Map/Go To Location/Everett");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.967976, -122.197627, 12);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_hoodcanal:
        mTracker.setScreenName("/Traffic Map/Go To Location/Hood Canal");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.85268, -122.628365, 13);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_mtvernon:
        mTracker.setScreenName("/Traffic Map/Go To Location/Mt. Vernon");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(48.420657, -122.334824, 13);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_stanwood:
        mTracker.setScreenName("/Traffic Map/Go To Location/Standwood");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(48.22959, -122.34581, 13);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_monroe:
        mTracker.setScreenName("/Traffic Map/Go To Location/Monroe");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.859476, -121.972446, 14);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_sultan:
        mTracker.setScreenName("/Traffic Map/Go To Location/Sultan");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.86034, -121.812286, 13);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_olympia:
        mTracker.setScreenName("/Traffic Map/Go To Location/Olympia");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.021461, -122.899933, 13);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_seattle:
        mTracker.setScreenName("/Traffic Map/Go To Location/Seattle");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.5990, -122.3350, 12);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_spokane:
        mTracker.setScreenName("/Traffic Map/Go To Location/Spokane");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.658566, -117.425995, 12);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_tacoma:
        mTracker.setScreenName("/Traffic Map/Go To Location/Tacoma");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.206275, -122.46254, 12);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_vancouver:
        mTracker.setScreenName("/Traffic Map/Go To Location/Vancouver");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(45.639968, -122.610512, 11);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_wenatchee:
        mTracker.setScreenName("/Traffic Map/Go To Location/Wenatchee");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.435867, -120.309563, 12);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_snoqualmiepass:
        mTracker.setScreenName("/Traffic Map/Go To Location/Snoqualmie Pass");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(47.404481, -121.4232569, 12);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_tricities:
        mTracker.setScreenName("/Traffic Map/Go To Location/Tri-Cities");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(46.2503607, -119.2063781, 11);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.goto_yakima:
        mTracker.setScreenName("/Traffic Map/Go To Location/Yakima");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        goToLocation(46.6063273, -120.4886952, 11);
        UIUtils.refreshActionBarMenu(this);
        return true;
    case R.id.map_legend:
        AlertDialog.Builder imageDialog = new AlertDialog.Builder(this, R.style.WSDOT_popup);
        LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);

        View layout = inflater.inflate(R.layout.map_legend_layout, null);
        imageDialog.setView(layout);
        imageDialog.setPositiveButton(R.string.submit, (dialog, whichButton) -> dialog.dismiss());
        imageDialog.create();
        imageDialog.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:es.farfuteam.vncpp.controller.CanvasActivity.java

/**
 * @return The new dialog//www .j ava2 s .com
 * @brief Show the dialog with the password needed message
 * @details Show the dialog with the password needed message
 */
private Dialog passwordNeededDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    String info = getString(R.string.password_title);
    String body = getString(R.string.password_dialog);

    builder.setTitle(info);
    builder.setMessage(body);
    // Set an EditText view to get user password 
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    builder.setView(input);

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
            pass = "";
            waitDialog = false;
        }
    });
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            String str = input.getEditableText().toString();
            pass = str;
            waitDialog = false;
        }

    });

    return builder.create();
}

From source file:com.crearo.gpslogger.GpsMainActivity.java

/**
 * Annotates GPX and KML files, TXT files are ignored.
 * The user is prompted for the content of the <name> tag. If a valid
 * description is given, the logging service starts in single point mode.
 *//* w  w w  .  j  a v  a 2s  .  com*/
private void annotate() {

    if (!preferenceHelper.shouldLogToGpx() && !preferenceHelper.shouldLogToKml()
            && !preferenceHelper.shouldLogToCustomUrl()) {
        Toast.makeText(getApplicationContext(), getString(R.string.annotation_requires_logging),
                Toast.LENGTH_SHORT).show();
        return;
    }

    new MaterialDialog.Builder(this).title(R.string.add_description).inputType(InputType.TYPE_CLASS_TEXT)
            .negativeText(R.string.cancel)
            .input(getString(R.string.letters_numbers), "", new MaterialDialog.InputCallback() {
                @Override
                public void onInput(MaterialDialog materialDialog, CharSequence input) {
                    LOG.info("Annotation entered : " + input.toString());
                    EventBus.getDefault().postSticky(new CommandEvents.Annotate(input.toString()));
                }
            }).onNegative(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog materialDialog,
                        @NonNull DialogAction dialogAction) {
                    materialDialog.dismiss();
                }
            }).show();

}

From source file:org.secu3.android.ParamActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    adapter = (ParamItemsAdapter) parent.getAdapter();
    if (adapter != null) {
        this.position = position;
        BaseParamItem i = (BaseParamItem) adapter.getItem(position);
        if (i instanceof ParamItemInteger) {
            dialog = new CustomNumberPickerIntegerDialog();
            dialog.setValid(isValid);//from   ww w . j av  a  2 s .  c o m
            ((CustomNumberPickerIntegerDialog) dialog.setId(i.getNameId()))
                    .setRange(((ParamItemInteger) i).getValue(), ((ParamItemInteger) i).getMinValue(),
                            ((ParamItemInteger) i).getMaxValue(), ((ParamItemInteger) i).getStepValue())
                    .setOnCustomNumberPickerAcceptListener(this).show(getSupportFragmentManager(), i.getName());
        } else if (i instanceof ParamItemFloat) {
            dialog = new CustomNumberPickerFloatDialog();
            dialog.setValid(isValid);
            ((CustomNumberPickerFloatDialog) dialog.setId(i.getNameId()))
                    .setRange(((ParamItemFloat) i).getValue(), ((ParamItemFloat) i).getMinValue(),
                            ((ParamItemFloat) i).getMaxValue(), ((ParamItemFloat) i).getStepValue())
                    .setFormat(((ParamItemFloat) i).getFormat()).setOnCustomNumberPickerAcceptListener(this)
                    .show(getSupportFragmentManager(), i.getName());
        } else if (i instanceof ParamItemBoolean) {
            adapter.setValue(String.valueOf(!((ParamItemBoolean) i).getValue()), position);
            onItemChange(i.getNameId());
        } else if (i instanceof ParamItemString) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(i.getName());
            final EditText input = new EditText(this);
            bluetoothSecurityFlags = i.getNameId();
            input.setText(((ParamItemString) i).getValue());
            switch (bluetoothSecurityFlags) {
            case R.string.secur_par_bluetooth_name_title:
                input.setInputType(InputType.TYPE_CLASS_TEXT);
                break;
            case R.string.secur_par_bluetooth_pass_title:
                input.setInputType(InputType.TYPE_CLASS_NUMBER);
                break;
            }
            builder.setView(input);
            builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    bluetoothSecurityValue = input.getText().toString();
                    onItemChange(bluetoothSecurityFlags);
                }
            });
            builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            builder.show();
        }
    }
}

From source file:com.eveningoutpost.dexdrip.Home.java

private void promptTextInput_old() {

    if (recognitionRunning)
        return;/*from   w  w w. j  av  a  2  s.co  m*/
    recognitionRunning = true;

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Type treatment\neg: units x.x");
    // Set up the input
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);
    // Set up the buttons
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            voiceRecognitionText.setText(input.getText().toString());
            voiceRecognitionText.setVisibility(View.VISIBLE);
            last_speech_time = JoH.ts();
            naturalLanguageRecognition(input.getText().toString());

        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    final AlertDialog dialog = builder.create();
    input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                if (dialog != null)
                    dialog.getWindow()
                            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });
    dialog.show();
    recognitionRunning = false;
}

From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java

/**
 * Navigates to an item by path/*from   w  ww  .  j a  v  a  2s.  co  m*/
 * @param item the source item
 */
private void navigateByPath(final Item item) {
    final BaseApplication application = (BaseApplication) getActivity().getApplication();
    final IOneDriveClient oneDriveClient = application.getOneDriveClient();
    final Activity activity = getActivity();

    final EditText itemPath = new EditText(activity);
    itemPath.setInputType(InputType.TYPE_CLASS_TEXT);

    final DefaultCallback<Item> itemCallback = new DefaultCallback<Item>(activity) {
        @Override
        public void success(final Item item) {
            final ItemFragment fragment = ItemFragment.newInstance(item.id);
            navigateToFragment(fragment);
        }
    };

    new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_map)
            .setTitle(R.string.navigate_by_path).setView(itemPath)
            .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    dialog.dismiss();
                }
            }).setPositiveButton(R.string.navigate, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    oneDriveClient.getDrive().getItems(item.id).getItemWithPath(itemPath.getText().toString())
                            .buildRequest().expand(getExpansionOptions(oneDriveClient)).get(itemCallback);
                }
            }).create().show();
}

From source file:com.kmshack.BusanBus.activity.SearchMainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main_common);
    setTitle("");
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerListener(new DrawerListener() {
        public void onDrawerOpened(View drawerView) {
            mDrawerToggle.onDrawerOpened(drawerView);
            getActionBarHelper().onDrawerOpened();
        }/* ww  w. ja v  a  2s  .  co m*/

        public void onDrawerClosed(View drawerView) {
            mDrawerToggle.onDrawerClosed(drawerView);
            getActionBarHelper().onDrawerClosed();
        }

        public void onDrawerSlide(View drawerView, float slideOffset) {
            mDrawerToggle.onDrawerSlide(drawerView, slideOffset);
        }

        public void onDrawerStateChanged(int newState) {
            mDrawerToggle.onDrawerStateChanged(newState);
        }
    });
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    mDrawerToggle = new SherlockActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_dark,
            R.string.drawer_open, R.string.drawer_close);
    mDrawerToggle.syncState();

    mBusDb = BusDb.getInstance(getApplicationContext());
    mUserDb = UserDb.getInstance(getApplicationContext());
    mBusanBusPrefrence = BusanBusPrefrence.getInstance(getApplicationContext());
    mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {

            switch (msg.what) {

            case TAB_NOSUN:
                searchNosun((String) msg.obj);
                break;

            case TAB_BUSSTOP:
                searchBusStop((String) msg.obj);
                break;
            }

        }
    };

    mImageFavorite = (ImageView) findViewById(R.id.main_tap_favorite_image);
    mImageNosun = (ImageView) findViewById(R.id.main_tap_nosun_image);
    mImageBusstop = (ImageView) findViewById(R.id.main_tap_busstop_image);
    mImageLocation = (ImageView) findViewById(R.id.main_tap_setting_image);

    mFavoriteImageNosun = (TextView) findViewById(R.id.favorite_tab_nosun);
    mFavoriteImageBusstop = (TextView) findViewById(R.id.favorite_tab_busstop);

    mTextFavorite = (TextView) findViewById(R.id.main_tap_favorite_text);
    mTextNosun = (TextView) findViewById(R.id.main_tap_nosun_text);
    mTextBusstop = (TextView) findViewById(R.id.main_tap_busstop_text);
    mTextSetting = (TextView) findViewById(R.id.main_tap_setting_text);

    mNosunListView = (ListView) findViewById(R.id.lv_nosun);
    mBusStopListView = (ListView) findViewById(R.id.lv_busstop);
    mFavoriteListView = (DragSortListView) findViewById(R.id.lv_favorite);

    mNosunListView.setEmptyView((TextView) findViewById(R.id.nosun_empty));
    mBusStopListView.setEmptyView((TextView) findViewById(R.id.busstop_empty));
    mFavoriteListView.setEmptyView((TextView) findViewById(R.id.favorite_empty));

    mFavoriteListView.setDropListener(mOnDrop);
    mFavoriteListView.setRemoveListener(mOnRemove);

    mTextSettingNotice = (TextView) findViewById(R.id.setting_notice);
    mTextSettingUpdate = (TextView) findViewById(R.id.setting_update);

    mLayoutSettingTextSize = (LinearLayout) findViewById(R.id.setting_textsize_sun);
    mLayoutSettingArrive = (LinearLayout) findViewById(R.id.setting_arrive_sun);
    mLayoutSettingFavorite = (LinearLayout) findViewById(R.id.setting_favorite_start);
    mLayoutSettingFavoriteLocation = (LinearLayout) findViewById(R.id.setting_favorite_location);

    mTextViewSettingTextSize = (TextView) findViewById(R.id.setting_textsize_value);
    mCheckSettingArrive = (ImageView) findViewById(R.id.setting_check_arrive_sun);
    mCheckSettingFavorite = (ImageView) findViewById(R.id.setting_check_favorite_start);
    mCheckSettingFavoriteLocation = (ImageView) findViewById(R.id.setting_check_favorite_location);

    mTextSettingNotice.setOnClickListener(mSettingClick);
    mTextSettingUpdate.setOnClickListener(mSettingClick);

    mLayoutSettingTextSize.setOnClickListener(mSettingClick);
    mLayoutSettingArrive.setOnClickListener(mSettingClick);
    mLayoutSettingFavorite.setOnClickListener(mSettingClick);
    mLayoutSettingFavoriteLocation.setOnClickListener(mSettingClick);

    findViewById(R.id.setting_opensource).setOnClickListener(mSettingClick);
    findViewById(R.id.setting_bin).setOnClickListener(mSettingClick);

    if (mBusanBusPrefrence.getIsArriveSort())
        mCheckSettingArrive.setImageResource(R.drawable.btn_setting_checkbox_check);
    else
        mCheckSettingArrive.setImageResource(R.drawable.btn_setting_checkbox_uncheck);

    if (mBusanBusPrefrence.getIsFavoriteStart())
        mCheckSettingFavorite.setImageResource(R.drawable.btn_setting_checkbox_check);
    else
        mCheckSettingFavorite.setImageResource(R.drawable.btn_setting_checkbox_uncheck);

    if (mBusanBusPrefrence.getIsFavoriteLocation())
        mCheckSettingFavoriteLocation.setImageResource(R.drawable.btn_setting_checkbox_check);
    else
        mCheckSettingFavoriteLocation.setImageResource(R.drawable.btn_setting_checkbox_uncheck);

    mNosunSearchView = (LinearLayout) LayoutInflater.from(getApplicationContext())
            .inflate(R.layout.search_bar_nosun, null);
    mNosunSearchView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mNosunEditText = (EditText) mNosunSearchView.findViewById(R.id.et_search_nosun);
    mNosunEditText.setHint(" ");
    mNosunEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
    mNosunEditText.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            mHandler.removeMessages(TAB_NOSUN);
            Message msg = Message.obtain(mHandler, TAB_NOSUN, s.toString());
            mHandler.sendMessageDelayed(msg, 200);
        }

        public void afterTextChanged(Editable s) {
        }

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

        }

    });

    ((LinearLayout) findViewById(R.id.search_nosun)).addView(mNosunSearchView);

    mNosunListView.setOnScrollListener(new OnScrollListener() {
        public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
        }

        public void onScrollStateChanged(AbsListView arg0, int arg1) {
            mInputMethodManager.hideSoftInputFromWindow(mNosunEditText.getWindowToken(), 0);
        }
    });

    mNosunListView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
            Cursor cursor = mMainNosunSearchAdapter.getCursor();
            cursor.moveToPosition(position);

            String nosun = cursor.getString(1);
            String realtime = cursor.getString(cursor.getColumnIndexOrThrow("WEBREALTIME"));
            String up = cursor.getString(2);
            String down = cursor.getString(3);

            Intent intent = new Intent(getApplicationContext(), NosunDetailActivity.class);
            intent.putExtra("NoSun", nosun);
            intent.putExtra("RealTimeNoSun", realtime);
            intent.putExtra("Up", up);
            intent.putExtra("Down", down);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);

        }
    });

    mBusstopSearchView = (LinearLayout) LayoutInflater.from(getApplicationContext())
            .inflate(R.layout.search_bar_busstop, null);
    mBusStopEditText = (EditText) mBusstopSearchView.findViewById(R.id.et_search_busstop);
    mBusStopEditText.setHint("/ ");
    mBusStopEditText.setInputType(InputType.TYPE_CLASS_TEXT);
    mBusStopEditText.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            mHandler.removeMessages(TAB_BUSSTOP);
            Message msg = Message.obtain(mHandler, TAB_BUSSTOP, s.toString());
            mHandler.sendMessageDelayed(msg, 200);
        }

        public void afterTextChanged(Editable s) {
        }

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

    });

    ((LinearLayout) findViewById(R.id.search_busstop)).addView(mBusstopSearchView);

    mBusStopListView.setOnScrollListener(new OnScrollListener() {
        public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
        }

        public void onScrollStateChanged(AbsListView arg0, int arg1) {
            mInputMethodManager.hideSoftInputFromWindow(mBusStopEditText.getWindowToken(), 0);
        }
    });

    mBusStopListView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
            Cursor cursor = mMainStopSearchAdapter.getCursor();
            cursor.moveToPosition(position);

            String busStop = cursor.getString(2).toString();

            Intent intent = new Intent(getApplicationContext(), BusstopDetailActivity.class);
            intent.putExtra("BusStop", busStop);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);

        }
    });

    mFavoriteListView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
            Cursor cursor = null;
            switch (mFavoriteMode) {
            case FAVORITE_TAB_NOSUN:
                cursor = mMainNosunFavoriteAdapter.getCursor();
                break;

            default:
                cursor = mMainStopFavoriteAdapter.getCursor();
                break;
            }

            if (cursor.getCount() > 0) {
                cursor.moveToPosition(position);
                Intent intent = null;

                switch (mFavoriteMode) {
                case FAVORITE_TAB_NOSUN:
                    intent = new Intent(getApplicationContext(), BusArriveActivity.class);
                    intent.putExtra("NOSUN", cursor.getString(1));
                    intent.putExtra("UNIQUEID", cursor.getString(2));
                    intent.putExtra("BUSSTOPNAME", cursor.getString(3));
                    intent.putExtra("UPDOWN", cursor.getString(4));
                    intent.putExtra("ORD", cursor.getString(6));

                    break;

                case FAVORITE_TAB_BUSSTOP:
                    intent = new Intent(getApplicationContext(), BusstopDetailActivity.class);
                    intent.putExtra("BusStop", cursor.getString(2));

                    break;
                }

                if (intent != null) {
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                }
            }
        }
    });

    mTabFavorite = (LinearLayout) findViewById(R.id.main_tap_favorite);
    mTabNosun = (LinearLayout) findViewById(R.id.main_tap_nosun);
    mTabBusstop = (LinearLayout) findViewById(R.id.main_tap_busstop);
    mTabLocation = (LinearLayout) findViewById(R.id.main_tap_location);

    mLayoutFavorite = (LinearLayout) findViewById(R.id.layout_main_favorite);
    mLayoutNosun = (LinearLayout) findViewById(R.id.layout_main_nosun_search);
    mLayoutBusstop = (LinearLayout) findViewById(R.id.layout_main_busstop_search);
    mLayoutLocation = (LinearLayout) findViewById(R.id.layout_main_location);

    mTabFavorite.setOnClickListener(mTabClickListener);
    mTabNosun.setOnClickListener(mTabClickListener);
    mTabBusstop.setOnClickListener(mTabClickListener);
    mTabLocation.setOnClickListener(mTabClickListener);
    mFavoriteImageNosun.setOnClickListener(mTabClickListener);
    mFavoriteImageBusstop.setOnClickListener(mTabClickListener);

    searchNosun("");
    searchBusStop("");

    if (mBusanBusPrefrence.getIsFavoriteStart()) {
        setTabChange(TAB_FAVORITE);
    } else {
        setTabChange(DEFAULT_TAB);
    }

    tracker.trackPageView("/SearchMain");

    loadSettingTextSizeSelect();
}

From source file:onion.chat.MainActivity.java

void changePassword() {
    final FrameLayout view = new FrameLayout(this);
    final EditText editText = new EditText(this);
    editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(32) });
    editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    editText.setSingleLine();//  w  w  w  .  j  a v  a2  s .  co m
    editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME
            | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    view.addView(editText);
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());
    ;
    view.setPadding(padding, padding, padding, padding);
    editText.setText("");
    new AlertDialog.Builder(this).setTitle(R.string.password).setView(view)
            .setPositiveButton(R.string.apply, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    db.setPassword(editText.getText().toString().trim());
                    update();
                    //snack(getString(R.string.snack_alias_changed));
                    String toSpeak = "password changed successfully";
                    Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();

                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).show();
}