diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4396a95
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+*.iml
+.gradle
+/local.properties
+/.idea
+/release
+/keystores
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
diff --git a/.gradle/5.4.1/executionHistory/executionHistory.bin b/.gradle/5.4.1/executionHistory/executionHistory.bin
index 1e77e8c..140e5f0 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.bin and b/.gradle/5.4.1/executionHistory/executionHistory.bin differ
diff --git a/.gradle/5.4.1/executionHistory/executionHistory.lock b/.gradle/5.4.1/executionHistory/executionHistory.lock
index 8bc6206..43b1436 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.lock and b/.gradle/5.4.1/executionHistory/executionHistory.lock differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.bin b/.gradle/5.4.1/fileHashes/fileHashes.bin
index 9d61fc8..d6cd782 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.bin and b/.gradle/5.4.1/fileHashes/fileHashes.bin differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.lock b/.gradle/5.4.1/fileHashes/fileHashes.lock
index 0450c07..d32a90a 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.lock and b/.gradle/5.4.1/fileHashes/fileHashes.lock differ
diff --git a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin
index 5eabcb7..ee281d8 100644
Binary files a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin and b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/5.4.1/javaCompile/classAnalysis.bin b/.gradle/5.4.1/javaCompile/classAnalysis.bin
index 7c93f03..862dad8 100644
Binary files a/.gradle/5.4.1/javaCompile/classAnalysis.bin and b/.gradle/5.4.1/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/5.4.1/javaCompile/jarAnalysis.bin b/.gradle/5.4.1/javaCompile/jarAnalysis.bin
index 15e75ff..13e32db 100644
Binary files a/.gradle/5.4.1/javaCompile/jarAnalysis.bin and b/.gradle/5.4.1/javaCompile/jarAnalysis.bin differ
diff --git a/.gradle/5.4.1/javaCompile/javaCompile.lock b/.gradle/5.4.1/javaCompile/javaCompile.lock
index e87e60f..411277c 100644
Binary files a/.gradle/5.4.1/javaCompile/javaCompile.lock and b/.gradle/5.4.1/javaCompile/javaCompile.lock differ
diff --git a/.gradle/5.4.1/javaCompile/taskHistory.bin b/.gradle/5.4.1/javaCompile/taskHistory.bin
index 9108797..94bbb6b 100644
Binary files a/.gradle/5.4.1/javaCompile/taskHistory.bin and b/.gradle/5.4.1/javaCompile/taskHistory.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 8da5b97..719947a 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
index a327e30..6029a3a 100644
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index 31d208c..536444f 100644
Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_1_1_aar.xml b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_1_1_aar.xml
new file mode 100644
index 0000000..d0dc89c
--- /dev/null
+++ b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_1_1_aar.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_2_6_jar.xml b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_2_6_jar.xml
new file mode 100644
index 0000000..c2362de
--- /dev/null
+++ b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_2_6_jar.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_2_jar.xml b/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_2_jar.xml
new file mode 100644
index 0000000..a0a2fe7
--- /dev/null
+++ b/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_2_jar.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 881b207..4f9d78d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,7 +6,6 @@
-
@@ -38,60 +37,61 @@
-
-
+
+
-
-
-
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
@@ -99,14 +99,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
@@ -178,12 +193,9 @@
-
-
-
@@ -191,14 +203,18 @@
-
-
+
+
+
+
+
+
@@ -209,12 +225,33 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -250,49 +287,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -306,7 +307,7 @@
-
+
@@ -417,11 +418,10 @@
-
-
+
-
+
@@ -434,12 +434,12 @@
-
+
-
+
@@ -454,15 +454,9 @@
file://$PROJECT_DIR$/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt
- 16
-
-
-
-
- file://$PROJECT_DIR$/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt
- 28
+ 18
-
+
@@ -470,47 +464,47 @@
- countryCodePicker.getCountry(Locale.getDefault().country)
+ getCountryBaseSim()
kotlin
EXPRESSION
- country
+ getResources().getConfiguration().locale.
kotlin
EXPRESSION
- Locale.getDefault().country
+ getResources().getConfiguration().locale.displayCountry
kotlin
EXPRESSION
- mCountries
+ getResources().getConfiguration().locale.getCountry()
kotlin
EXPRESSION
- getFlagMasterResID(country)
+ countryCodePicker.getCountry(getResources().getConfiguration().locale.getCountry())
kotlin
EXPRESSION
- "ccp_$languageCode"
+ countryCodePicker.getCountry(Locale.getDefault().country)
kotlin
EXPRESSION
- xmlPullParser.name
+ country
kotlin
EXPRESSION
- xmlPullParser.
+ Locale.getDefault().country
kotlin
EXPRESSION
- xmlPullParser.END_TAG
+ mCountries
kotlin
EXPRESSION
@@ -554,13 +548,6 @@
-
-
-
-
-
-
-
@@ -576,13 +563,6 @@
-
-
-
-
-
-
-
@@ -597,20 +577,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -648,76 +614,114 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
diff --git a/app/app.iml b/app/app.iml
index 34dfce6..58a33e9 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -31,7 +31,7 @@
-
+
diff --git a/ccp/.gitignore b/ccp/.gitignore
index 4396a95..796b96d 100644
--- a/ccp/.gitignore
+++ b/ccp/.gitignore
@@ -1,11 +1 @@
-*.iml
-.gradle
-/local.properties
-/.idea
-/release
-/keystores
-.DS_Store
/build
-/captures
-.externalNativeBuild
-.cxx
diff --git a/ccp/build.gradle b/ccp/build.gradle
index 11301e3..ee87173 100644
--- a/ccp/build.gradle
+++ b/ccp/build.gradle
@@ -33,6 +33,8 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation "io.reactivex.rxjava2:rxjava:2.1.7"
+ implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation 'androidx.core:core-ktx:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
diff --git a/ccp/ccp.iml b/ccp/ccp.iml
index be0a58d..e049732 100644
--- a/ccp/ccp.iml
+++ b/ccp/ccp.iml
@@ -32,7 +32,7 @@
-
+
@@ -150,6 +150,8 @@
+
+
@@ -181,5 +183,6 @@
+
\ No newline at end of file
diff --git a/ccp/src/main/java/com/ccc/ccp/CountryCodePickerFragment.kt b/ccp/src/main/java/com/ccc/ccp/CountryCodePickerFragment.kt
index 677064b..46eda61 100644
--- a/ccp/src/main/java/com/ccc/ccp/CountryCodePickerFragment.kt
+++ b/ccp/src/main/java/com/ccc/ccp/CountryCodePickerFragment.kt
@@ -2,12 +2,17 @@ package com.ccc.ccp
import android.content.Context
import android.os.Bundle
+import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.ccc.ccp.utils.DimensionUtils
+import io.reactivex.Single
+import io.reactivex.android.schedulers.AndroidSchedulers
+import io.reactivex.observers.DisposableSingleObserver
+import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.fragment_country_code_picker.view.*
import java.util.*
@@ -43,13 +48,36 @@ class CountryCodePickerFragment : DialogFragment(), CountryCodeAdapter.OnItemCli
return mView
}
+ override fun onActivityCreated(savedInstanceState: Bundle?) {
+ super.onActivityCreated(savedInstanceState)
+ val context = context ?: return
+ Single.create> {
+ it.onSuccess(
+ Country.loadCountryDataFromXML(
+ context,
+ arguments?.getString("LanguageCode") ?: Locale.getDefault().language
+ )
+ )
+ }.subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(object : DisposableSingleObserver>() {
+ override fun onSuccess(data: List) {
+ mAdapter.updateData(data)
+ }
+
+ override fun onError(e: Throwable) {
+ Log.e(this::class.java.simpleName, "error", e)
+ }
+ })
+ }
+
override fun onResume() {
super.onResume()
val context = context ?: return
val params = dialog!!.window!!.attributes
params.width = (DimensionUtils.getDisplayWidth(context) / 1.15).toInt()
params.height = (DimensionUtils.getDisplayHeight(context) / 1.7).toInt()
- dialog!!.window!!.attributes = params as android.view.WindowManager.LayoutParams
+ dialog?.window?.attributes = params as android.view.WindowManager.LayoutParams
}
override fun onDestroy() {
@@ -84,12 +112,6 @@ class CountryCodePickerFragment : DialogFragment(), CountryCodeAdapter.OnItemCli
val manager = LinearLayoutManager(context)
mView.recyclerView.layoutManager = manager
mView.recyclerView.adapter = mAdapter
- mAdapter.updateData(
- Country.loadCountryDataFromXML(
- context,
- arguments?.getString("LanguageCode") ?: Locale.getDefault().language
- )
- )
mAdapter.setOnItemClickListener(this)
}