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

Commit

Permalink
Merge pull request #111 from akexorcist/issue/bad-parcelable-exception
Browse files Browse the repository at this point in the history
Add try catch to prevent the crashing from bad parcelable exception
  • Loading branch information
akexorcist authored May 11, 2021
2 parents 02d72e7 + aea5ddf commit 1381696
Showing 1 changed file with 9 additions and 4 deletions.
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

0 comments on commit 1381696

Please sign in to comment.