Skip to content

please Open to use Country #136

Closed
Closed

Description

@user32338

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

Activity

  1. Flo354 commented on Dec 7, 2017

    @Flo354

    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));
        }
    }
  2. user32338 commented on Dec 7, 2017

    @user32338
    Author

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

  3. Flo354 commented on Dec 7, 2017

    @Flo354

    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 :)

  4. hbb20 commented on Dec 7, 2017

    @hbb20
    Owner

    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.

  5. Flo354 commented on Dec 7, 2017

    @Flo354

    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

  6. hbb20 commented on Dec 14, 2017

    @hbb20
    Owner

    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

  7. Flo354 commented on Dec 14, 2017

    @Flo354

    Thanks @hbb20, works well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions