Giter Site home page Giter Site logo

mukeshsolanki / country-picker-android Goto Github PK

View Code? Open in Web Editor NEW
323.0 9.0 136.0 37.07 MB

A simple library that displays a beautiful list of all the countries allowing the user to pick the country he wishes and provide details like country code, iso code name,currency and flag.

License: MIT License

Java 100.00%
country-picker country gradle android android-development

country-picker-android's Introduction

Hi, I'm Mukesh Solanki!

Linkedin Badge Twitter Badge Medium Badge Website Badge

Typing SVG

About Me

  • ⚡ Contribuing to a whole bunch of opensource projects.
  • 🖨️ I write tech articles almost every week on Medium.
  • 🌱 Always experimenting with bleading edge tech.
  • ⛰️ Love exploring and going on hikes

Latest Blog Posts

Github Stats

Mukesh Solanki's Github Stats Mukesh Solanki's Top Languages

country-picker-android's People

Contributors

indolia143 avatar kykrueger avatar lo-g avatar mukeshsolanki avatar orrinlife360 avatar vakabus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

country-picker-android's Issues

fast scrolling down throwing NoSuchFieldException

E/CountryCodePicker: Failure to get drawable id.
java.lang.NoSuchFieldException: flag_bl
at java.lang.Class.getField(Class.java:891)
at com.mukesh.countrypicker.adapters.CountryListAdapter.getResId(CountryListAdapter.java:30)
at com.mukesh.countrypicker.adapters.CountryListAdapter.getView(CountryListAdapter.java:76)
at android.widget.AbsListView.obtainView(AbsListView.java:2346)
at android.widget.ListView.makeAndAddView(ListView.java:1875)
at android.widget.ListView.fillDown(ListView.java:702)
at android.widget.ListView.fillGap(ListView.java:666)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5029)
at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4577)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

problem last update

recently with the last update i got this error
error: cannot find symbol class OnCountryPickerListener

Androidx support

I upgraded my app to use AndroidX, but it unfortunately didn't build because country-picker-android library isn't upgraded to use AndroidX.

Sorting countries does not work

Countries are always sorted by dial code. You are missing break at the end of each case in switch statement in sortCountries() method.

@Override public void sortCountries(@NonNull List<Country> countries) {
switch (sortBy) {
case SORT_BY_NAME:
Collections.sort(countries, new Comparator<Country>() {
@Override
public int compare(Country country1, Country country2) {
return country1.getName().trim().compareToIgnoreCase(country2.getName().trim());
}
});
case SORT_BY_ISO:
Collections.sort(countries, new Comparator<Country>() {
@Override
public int compare(Country country1, Country country2) {
return country1.getCode().trim().compareToIgnoreCase(country2.getCode().trim());
}
});
case SORT_BY_DIAL_CODE:
Collections.sort(countries, new Comparator<Country>() {
@Override
public int compare(Country country1, Country country2) {
return country1.getDialCode().trim().compareToIgnoreCase(country2.getDialCode().trim());
}
});
}
}

Need to show only few countries

Hi, Good job on this library.

Is that a way to limit the list ?
I want to let the user pick between only , maybe, 10 countries that i'v choosen.
(sorry for bad english)

Search EditText should not be Multiline

I want to use this library but only problem is your Search EditText is not single line. Can you look forward on this issue asap and set SingleLine property to true ?

Flag is Missing

Saint Barthelemy Flag i.e flag_bl is missing and keeps throwing "java.lang.NoSuchFieldException: flag_bl".
Check that out!

CraSh on Click of Spinner

