From a32e5c2841dea20a3043dc3472ede0a9b15f4a33 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 11 Sep 2023 10:54:06 +0200 Subject: [PATCH] fix: crash when long pressing search result --- .../java/com/github/libretube/ui/adapters/SearchAdapter.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt index 994b60fb3..5fd7189e3 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt @@ -6,6 +6,7 @@ import androidx.core.os.bundleOf import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import com.github.libretube.R +import com.github.libretube.api.JsonHelper import com.github.libretube.api.obj.ContentItem import com.github.libretube.api.obj.StreamItem import com.github.libretube.constants.IntentData @@ -26,6 +27,7 @@ import com.github.libretube.ui.sheets.PlaylistOptionsBottomSheet import com.github.libretube.ui.sheets.VideoOptionsBottomSheet import com.github.libretube.ui.viewholders.SearchViewHolder import com.github.libretube.util.TextUtils +import kotlinx.serialization.encodeToString class SearchAdapter( private val isChannelAdapter: Boolean = false @@ -109,7 +111,9 @@ class SearchAdapter( notifyItemChanged(position) } val sheet = VideoOptionsBottomSheet() - sheet.arguments = bundleOf(IntentData.streamItem to item) + val contentItemString = JsonHelper.json.encodeToString(item) + val streamItem: StreamItem = JsonHelper.json.decodeFromString(contentItemString) + sheet.arguments = bundleOf(IntentData.streamItem to streamItem) sheet.show(fragmentManager, SearchAdapter::class.java.name) true }