Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Add try catch to prevent the crashing from bad parcelable exception #111

Merged
merged 1 commit into from
May 11, 2021
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 @@ -5,6 +5,7 @@ import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.content.res.Resources
import android.os.BadParcelableException
import android.os.Handler
import android.os.Looper
import java.util.*
Expand Down Expand Up @@ -106,10 +107,14 @@ open class LocalizationActivityDelegate(val activity: Activity) {
// Check that bundle come from locale change.
// 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) ?: false
if (isLocalizationChanged) {
this.isLocalizationChanged = true
activity.intent?.removeExtra(KEY_ACTIVITY_LOCALE_CHANGED)
try {
val isLocalizationChanged = activity.intent?.getBooleanExtra(KEY_ACTIVITY_LOCALE_CHANGED, false) ?: false
if (isLocalizationChanged) {
this.isLocalizationChanged = true
activity.intent?.removeExtra(KEY_ACTIVITY_LOCALE_CHANGED)
}
} catch (e: BadParcelableException) {
e.printStackTrace()
}
}

Expand Down