Search in sources :

Example 11 with VideoGroupObjectAdapter

use of com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter in project SmartTubeNext by yuliskov.

the class MultiVideoGridFragment method setupAdapter.

private void setupAdapter() {
    // Left vertical list of channels
    VerticalGridPresenter presenter1 = new CustomVerticalGridPresenter(R.layout.lb_vertical_grid1, R.id.browse_grid1);
    presenter1.setNumberOfColumns(1);
    // Right grid of channel's content
    VerticalGridPresenter presenter2 = new CustomVerticalGridPresenter(R.layout.lb_vertical_grid2, R.id.browse_grid2);
    presenter2.setNumberOfColumns(GridFragmentHelper.getMaxColsNum(getContext(), R.dimen.card_width, mVideoGridScale) - 1);
    setGridPresenter1(presenter1);
    setGridPresenter2(presenter2);
    if (mGridAdapter1 == null) {
        mGridAdapter1 = new VideoGroupObjectAdapter(mCardPresenter1);
        setAdapter1(mGridAdapter1);
    }
    if (mGridAdapter2 == null) {
        mGridAdapter2 = new VideoGroupObjectAdapter(mCardPresenter2);
        setAdapter2(mGridAdapter2);
    }
}
Also used : CustomVerticalGridPresenter(com.liskovsoft.smartyoutubetv2.tv.presenter.CustomVerticalGridPresenter) VerticalGridPresenter(androidx.leanback.widget.VerticalGridPresenter) CustomVerticalGridPresenter(com.liskovsoft.smartyoutubetv2.tv.presenter.CustomVerticalGridPresenter) VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter)

Example 12 with VideoGroupObjectAdapter

use of com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter in project SmartTubeNext by yuliskov.

the class MultipleRowsFragment method update.

@Override
public void update(VideoGroup group) {
    if (mVideoGroupAdapters == null) {
        mPendingUpdates.add(group);
        return;
    }
    int action = group.getAction();
    if (action == VideoGroup.ACTION_REPLACE) {
        clear();
    } else if (action == VideoGroup.ACTION_REMOVE) {
        VideoGroupObjectAdapter adapter = mVideoGroupAdapters.get(group.getId());
        if (adapter != null) {
            adapter.remove(group);
        }
        return;
    } else if (action == VideoGroup.ACTION_SYNC) {
        VideoGroupObjectAdapter adapter = mVideoGroupAdapters.get(group.getId());
        if (adapter != null) {
            adapter.sync(group);
        }
        return;
    }
    if (group.isEmpty()) {
        return;
    }
    HeaderItem rowHeader = new HeaderItem(group.getTitle());
    // Create unique int from category.
    int mediaGroupId = group.getId();
    VideoGroupObjectAdapter existingAdapter = mVideoGroupAdapters.get(mediaGroupId);
    if (existingAdapter == null) {
        VideoGroupObjectAdapter mediaGroupAdapter = new VideoGroupObjectAdapter(group, mCardPresenter);
        mVideoGroupAdapters.put(mediaGroupId, mediaGroupAdapter);
        ListRow row = new ListRow(rowHeader, mediaGroupAdapter);
        if (group.getPosition() == -1) {
            mRowsAdapter.add(row);
        } else {
            mRowsAdapter.add(group.getPosition(), row);
        }
    } else {
        Log.d(TAG, "Continue row %s %s", group.getTitle(), System.currentTimeMillis());
        freeze(true);
        // continue row
        existingAdapter.append(group);
        freeze(false);
    }
    restorePosition();
}
Also used : VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter) HeaderItem(androidx.leanback.widget.HeaderItem) ListRow(androidx.leanback.widget.ListRow)

Aggregations

VideoGroupObjectAdapter (com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter)11 ListRow (androidx.leanback.widget.ListRow)6 HeaderItem (androidx.leanback.widget.HeaderItem)4 ObjectAdapter (androidx.leanback.widget.ObjectAdapter)2 VerticalGridPresenter (androidx.leanback.widget.VerticalGridPresenter)2 CustomVerticalGridPresenter (com.liskovsoft.smartyoutubetv2.tv.presenter.CustomVerticalGridPresenter)2 ArrayObjectAdapter (androidx.leanback.widget.ArrayObjectAdapter)1 MediaServiceSearchTagProvider (com.liskovsoft.smartyoutubetv2.common.app.models.search.MediaServiceSearchTagProvider)1 VideoCardPresenter (com.liskovsoft.smartyoutubetv2.tv.presenter.VideoCardPresenter)1