diff --git a/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/BrowseViewModel.kt b/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/BrowseViewModel.kt index 5b6faa2b..77faed63 100644 --- a/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/BrowseViewModel.kt +++ b/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/BrowseViewModel.kt @@ -69,6 +69,8 @@ class BrowseViewModel( .getAllSync() .map { it.eventGuid } } + fun getPromotedEvents(): LiveData> = database.eventDao().findPromotedEvents() + private fun updateAndGetEventsForGuids(guidProvider: ()->List):LiveData>{ val result = MutableLiveData>() handler.runOnBackgroundThread { diff --git a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/fragments/ConferencesBrowseFragment.java b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/fragments/ConferencesBrowseFragment.java index dace9809..816cdcdd 100644 --- a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/fragments/ConferencesBrowseFragment.java +++ b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/fragments/ConferencesBrowseFragment.java @@ -93,6 +93,7 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment { watchListAdapter = new ChaosflixEventAdapter(eventPresenter); inProgressAdapter = new ChaosflixEventAdapter(eventPresenter); + promotedAdapter = new ChaosflixEventAdapter(eventPresenter); streamingSection = new SectionRow(new HeaderItem(getString(R.string.livestreams))); streamsDivider = new DividerRow(); @@ -105,10 +106,13 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment { rowsAdapter.add(streamsDivider); // Recomendations - rowsAdapter.add(recomendationsSectionsRow); + Row promotedRow = new ListRow(new HeaderItem("Promoted"), promotedAdapter); watchlistRow = new ListRow(new HeaderItem(getString(R.string.watchlist)), watchListAdapter); - rowsAdapter.add(watchlistRow); inProgressRow = new ListRow(new HeaderItem("Continue Watching"), inProgressAdapter); + + rowsAdapter.add(recomendationsSectionsRow); + rowsAdapter.add(promotedRow); + rowsAdapter.add(watchlistRow); rowsAdapter.add(inProgressRow); rowsAdapter.add(recomendationsDivider); @@ -170,6 +174,12 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment { } }); + viewModel.getPromotedEvents().observe(this, (promoted) -> { + if(promoted != null){ + promotedAdapter.setItems(promoted, eventDiffCallback); + } + }); + viewModel.getLivestreams().observe(this, liveConferences -> { if (liveConferences != null) { // if (BuildConfig.DEBUG) {