Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thubalek committed Dec 7, 2021
1 parent b323a15 commit ef6833f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -104,4 +106,6 @@ class LocaleHelperAppCompatDelegate(private val superDelegate: AppCompatDelegate
override fun getLocalNightMode() = superDelegate.localNightMode

private fun wrap(context: Context): Context = LocaleHelper.onAttach(context)

override fun attachBaseContext(context: Context?) = superDelegate.attachBaseContext(context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.util.Locale

interface LocaleHelperActivityDelegate {
fun setLocale(activity: Activity, newLocale: Locale)
fun attachBaseContext(newBase: Context): Context
fun attachBaseContext2(newBase: Context): Context
fun onPaused()
fun onResumed(activity: Activity)
fun onCreate(activity: Activity)
Expand Down Expand Up @@ -41,7 +41,9 @@ class LocaleHelperActivityDelegateImpl : LocaleHelperActivityDelegate {
activity.recreate()
}

override fun attachBaseContext(newBase: Context): Context = LocaleHelper.onAttach(newBase)
override fun attachBaseContext2(newBase: Context): Context {
return LocaleHelper.onAttach(newBase)
}

override fun getApplicationContext(applicationContext: Context): Context = applicationContext

Expand Down

0 comments on commit ef6833f

Please sign in to comment.