Leanback: add promoted Events

This commit is contained in:
Felix 2018-12-12 00:06:11 +01:00
parent efc2a42b62
commit a5ef33e75f
2 changed files with 14 additions and 2 deletions

View file

@ -69,6 +69,8 @@ class BrowseViewModel(
.getAllSync() .getAllSync()
.map { it.eventGuid } } .map { it.eventGuid } }
fun getPromotedEvents(): LiveData<List<PersistentEvent>> = database.eventDao().findPromotedEvents()
private fun updateAndGetEventsForGuids(guidProvider: ()->List<String>):LiveData<List<PersistentEvent>>{ private fun updateAndGetEventsForGuids(guidProvider: ()->List<String>):LiveData<List<PersistentEvent>>{
val result = MutableLiveData<List<PersistentEvent>>() val result = MutableLiveData<List<PersistentEvent>>()
handler.runOnBackgroundThread { handler.runOnBackgroundThread {

View file

@ -93,6 +93,7 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
watchListAdapter = new ChaosflixEventAdapter(eventPresenter); watchListAdapter = new ChaosflixEventAdapter(eventPresenter);
inProgressAdapter = new ChaosflixEventAdapter(eventPresenter); inProgressAdapter = new ChaosflixEventAdapter(eventPresenter);
promotedAdapter = new ChaosflixEventAdapter(eventPresenter);
streamingSection = new SectionRow(new HeaderItem(getString(R.string.livestreams))); streamingSection = new SectionRow(new HeaderItem(getString(R.string.livestreams)));
streamsDivider = new DividerRow(); streamsDivider = new DividerRow();
@ -105,10 +106,13 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
rowsAdapter.add(streamsDivider); rowsAdapter.add(streamsDivider);
// Recomendations // Recomendations
rowsAdapter.add(recomendationsSectionsRow); Row promotedRow = new ListRow(new HeaderItem("Promoted"), promotedAdapter);
watchlistRow = new ListRow(new HeaderItem(getString(R.string.watchlist)), watchListAdapter); watchlistRow = new ListRow(new HeaderItem(getString(R.string.watchlist)), watchListAdapter);
rowsAdapter.add(watchlistRow);
inProgressRow = new ListRow(new HeaderItem("Continue Watching"), inProgressAdapter); inProgressRow = new ListRow(new HeaderItem("Continue Watching"), inProgressAdapter);
rowsAdapter.add(recomendationsSectionsRow);
rowsAdapter.add(promotedRow);
rowsAdapter.add(watchlistRow);
rowsAdapter.add(inProgressRow); rowsAdapter.add(inProgressRow);
rowsAdapter.add(recomendationsDivider); 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 -> { viewModel.getLivestreams().observe(this, liveConferences -> {
if (liveConferences != null) { if (liveConferences != null) {
// if (BuildConfig.DEBUG) { // if (BuildConfig.DEBUG) {