diff --git a/.gradle/5.4.1/executionHistory/executionHistory.bin b/.gradle/5.4.1/executionHistory/executionHistory.bin index dc6626f..3092c30 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/fileHashes/fileHashes.bin b/.gradle/5.4.1/fileHashes/fileHashes.bin index e82e135..750c19e 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 8dbf9bb..76fe77a 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 7a75793..2c79a87 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 a61aacf..ffc3bc2 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 cdbdadd..9e606ee 100644 Binary files a/.gradle/5.4.1/javaCompile/jarAnalysis.bin and b/.gradle/5.4.1/javaCompile/jarAnalysis.bin differ diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5548923..e4c3b67 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,7 +6,6 @@ - @@ -18,11 +17,10 @@ - - + - + - - + + - + - - + + @@ -118,8 +116,8 @@ - - + + @@ -198,7 +196,6 @@ @@ -423,7 +421,7 @@ - + @@ -431,13 +429,13 @@ - + - + @@ -609,20 +607,17 @@ - + - - + + - + - - - - - + + @@ -641,46 +636,49 @@ - + - - + + + - + - - + + - + - - + + + + + - - - + + - + - - + + - + - - + + diff --git a/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt b/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt index a0da114..7666faa 100644 --- a/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt +++ b/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt @@ -26,7 +26,6 @@ class MainActivity : AppCompatActivity(), OnCountryPickedListener { val fm = supportFragmentManager val newFragment = com.ccc.ccp.CountryCodePickerFragment.getInstance(country, Locale.getDefault().language) - newFragment.setOnCountryPickedListener(this) newFragment.show(fm, com.ccc.ccp.CountryCodePickerFragment.TAG) } } diff --git a/ccp/.gitignore b/ccp/.gitignore index 796b96d..4396a95 100644 --- a/ccp/.gitignore +++ b/ccp/.gitignore @@ -1 +1,11 @@ +*.iml +.gradle +/local.properties +/.idea +/release +/keystores +.DS_Store /build +/captures +.externalNativeBuild +.cxx diff --git a/ccp/src/main/java/com/ccc/ccp/CountryCodePickerFragment.kt b/ccp/src/main/java/com/ccc/ccp/CountryCodePickerFragment.kt index 9e16315..677064b 100644 --- a/ccp/src/main/java/com/ccc/ccp/CountryCodePickerFragment.kt +++ b/ccp/src/main/java/com/ccc/ccp/CountryCodePickerFragment.kt @@ -1,6 +1,6 @@ package com.ccc.ccp -import android.app.Dialog +import android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -18,6 +18,20 @@ class CountryCodePickerFragment : DialogFragment(), CountryCodeAdapter.OnItemCli private var mOnCountryPicked: OnCountryPickedListener? = null + override fun onAttach(context: Context) { + super.onAttach(context) + if (mOnCountryPicked == null && context is OnCountryPickedListener) { + mOnCountryPicked = context + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + if (mOnCountryPicked == null && parentFragment is OnCountryPickedListener) { + mOnCountryPicked = parentFragment as? OnCountryPickedListener + } + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -70,7 +84,12 @@ 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.updateData( + Country.loadCountryDataFromXML( + context, + arguments?.getString("LanguageCode") ?: Locale.getDefault().language + ) + ) mAdapter.setOnItemClickListener(this) }