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

please Open to use Country #136

Closed
user32338 opened this issue Dec 4, 2017 · 7 comments
Closed

please Open to use Country #136

user32338 opened this issue Dec 4, 2017 · 7 comments

Comments

@user32338
Copy link

Hi!
I need use in my custom Fragment (Search Toolbar + RecyclerView) your Country Database)
so please open our class Country or CountryAdapter)

@Flo354
Copy link

Flo354 commented Dec 7, 2017

Hi,

I am facing the same situation. I would like to store in my database the country code extracted from the chosen country (I can do that), and after, when I retrieve the country code, display the country name (without using the . It would be awesome if this class was usable outside the package.

As a temporary workaround for my case, I created a class com.hbb20.MyCountry (which is in the same package so accessible and containing the following code:

package com.hbb20;

import android.content.Context;
import java.util.Locale;

public class MyCountry {

    private Country country;

    private MyCountry(Country country) {
        this.country = country;
    }

    public String getName() {
        return country.getName();
    }

    public static MyCountry fromCodeName(Context context, String codeName) {
        Locale currentLocale = context.getResources().getConfiguration().locale;

        CountryCodePicker.Language chosenLanguage = null;
        for (CountryCodePicker.Language language : CountryCodePicker.Language.values()) {
            if (language.getCode().equalsIgnoreCase(currentLocale.getLanguage())) {
                chosenLanguage = language;
            }
        }

        if (chosenLanguage == null) {
            chosenLanguage = CountryCodePicker.Language.ENGLISH;
        }

        return new MyCountry(Country.getCountryForNameCodeFromLibraryMasterList(context, chosenLanguage, codeName));
    }
}

@user32338
Copy link
Author

so, this is not good))
if the structure changes, you will have to change this class((
I think better do fork..

@Flo354
Copy link

Flo354 commented Dec 7, 2017

Yes, you are right. But as I said, it is only a temporary workaround. By doing this I don't need to fork, sync the changes and publish my own library to maven, which is time consuming compared to the 10 minutes I took to make this class.

It works for now and with some luck the author will open the class so I can get rid of this class in the near future :)

@hbb20
Copy link
Owner

hbb20 commented Dec 7, 2017

Sorry for the trouble it is causing to you people. As this was not my own use case so I never realized need to make country class open. I will open this class and release the new version (along with other pending features) soon. If you can wait for a week then it will good enough for me.

@Flo354
Copy link

Flo354 commented Dec 7, 2017

Thanks @hbb20 !

Actually, your library is much more powerful than just letting us pick some country or write number formatted as we type. You solve such a headache with your library :p

@hbb20
Copy link
Owner

hbb20 commented Dec 14, 2017

Please try v2.1.1. Please note that name of the class is changed to CCPCountry from Country to avoid any possible confusion. Please let me know if you want something else. Thanks

@hbb20 hbb20 closed this as completed Dec 14, 2017
@Flo354
Copy link

Flo354 commented Dec 14, 2017

Thanks @hbb20, works well!

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

3 participants