Skip to content Skip to sidebar Skip to footer

Dynamically Add More Cards In A List Row Android Tv Leanback

I am working on a Android TV app for quite some time now and I have come far while working on it. I am trying to develop an app like popcorn time but it's for Google nexus TV box.

Solution 1:

To add items to a presenter;

CardPresenterchannelCardPresenter=newCardPresenter();
ArrayObjectAdapterchannelRowAdapter=newArrayObjectAdapter(channelCardPresenter);
channelRowAdapter.add(newMovie("Movie Title"));
HeaderItemheader=newHeaderItem(0, "My Channels");
mRowsAdapter.add(newListRow(header, channelRowAdapter));

Of course this may only work for the first time you're creating the UI. Future times may not do this. In my app, https://github.com/Fleker/CumulusTV/blob/master/app/src/main/java/com/felkertech/n/tv/LeanbackFragment.java, I create a method that will be called each time I want to do a full redraw of the app:

public void refreshUI() {
    prepareBackgroundManager();
    setupUIElements();
    loadRows(); //Generate and populate all the rowssetupEventListeners();
}

Solution 2:

I have been working with android TV Leanback library from past 7 or 8 months. And I have developed my own presenter class via which you can load more cards dynamically on scroll, but its not possible using Leanback Library, ListAdapter updateds a single row and than move to next category to update it's cards. which take time on run time.

I have used the below answer to create my own presenter class. The Trick while implementing endless loading on scroll is that you have to create two AysncTasks.

Have a look at at post 34

Lazy download images into gridView

it will a little time taking but you will get the idea.

Post a Comment for "Dynamically Add More Cards In A List Row Android Tv Leanback"