Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.akexorcist.localizationactivity.core

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.content.res.Resources
import android.os.Build
Expand Down Expand Up @@ -137,10 +138,10 @@ open class LocalizationActivityDelegate(val activity: Activity) {
// If yes, bundle will be remove and set boolean flag to "true".
private fun checkBeforeLocaleChanging() {
val isLocalizationChanged =
activity.intent.getBooleanExtra(KEY_ACTIVITY_LOCALE_CHANGED, false)
activity.intent?.getBooleanExtra(KEY_ACTIVITY_LOCALE_CHANGED, false) ?: false
if (isLocalizationChanged) {
this.isLocalizationChanged = true
activity.intent.removeExtra(KEY_ACTIVITY_LOCALE_CHANGED)
activity.intent?.removeExtra(KEY_ACTIVITY_LOCALE_CHANGED)
}
}

Expand All @@ -162,6 +163,9 @@ open class LocalizationActivityDelegate(val activity: Activity) {
// Let's take it change! (Using recreate method that available on API 11 or more.
private fun notifyLanguageChanged() {
sendOnBeforeLocaleChangedEvent()
if (activity.intent == null)
activity.intent = Intent()

activity.intent.putExtra(KEY_ACTIVITY_LOCALE_CHANGED, true)
activity.recreate()
}
Expand Down