java.lang.NoSuchFieldError: No static field row_title of type I in class Lcom/mukesh/countrypicker/R$id; or its superclasses (declaration of 'com.mukesh.countrypicker.R$id' appears in /data/app/in.ticketninja.test-gy1ogBf0PImNXdeOb5B9_A==/base.apk)
at com.mukesh.countrypicker.CountryListAdapter$Cell.from(CountryListAdapter.java:70)
at com.mukesh.countrypicker.CountryListAdapter.getView(CountryListAdapter.java:51)
at android.widget.AbsListView.obtainView(AbsListView.java:2372)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1408)
at android.widget.ListView.onMeasure(ListView.java:1315)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:721)
at android.view.View.measure(View.java:21998)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2410)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1471)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1751)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

No sim afghanistan country dial code missing +

private Country afghanistan() {
Country country = new Country();
country.setCode("AF");
country.setName("Afghanistan");
country.setDialCode("+93");
country.setFlag(R.drawable.flag_af);
return country;
}

Thanks.

Logo Proposal

Hello...

I came across your fantastic project and i wanted to help contribute to your project by using my Skills in Logo Design to contribute and help create a logo for your project...

I am already working on an idea... i will update what i have done here so you can give your feedback and possibly any change or tweek you may want...

you can also give your own idea...

Regards.

Crashing application on Show in Xamarin Android

Below are the steps I followed in my Xamarin Android project.

I have added the nuget package "Karamunting.Android.MukeshSolanki.CountryPickerAndroid" version="1.1.9" in my project.
Now I just want to display the country code picker dialog so I followed the following Csharp code
CountryPicker countryPicker = new CountryPicker();
countryPicker.Show(this.Activity.SupportFragmentManager, "COUNTRY_PICKER");
countryPicker.CountrySelect += (o, e) => {
// Perform action on click
};

App crashed on show

Country constructor is not public

How is it supposed to create my own Country (as described in README, to set custom list of countries, load country flag by iso, etc), if all constructors of Country class are package-access ?!

We need to open them and make convenient to use. We need Country.Builder() with setters and default value. Say, i need to show picker for provinces - i'd like to use CountryPicker, but with my own custom list of "countries" (provinces) without flags - just with names and some province codes. I'm not able to do that atm.

Cannot be used in fragment

picker.show(getSupportFragmentManager(), "CURRENCY_PICKER");

This line is giving me an error while using this in fragment

Change the color of Country Search EditText

Hello Mukesh,
I am developing an android app in which I want to integrate "Country Selector", I find your library truly amazing, but I am unable to change the color of it's search edittext.

Help !!
Thanks

RISHI

Feature, return country flag from country name or ISO code.

Hi,

When using your library I found myself needing to save the country flag selection in a database. I want to do this as country code or country name. Then when re-loading the view, I need to set the flag from the database (it is possible for the user to change the country from another platform). For this, I am proposing two public static methods.

getFlagFromCountryCode (String countryCode);
getFlagFromCountryName(String countryName);

I will fork the project, add the feature, and create a pull request when it is ready. I hope you are interested in integrating this functionality.

-- Kyle

style colors

I'm getting white text on white dialog background, how to style it?

white

Latest version

compile 'com.github.mukeshsolanki:country-picker-android:'
Couldn't find latest version :(

Search input is multiline

The EditText for search is multiline (it just shows one line at a time). This can be fixed by adding: android:inputType="text" to the country_code_picker_search EditText

Dialog doesn't close and select a country

I am using exactly the same code in the example.
The dialog shows properly, but when clicking a country for selection the dialog doesn't close and the event: "onSelectCountry" is not fired.

Sorting countries by name

The list is not sorted by the country name, is there a option or a feature that can do this, or do I need to sort it my self?

Change the color

Hi, thanks for the library. I want to change the background color from Black, which I'm currently getting to white which is there in the library image currently. How to do that?

method can not resolve

I'm trying to get country name in onCreate( ) method of activity and using getCountryFromSIM( ) method of CountryPicker to get the current country name of the user but its not resolving this method and showing "Cannot resolve method 'getCountryFromSIM(this)' .

can add one item more

