Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5148] Crash on MediaGalleryPreviewActivity #5387

Merged
merged 3 commits into from
Aug 30, 2024
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 @@ -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
Loading