Skip to content
Snippets Groups Projects
Commit 258a5895 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

TV: Prevent NPE on play click with no ViewModel

Fix #891
parent edabe272
No related branches found
No related tags found
No related merge requests found
Pipeline #7292 passed with stage
in 3 minutes and 54 seconds
......@@ -47,7 +47,7 @@ class SearchFragment : SearchSupportFragment(), SearchSupportFragment.SearchResu
private val rowsAdapter = ArrayObjectAdapter(ListRowPresenter())
private val defaultItemClickedListener: OnItemViewClickedListener
get() = OnItemViewClickedListener { _, item, _, row ->
get() = OnItemViewClickedListener { _, item, _, _ ->
if (item is MediaWrapper) TvUtil.openMedia(requireActivity(), item, null)
else TvUtil.openAudioCategory(requireActivity(), item as MediaLibraryItem)
requireActivity().finish()
......
......@@ -131,11 +131,11 @@ object TvUtil {
intent.putExtra(KEY_GROUP, title)
activity.startActivity(intent)
}
else -> {
val list = (model!!.dataset.value as List<MediaWrapper>).filter { it.type != MediaWrapper.TYPE_DIR }
else -> model?.run {
val list = (dataset.value as List<MediaWrapper>).filter { it.type != MediaWrapper.TYPE_DIR }
val position = list.getposition(item)
MediaUtils.openList(activity, list, position)
}
} ?: MediaUtils.openMedia(activity, item)
}
is DummyItem -> when {
item.id == HEADER_STREAM -> activity.startActivity(Intent(activity, DialogActivity::class.java).setAction(DialogActivity.KEY_STREAM)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment