Dynamically add more cards in a list Row android TV leanback
Asked Answered
S

2

1

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. The problem where I am stuck in, is really simple but even after a lot of effort I am still unable to figure out the solution. I am fetching the json data from my database which has all the movies details and links and this works perfectly fine. Over all app view

Now those who have used the you tube app on Android TV must have noticed that it was built on leanback and as you scroll down in a listrow more cards are added into a row and likewise the app made the json calls to fetch more data according to the category we are scrolling in. (that's what I want to do)

Right now it is impossible, if I request for large data it takes a long time to fetch everything from the server so I have devised a way via which I can make json calls on scroll but I am unable to present them in a listrow at runtime.

Sherronsherry answered 21/11, 2015 at 10:46 Comment(1)
Post your adapter code.! where you add json values to the adapter and the adapter to the listrowSeraphina
S
1

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.

Sherronsherry answered 1/8, 2016 at 11:1 Comment(0)
C
1

To add items to a presenter;

CardPresenter channelCardPresenter = new CardPresenter();
ArrayObjectAdapter channelRowAdapter = new ArrayObjectAdapter(channelCardPresenter);
channelRowAdapter.add(new Movie("Movie Title"));
HeaderItem header = new HeaderItem(0, "My Channels");
mRowsAdapter.add(new ListRow(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 rows
    setupEventListeners();
}
Collyrium answered 21/11, 2015 at 22:25 Comment(0)
S
1

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.

Sherronsherry answered 1/8, 2016 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.