Skip to content

Commit

Permalink
[5148] Crash on MediaGalleryPreviewActivity (#5387)
Browse files Browse the repository at this point in the history
* [5148] Crash on MediaGalleryPreviewActivity

* fix spotless
  • Loading branch information
kanat authored Aug 30, 2024
1 parent d7cc860 commit 70da8ba
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ public class MediaGalleryPreviewActivity : AppCompatActivity() {
*/
private var fileSharingJob: Job? = null

/**
* The current state of the screen.
*/
private var uiState: MediaGalleryPreviewActivityState? = null

/**
* The ViewModel that exposes screen data.
*/
Expand All @@ -216,16 +221,18 @@ public class MediaGalleryPreviewActivity : AppCompatActivity() {
*/
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val mediaGalleryPreviewActivityState = intent?.getParcelableExtra<MediaGalleryPreviewActivityState>(

uiState = savedInstanceState?.getParcelable(
KeyMediaGalleryPreviewActivityState,
)
) ?: intent?.getParcelableExtra(KeyMediaGalleryPreviewActivityState)

val videoThumbnailsEnabled = intent?.getBooleanExtra(KeyVideoThumbnailsEnabled, true) ?: true
val streamCdnImageResizing = intent?.createStreamCdnImageResizing()
?: StreamCdnImageResizing.defaultStreamCdnImageResizing()
val messageId = mediaGalleryPreviewActivityState?.messageId ?: ""
val messageId = uiState?.messageId ?: ""

if (!mediaGalleryPreviewViewModel.hasCompleteMessage) {
val message = mediaGalleryPreviewActivityState?.toMessage()
val message = uiState?.toMessage()

if (message != null) {
mediaGalleryPreviewViewModel.message = message
Expand Down Expand Up @@ -257,6 +264,13 @@ public class MediaGalleryPreviewActivity : AppCompatActivity() {
}
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
uiState?.also {
outState.putParcelable(KeyMediaGalleryPreviewActivityState, it)
}
}

/**
* Responsible for updating the system UI.
*/
Expand Down

0 comments on commit 70da8ba

Please sign in to comment.