Skip to content

Conversation

Kota-Jagadeesh
Copy link
Collaborator

This pull request addresses the crashes in the image upload flow of the app, specifically targeting issue #6404 (App crashes when switching between light and dark theme). Theese changes ensure that handling of activity recreation and state restoration, improving stability during theme changes, rotation, and process death.

Changes Made

  • UploadMediaPresenter.kt: Fixed IndexOutOfBoundsException in setUploadMediaDetails by adding validation for uploadItemIndex and uploadItems list size, preventing crashes when the list is empty during activity recreation .
  • UploadMediaDetailFragment.kt: Prevented IndexOutOfBoundsException by safely handling saved state and indexOfFragment in onViewCreated, ensuring setUploadMediaDetails is only called with valid data .
  • ImageFragment.kt: Resolved UninitializedPropertyAccessException by safely initializing and accessing imageAdapter in onCreateView, onDestroy, and other methods, adding checks for initialization state .
  • UploadActivity.kt: Fixed Unresolved reference: setImageToBeUploaded compilation error by replacing it with direct field assignments and deferred initializeFragment calls, ensuring proper fragment setup .

Verification

  • Tested on Android 14 with theme changes (light to dark and vice versa), rotation, and process death.
  • Verified thaat no crashes occur in CustomSelectorActivity, ImageFragment, UploadActivity, or UploadMediaDetailFragment.
  • Confirmed Logcat logs show proper initialization and state handling (e.g., "Initialized imageAdapter", "Set uploadMediaDetails for index X").

  • Added Timber logging across all changed files to aid debugging.

Closes #6404

@rohit9625
Copy link
Collaborator

Hmm, there are so many changes, I'll review it by tomorrow :)

@Kota-Jagadeesh
Copy link
Collaborator Author

Kota-Jagadeesh commented Oct 2, 2025

Hmm, there are so many changes, I'll review it by tomorrow :)

Hi @rohit9625 , just checking in - is this PR still under review, or would you like me to make any changes ?

@rohit9625
Copy link
Collaborator

rohit9625 commented Oct 4, 2025

Hmm, there are so many changes, I'll review it by tomorrow :)

Hi @rohit9625 , just checking in - is this PR still under review, or would you like me to make any changes ?

I didn't get time to review this, I wonder why there are so many changes to fix this tiny crash. Did you also refactor the code? I'll review this once done with 16KB compilation task :)

Meanwhile, please fix the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: App crashes when trying to change theme while at Upload screen with multi-upload
2 participants