From 9e4395ea80c075b9d0703c065007ea3718491796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Huba=CC=81lek?= Date: Tue, 7 Dec 2021 10:26:47 +0100 Subject: [PATCH] Closed zeugma-solutions#32 --- .../androidx/appcompat/app/LocaleHelperAppCompatDelegate.kt | 6 ++++-- .../zeugmasolutions/localehelper/LocaleHelperActivities.kt | 6 +----- .../zeugmasolutions/localehelper/LocaleHelperDelegates.kt | 3 --- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/localehelper/src/main/java/androidx/appcompat/app/LocaleHelperAppCompatDelegate.kt b/localehelper/src/main/java/androidx/appcompat/app/LocaleHelperAppCompatDelegate.kt index 62ba91c..64f8fed 100644 --- a/localehelper/src/main/java/androidx/appcompat/app/LocaleHelperAppCompatDelegate.kt +++ b/localehelper/src/main/java/androidx/appcompat/app/LocaleHelperAppCompatDelegate.kt @@ -54,8 +54,10 @@ class LocaleHelperAppCompatDelegate(private val superDelegate: AppCompatDelegate override fun addContentView(v: View?, lp: ViewGroup.LayoutParams?) = superDelegate.addContentView(v, lp) - override fun attachBaseContext2(context: Context) = - wrap(superDelegate.attachBaseContext2(super.attachBaseContext2(context))) + override fun attachBaseContext2(originalContext: Context): Context { + val superDelegateContext = super.attachBaseContext2(originalContext) + return wrap(superDelegateContext) + } override fun setTitle(title: CharSequence?) = superDelegate.setTitle(title) diff --git a/localehelper/src/main/java/com/zeugmasolutions/localehelper/LocaleHelperActivities.kt b/localehelper/src/main/java/com/zeugmasolutions/localehelper/LocaleHelperActivities.kt index 6f182c2..d2ad231 100644 --- a/localehelper/src/main/java/com/zeugmasolutions/localehelper/LocaleHelperActivities.kt +++ b/localehelper/src/main/java/com/zeugmasolutions/localehelper/LocaleHelperActivities.kt @@ -12,11 +12,7 @@ open class LocaleAwareCompatActivity : AppCompatActivity() { override fun getDelegate() = localeDelegate.getAppCompatDelegate(super.getDelegate()) - override fun attachBaseContext(newBase: Context) { - super.attachBaseContext(localeDelegate.attachBaseContext(newBase)) - } - - override fun onCreate(savedInstanceState: Bundle?) { + override fun onCreate(savedInstanceState: Bundle?) { localeDelegate.onCreate(this) super.onCreate(savedInstanceState) } diff --git a/localehelper/src/main/java/com/zeugmasolutions/localehelper/LocaleHelperDelegates.kt b/localehelper/src/main/java/com/zeugmasolutions/localehelper/LocaleHelperDelegates.kt index 5e76f2c..84f3c8a 100644 --- a/localehelper/src/main/java/com/zeugmasolutions/localehelper/LocaleHelperDelegates.kt +++ b/localehelper/src/main/java/com/zeugmasolutions/localehelper/LocaleHelperDelegates.kt @@ -10,7 +10,6 @@ import java.util.Locale interface LocaleHelperActivityDelegate { fun setLocale(activity: Activity, newLocale: Locale) - fun attachBaseContext(newBase: Context): Context fun onPaused() fun onResumed(activity: Activity) fun onCreate(activity: Activity) @@ -41,8 +40,6 @@ class LocaleHelperActivityDelegateImpl : LocaleHelperActivityDelegate { activity.recreate() } - override fun attachBaseContext(newBase: Context): Context = LocaleHelper.onAttach(newBase) - override fun getApplicationContext(applicationContext: Context): Context = applicationContext override fun onPaused() {