Leanback: add action to update streams

This commit is contained in:
Felix 2020-04-10 01:00:33 +02:00
parent 165f0fbd86
commit 61c9f13867
5 changed files with 14 additions and 7 deletions

View file

@ -1,5 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
<vector android:height="96dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
android:width="96dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M19.1,12.9a2.8,2.8 0,0 0,0.1 -0.9,2.8 2.8,0 0,0 -0.1,-0.9l2.1,-1.6a0.7,0.7 0,0 0,0.1 -0.6L19.4,5.5a0.7,0.7 0,0 0,-0.6 -0.2l-2.4,1a6.5,6.5 0,0 0,-1.6 -0.9l-0.4,-2.6a0.5,0.5 0,0 0,-0.5 -0.4H10.1a0.5,0.5 0,0 0,-0.5 0.4L9.3,5.4a5.6,5.6 0,0 0,-1.7 0.9l-2.4,-1a0.4,0.4 0,0 0,-0.5 0.2l-2,3.4c-0.1,0.2 0,0.4 0.2,0.6l2,1.6a2.8,2.8 0,0 0,-0.1 0.9,2.8 2.8,0 0,0 0.1,0.9L2.8,14.5a0.7,0.7 0,0 0,-0.1 0.6l1.9,3.4a0.7,0.7 0,0 0,0.6 0.2l2.4,-1a6.5,6.5 0,0 0,1.6 0.9l0.4,2.6a0.5,0.5 0,0 0,0.5 0.4h3.8a0.5,0.5 0,0 0,0.5 -0.4l0.3,-2.6a5.6,5.6 0,0 0,1.7 -0.9l2.4,1a0.4,0.4 0,0 0,0.5 -0.2l2,-3.4c0.1,-0.2 0,-0.4 -0.2,-0.6ZM12,15.6A3.6,3.6 0,1 1,15.6 12,3.6 3.6,0 0,1 12,15.6Z"/>
</vector>

View file

@ -18,7 +18,7 @@ import de.nicidienase.chaosflix.leanback.events.EventsActivity
import de.nicidienase.chaosflix.leanback.events.EventsActivity.Companion.start
import de.nicidienase.chaosflix.leanback.settings.ChaosflixSettingsActivity
class ItemViewClickedListener(private val fragment: Fragment) : OnItemViewClickedListener {
class ItemViewClickedListener(private val fragment: Fragment, private val streamUpdater: (()->Unit)? = null) : OnItemViewClickedListener {
override fun onItemClicked(itemViewHolder: Presenter.ViewHolder, item: Any, rowViewHolder: RowPresenter.ViewHolder?, row: Row?) {
Log.d(TAG, "onItemClicked")
val activity = fragment.requireActivity()
@ -54,6 +54,9 @@ class ItemViewClickedListener(private val fragment: Fragment) : OnItemViewClicke
LeakCanaryLauncher.launch(fragment.requireContext())
}
}
SelectableContentItem.UpdateStreams -> {
streamUpdater?.invoke()
}
}
}
}

View file

@ -5,5 +5,6 @@ import androidx.annotation.DrawableRes
enum class SelectableContentItem(val title: String, @DrawableRes val icon: Int, val data: Any? = null) {
Settings("Settings", R.drawable.ic_settings),
About("About", R.drawable.ic_info),
LeakCanary("Leak Canary", R.drawable.ic_warning)
LeakCanary("Leak Canary", R.drawable.ic_warning),
UpdateStreams("Update Streams", R.drawable.ic_refresh)
}

View file

@ -84,10 +84,13 @@ class ConferencesBrowseFragment : BrowseSupportFragment() {
rowsAdapter.add(conferencesSection)
onItemViewClickedListener = ItemViewClickedListener(this)
onItemViewClickedListener = ItemViewClickedListener(this){
viewModel.updateLiveStreams()
}
adapter = rowsAdapter
val listRowAdapter = ArrayObjectAdapter(settingsPresenter)
listRowAdapter.add(SelectableContentItem.UpdateStreams)
listRowAdapter.add(SelectableContentItem.Settings)
// listRowAdapter.add(SelectableContentItem.About)
if (BuildConfig.DEBUG) {

View file

@ -1,5 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
<vector android:height="96dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
android:width="96dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z"/>
</vector>