Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Country Code for Phone? #21

Open
rchockxm opened this issue Apr 15, 2015 · 1 comment
Open

Country Code for Phone? #21

rchockxm opened this issue Apr 15, 2015 · 1 comment

Comments

@rchockxm
Copy link

Hi,

I made a point of being used and modified to support mobile phone country code.

strings_countries.xml

<string name="countries">eyJJTSI6IjQ0O0lzbGUgb2YgTWFuIiwiSFIiOiIzODU7Q3JvYXRpYSIsIkdXIjoiMjQ1O0d1aW5lYS1CaXNzYXUiLCJJTiI6IjkxO0luZGlhIiwiS0UiOiIyNTQ7S2VueWEiLCJMQSI6Ijg1NjtMYW9zIiwiSU8iOiJCcml0aXNoIEluZGlhbiBPY2VhbiBUZXJyaXRvcnkiLCJIVCI6IjUwOTtIYWl0aSIsIkxCIjoiOTYxO0xlYmFub24iLCJHWSI6IjU5MjtHdXlhbmEiLCJLRyI6Ijk5NjtLeXJneXpzdGFuIiwiSFUiOiIzNjtIdW5nYXJ5IiwiTEMiOiJTYWludCBMdWNpYSIsIklRIjoiOTY0O0lyYXEiLCJLSCI6Ijg1NTtDYW1ib2RpYSIsIkpNIjoiSmFtYWljYSIsIklSIjoiOTg7SXJhbiIsIktJIjoiNjg2O0tpcmliYXRpIiwiSVMiOiJJY2VsYW5kIiwiTUEiOiIyMTI7TW9yb2NjbyIsIkpPIjoiOTYyO0pvcmRhbiIsIklUIjoiMzk7SXRhbHkiLCJKUCI6IjgxO0phcGFuIiwiTUMiOiIzNzc7TW9uYWNvIiwiS00iOiIyNjk7Q29tb3JvcyIsIk1EIjoiMzczO01vbGRvdmEiLCJMSSI6IjQyMztMaWVjaHRlbnN0ZWluIiwiS04iOiJTYWludCBLaXR0cyAmIE5ldmlzIiwiTUUiOiIzODI7TW9udGVuZWdybyIsIk5BIjoiMjY0O05hbWliaWEiLCJNRiI6IlN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iLCJJTCI6Ijk3MjtJc3JhZWwifQ==</string>

Country.java

public String getName() {
    String lpszName = name;

    if (name != null && name.isEmpty() == false) {
        String[] lpszNames = name.split(";");

        if (lpszNames.length == 2) {
            lpszName = lpszNames[1].trim();
        }
    }

    return lpszName;
}

public String getCountryCode() {
    String lpszName = "";

    if (name != null && name.isEmpty() == false) {
        String[] lpszNames = name.split(";");

        if (lpszNames.length == 2) {
            lpszName = lpszNames[0].trim();
        }
    }

    return lpszName;
}

CountryPickerListener.java

public interface CountryPickerListener {
public void onSelectCountry(String name, String code, String ccode);
}

CountryPicker.java

    countryListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            if (listener != null) {
                Country country = selectedCountriesList.get(position);
                listener.onSelectCountry(country.getName(),
                        country.getCode(),
                        country.getCountryCode()
                );
            }
        }
    });

MainActivity.java

    // Test Country Code Select
    m_CountryCodePicker = CountryPicker.newInstance("Select Country");
    m_CountryCodePicker.setListener(new CountryPickerListener() {

        @Override
        public void onSelectCountry(String name, String code, String ccode) {

            Toast.makeText(
                    getActivity(),
                    "Country Name: " + name + " - Code: " + code
                            + " - Ccode: " + ccode
                            + " - Currency: "
                            + CountryPicker.getCurrencyCode(code),
                    Toast.LENGTH_SHORT).show();

            m_CountryCodePicker.dismiss();
        }
    });

    m_CountryCodePicker.show(getActivity().getSupportFragmentManager(), "COUNTRY_PICKER");

Regards,
Rchockxm

@dmsherazi
Copy link

It would be better to fork the repo and make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants