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

Fix: IndexOutOfBoundsException crash when removing last two images of multiupload #6124

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rohit9625
Copy link
Contributor

Description (required)

Fixes #6122

What changes did you make and why?
When removing images from Thumbnails Row, the uploadableImages property inside ThubnailsAdapter was not updating. It results in the image being removed at an invalid index and sometimes IndexOutOfBoundsException.
So, I added the code to notify the adapter that the image was removed.

Tests performed (required)

Tested ProdDebug on Samsung A14 with API level 34.

Screenshots (for UI changes only)
Screencast after fix

After_Fix.mp4

@nicolas-raoul
Copy link
Member

Looks great, thanks!
Sorry I just merged a pull request with UploadActivity.java moved to Kotlin, would you mind porting the change?

@rohit9625
Copy link
Contributor Author

Done 👍

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting this crash when trying to remove the middle picture, any idea what might be the issue? 🙂

APP_VERSION_NAME=5.1.2-debug-rohit9625-fix-multiupload
ANDROID_VERSION=15
PHONE_MODEL=Pixel 9 Pro
STACK_TRACE=kotlin.UninitializedPropertyAccessException: lateinit property basicKvStoreFactory has not been initialized
at fr.free.nrw.commons.upload.mediaDetails.UploadMediaPresenter.getBasicKvStoreFactory(UploadMediaPresenter.kt:54)
at fr.free.nrw.commons.upload.mediaDetails.UploadMediaPresenter.updateImageQualitiesJSON(UploadMediaPresenter.kt:366)
at fr.free.nrw.commons.upload.UploadPresenter.deletePictureAtIndex(UploadPresenter.kt:162)
at fr.free.nrw.commons.upload.UploadActivity.onThumbnailDeleted(UploadActivity.kt:776)
at fr.free.nrw.commons.upload.ThumbnailsAdapter$ViewHolder.bind$lambda$0(ThumbnailsAdapter.kt:72)
at fr.free.nrw.commons.upload.ThumbnailsAdapter$ViewHolder.$r8$lambda$h9qbE-GosgolnpmsfOlWqsny9oU(Unknown Source:0)
at fr.free.nrw.commons.upload.ThumbnailsAdapter$ViewHolder$$ExternalSyntheticLambda1.onClick(D8$$SyntheticClass:0)
at android.view.View.performClick(View.java:8081)
at android.view.View.performClickInternal(View.java:8058)
at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
at android.view.View$PerformClick.run(View.java:31517)
at android.os.Handler.handleCallback(Handler.java:991)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8934)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:591)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

@rohit9625
Copy link
Contributor Author

Doesn't happen on my device. What are the exact steps you followed?
Apart from that, I encountered another IndexOutOfBoundsException when deleting images from a 4-image upload. Using notifyDataSetChanged instead of notifyItemRemoved fixed the issue. Would you please try deleting images from a 4-image upload @nicolas-raoul?
I'll push the changes once confirmed.

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.

IndexOutOfBoundsException crash when removing last two images of multiupload
2 participants