Skip to content

Commit

Permalink
Merge pull request #6 from barrywe7/Collator
Browse files Browse the repository at this point in the history
Introduce Collator
  • Loading branch information
EKami authored Aug 3, 2016
2 parents f2d5542 + 2f1dc41 commit b979f64
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:2.1.0'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
minSdkVersion 10
targetSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
Expand All @@ -29,5 +29,5 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:23.4.0'
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Wed May 18 08:34:14 BST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
12 changes: 7 additions & 5 deletions src/main/java/com/heetch/countrypicker/CountryPickerDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.widget.ListView;

import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -38,6 +37,7 @@ public CountryPickerDialog(Context context, CountryPickerCallbacks callbacks, @N
/**
* You can set the heading country in headingCountryCode to show
* your favorite country as the head of the list
*
* @param context
* @param callbacks
* @param headingCountryCode
Expand All @@ -52,10 +52,12 @@ public CountryPickerDialog(Context context, CountryPickerCallbacks callbacks,
Collections.sort(countries, new Comparator<Country>() {
@Override
public int compare(Country country1, Country country2) {
return new Locale(getContext().getResources().getConfiguration().locale.getLanguage(),
country1.getIsoCode()).getDisplayCountry().compareTo(
new Locale(getContext().getResources().getConfiguration().locale.getLanguage(),
country2.getIsoCode()).getDisplayCountry());
final Locale locale = getContext().getResources().getConfiguration().locale;
final Collator collator = Collator.getInstance(locale);
collator.setStrength(Collator.PRIMARY);
return collator.compare(
new Locale(locale.getLanguage(), country1.getIsoCode()).getDisplayCountry(),
new Locale(locale.getLanguage(), country2.getIsoCode()).getDisplayCountry());
}
});
}
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/heetch/countrypicker/Utils.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.heetch.countrypicker;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import org.apache.http.HttpEntity;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.InputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -45,7 +41,7 @@ public static JSONObject getCountriesJSON(Context context) {
}

public static List<Country> parseCountries(JSONObject jsonCountries) {
List<Country> countries = new ArrayList<Country>();
List<Country> countries = new ArrayList<>();
Iterator<String> iter = jsonCountries.keys();

while (iter.hasNext()) {
Expand Down

0 comments on commit b979f64

Please sign in to comment.