is necessary can add more items to the list, for example i need add an item where this one is ALL COUNTRIES so when the user select this item i know he wants to filter all countries
because i am creating a filter with this library
this would be like your method setCountriesList() but instead put setCountry()
could you please add that ? :)

Carriage return can be entered into search bar

It's a minor issue, but users can press return on their soft keyboard to enter a carriage return, which then empties the results list. This could be solved pretty trivially with android:inputType="textShortMessage".

Mutlilingual

Hello,

First of all, awesome work :)
Is it possible to have the strings in another language? Is it english only? Thank you very much

Need reduce the dialog

Need to reduce the dialog when the keyboard is open because some countries have overlapping by keyboard.

P.S. Where is located a code of library?

Error in latest version

Hello,
Thanks for your breat Work

I followed all the steps but I'm getting this error

java.lang.NoSuchFieldError: No field country_flag of type I in class Lcom/mukesh/countrypicker/R$id; or its superclasses (declaration of 'com.mukesh.countrypicker.R$id' appears in /data/app/com.package.app/base.apk)

How can I fix this please ?

Crash On EditText Click

java.lang.NoSuchFieldError: No static field country_flag of type I in class Lcom/mukesh/countrypicker/R$id; or its superclasses (declaration of 'com.mukesh.countrypicker.R$id' appears in /data/app/com.imarad.app-2/base.apk) at com.mukesh.countrypicker.CountriesAdapter$ViewHolder.<init>(CountriesAdapter.java:67) at com.mukesh.countrypicker.CountriesAdapter.onCreateViewHolder(CountriesAdapter.java:36) at com.mukesh.countrypicker.CountriesAdapter.onCreateViewHolder(CountriesAdapter.java:14) at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6519) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5706) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1558) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3135) at android.view.View.measure(View.java) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java) at android.widget.LinearLayout.measureVertical(LinearLayout.java) at android.widget.LinearLayout.onMeasure(LinearLayout.java) at android.view.View.measure(View.java) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java) at android.widget.FrameLayout.onMeasure(FrameLayout.java) at android.view.View.measure(View.java) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java) at android.widget.FrameLayout.onMeasure(FrameLayout.java) at android.view.View.measure(View.java) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java) at android.widget.LinearLayout.measureVertical(LinearLayout.java) at android.widget.LinearLayout.onMeasure(LinearLayout.java) at android.view.View.measure(View.java) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java) at android.widget.FrameLayout.onMeasure(FrameLayout.java) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java) at android.view.View.measure(View.java) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java) at android.view.Choreographer$CallbackRecord.run(Choreographer.java) at android.view.Choreographer.doCallbacks(Choreographer.java) at android.view.Choreographer.doFrame(Choreographer.java) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java) at android.os.Handler.handleCallback(Handler.java) at android.os.Handler.dispatchMessage(Handler.java) at android.os.Looper.loop(Looper.java) at android.app.ActivityThread.main(ActivityThread.java) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
I am using Version 1.2.2 of the library.
Basically, I am doing an onClick on the EditText but I persistently get this error

Antartica has no currency

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.util.Currency.getSymbol()' on a null object reference

Pick Country Problem

Hello, when I click on "Pick Country" Button, it's showing just some countries not all of them, and they begin with "Z" countries.
Please Help

Ukraine locale

unable to use properly library with users from Ukraine, 'cos by Google standards Ukraine is shortened to uk (when we are extracting country from Locale) and NOT ua

Find crash on changing 5 to 6 times by picing country

FATAL EXCEPTION: main
java.lang.IllegalStateException: Fragment already added: CountryPicker{5321ceb8 #0 COUNTRY_PICKER}
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1679)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:727)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Keyboard down

Hi, how can I prevent the keyboard from popping up when I open the dialog?

problem last update 2.0.1

recently with the last update (2.0.1) i got this error
error: cannot find symbol class OnCountryPickerListener
.............................................................................................................
with problems with my internet i attached 2 same issues so i closed one

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.