Example usage for android.telephony PhoneNumberUtils getFormatTypeForLocale

List of usage examples for android.telephony PhoneNumberUtils getFormatTypeForLocale

Introduction

In this page you can find the example usage for android.telephony PhoneNumberUtils getFormatTypeForLocale.

Prototype

@Deprecated
public static int getFormatTypeForLocale(Locale locale) 

Source Link

Document

Returns the phone number formatting type for the given locale.

Usage

From source file:com.hackensack.umc.activity.ViewProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_profile);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    sharedPreferences = getSharedPreferences(Constant.SHAREPREF_TAG, MODE_PRIVATE);
    insuranceInfoTv = (TextView) findViewById(R.id.prof_insurance_tv);
    if (Util.isUserLogin(this) && Util.isPatientIdValid(this)) {

        try {//  www . ja va  2 s  . com
            mPatient = new LoginUserData(new JSONObject(Util.getPatientJSON(this)));
            ((TextView) findViewById(R.id.profile_fname)).setText(mPatient.getFirstName());
            ((TextView) findViewById(R.id.prof_lname)).setText(mPatient.getLastName());
            ((TextView) findViewById(R.id.prof_license)).setText(
                    TextUtils.isEmpty(mPatient.getDrivingLicense()) ? "-" : mPatient.getDrivingLicense());
            DateFormat formatterDate = new SimpleDateFormat("MM-dd-yyyy");

            Date d = null;
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
                d = sdf.parse(mPatient.getBirthDate());
            } catch (Exception e) {
                Log.e("Date", " " + e);
            }

            //Bug is there : Null Pointer : Appointment Date
            ((TextView) findViewById(R.id.prof_date)).setText(formatterDate.format(d.getTime()));
            ((TextView) findViewById(R.id.prof_gender_tv)).setText(mPatient.getGender());
            //Code for getting and displaying phone numbers
            ArrayList<Telecom> telecom = mPatient.getTelephone();
            Log.v("Telecom", telecom.toString());
            String phonestr = null;
            for (int i = 0; i < telecom.size(); i++) {
                if (((Telecom) telecom.get(i)).getSystem().equalsIgnoreCase(Telecom.TELECOM_EMAIL)) {
                    ((TextView) findViewById(R.id.prof_email)).setText(((Telecom) telecom.get(i)).getValue());
                } else if (((Telecom) telecom.get(i)).getSystem().equalsIgnoreCase(Telecom.TELECOM_PHONE)) {
                    phonestr = telecom.get(i).getValue();
                    final Editable doctorPhoneNum = new SpannableStringBuilder(phonestr);
                    PhoneNumberUtils.formatNumber(doctorPhoneNum,
                            PhoneNumberUtils.getFormatTypeForLocale(Locale.US));
                    if (((Telecom) telecom.get(i)).getUse().equalsIgnoreCase(Telecom.TELECOM_MOBILE_PHONE)) {
                        findViewById(R.id.mobile_ll).setVisibility(View.VISIBLE);
                        ((TextView) findViewById(R.id.prof_mob_num)).setText(doctorPhoneNum);

                    } else if (((Telecom) telecom.get(i)).getUse()
                            .equalsIgnoreCase(Telecom.TELECOM_HOME_PHONE)) {
                        findViewById(R.id.home_ll).setVisibility(View.VISIBLE);
                        ((TextView) findViewById(R.id.prof_home_num)).setText(doctorPhoneNum);

                    } else if (((Telecom) telecom.get(i)).getUse()
                            .equalsIgnoreCase(Telecom.TELECOM_WORK_PHONE)) {
                        findViewById(R.id.work_ll).setVisibility(View.VISIBLE);
                        ((TextView) findViewById(R.id.prof_work_num)).setText(doctorPhoneNum);
                    }
                }
            }
            //Code to get and display address
            if (mPatient.getAddress() != null && mPatient.getAddress().size() > 0) {
                Address address = ((ArrayList<Address>) mPatient.getAddress()).get(0);
                ((TextView) findViewById(R.id.prof_addr_tv)).setText(address.getStreet1() + ","
                        + (TextUtils.isEmpty(address.getStreet2()) ? "" : address.getStreet2() + ",")
                        + address.getCity() + "," + address.getState() + "," + address.getZip() + ","
                        + address.getCountry());
            }

        } catch (Exception e) {
            Log.e("isUserLogin", "", e);

        }
        //Code to get and display insurance info

        new GetInsuranceInfo().execute(mPatient.getMRNId());
    }

    /* mProgressDialog = new ProgressDialog(this);
     mProgressDialog.setCancelable(false);*/
}