Skip to content

Commit 3842ba9

Browse files
committed
refactor: avoid checking fragment is currentSelectedPosition is out of bounds
1 parent 9002978 commit 3842ba9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,10 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
388388
fragments!!.removeAt(index) //Remove the corresponding fragment
389389
uploadableFiles.removeAt(index) //Remove the files from the list
390390

391-
if(fragments!![currentSelectedPosition] !is UploadMediaDetailFragment) {
391+
val isMediaDetailFragment = fragments!!.getOrNull(currentSelectedPosition)?.let {
392+
it is UploadMediaDetailFragment
393+
} ?: false
394+
if(!isMediaDetailFragment) {
392395
// Should hide the top card current fragment is not the media detail fragment
393396
showHideTopCard(false)
394397
}

0 commit comments

Comments
 (0)