diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 8578357b2..c36cc7191 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -320,7 +320,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { initZoomListener() val fastscroller = if (config.scrollHorizontally) media_horizontal_fastscroller else media_vertical_fastscroller MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid, fastscroller) { - itemClicked((it as Medium).path) + if (it is Medium) { + itemClicked(it.path) + } }.apply { setupZoomListener(mZoomListener) media_grid.adapter = this diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index f20d59461..eddf5d004 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -81,7 +81,8 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList + val allowLongPress = !allowMultiplePicks && tmbItem is Medium + val view = holder.bindView(tmbItem, allowLongPress) { itemView, adapterPosition -> if (tmbItem is Medium) { setupThumbnail(itemView, tmbItem) } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt index dbdd77856..1a45671cb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt @@ -64,8 +64,10 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c shownMedia = media val adapter = MediaAdapter(activity, shownMedia, null, true, false, view.media_grid, null) { - callback((it as Medium).path) - dialog.dismiss() + if (it is Medium) { + callback(it.path) + dialog.dismiss() + } } val scrollHorizontally = activity.config.scrollHorizontally && isGridViewType