Merge pull request #4755 from Bnyro/master

fix: crash when long pressing search result
This commit is contained in:
Bnyro 2023-09-11 10:53:19 +02:00 committed by GitHub
commit a340de1fe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}