Skip to content

Commit

Permalink
Merge pull request #11 from onstonboy/develop
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
onstonboy authored Sep 30, 2019
2 parents ec5b991 + b79148c commit 7c3c691
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 55 deletions.
Binary file modified .gradle/5.4.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/5.4.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/5.4.1/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/javaCompile/jarAnalysis.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
104 changes: 52 additions & 52 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MainActivity : AppCompatActivity(), OnCountryPickedListener {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

countryCodePicker.setCountryPicked(countryCodePicker.getDefaultCountryPicked())
countryCodePicker.setCountryPicked(countryCodePicker.getCountry(Locale.getDefault().country))
}

override fun onCountryPicked(country: Country) {
Expand Down
13 changes: 11 additions & 2 deletions ccp/src/main/java/com/ccc/ccp/CountryCodePicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ class CountryCodePicker : LinearLayout {

// Default country is Viet Nam
fun getDefaultCountryPicked(): Country {
val countries = Country.loadCountryDataFromXML(context, mLanguageCode)
countries.find { it.nameCode == "vn" }?.let {
if (mCountries.isEmpty()) {
mCountries.addAll(Country.loadCountryDataFromXML(context, mLanguageCode))
}
mCountries.find { it.nameCode == "vn" }?.let {
return it
}
if (mLanguageCode == "vi") {
Expand All @@ -94,6 +96,13 @@ class CountryCodePicker : LinearLayout {
return Country("vn", "+84", "VietNam")
}

fun getCountry(nameCode: String): Country {
if (mCountries.isEmpty()) {
mCountries.addAll(Country.loadCountryDataFromXML(context, mLanguageCode))
}
return mCountries.find { it.nameCode == nameCode.toLowerCase(Locale.getDefault()) } ?: getDefaultCountryPicked()
}

fun getCountryPicked(): Country? {
return mCountryPicked
}
Expand Down

0 comments on commit 7c3c691

Please sign in to comment.