Search in sources :

Example 1 with VideoGroupObjectAdapter

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

the class PlaybackFragment method getSuggestionsIndex.

@Override
public int getSuggestionsIndex(VideoGroup group) {
    if (mRowsAdapter == null) {
        Log.e(TAG, "Related videos row not initialized yet.");
        return -1;
    }
    VideoGroupObjectAdapter existingAdapter = mMediaGroupAdapters.get(group.getId());
    int index = -1;
    for (int i = 0; i < mRowsAdapter.size(); i++) {
        Object row = mRowsAdapter.get(i);
        if (row instanceof ListRow) {
            ObjectAdapter adapter = ((ListRow) row).getAdapter();
            if (adapter == existingAdapter) {
                index = mRowsAdapter.indexOf(row);
                break;
            }
        }
    }
    return index != -1 ? index - 1 : -1;
}
Also used : ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter) ObjectAdapter(androidx.leanback.widget.ObjectAdapter) VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter) VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter) ListRow(androidx.leanback.widget.ListRow)

Example 2 with VideoGroupObjectAdapter

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

the class SearchFragment method updateSearch.

@Override
public void updateSearch(VideoGroup group) {
    int titleRes;
    if (group.getVideos() != null) {
        mResultsFound = true;
        titleRes = R.string.search_results;
    } else {
        mResultsFound = false;
        titleRes = R.string.no_search_results;
    }
    if (mRowsAdapter.size() == 0) {
        HeaderItem header = new HeaderItem(getString(titleRes, mQuery));
        mAdapter = new VideoGroupObjectAdapter(group, mCardPresenter);
        ListRow row = new ListRow(header, mAdapter);
        mRowsAdapter.add(row);
    } else {
        mAdapter.append(group);
    }
}
Also used : VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter) HeaderItem(androidx.leanback.widget.HeaderItem) ListRow(androidx.leanback.widget.ListRow)

Example 3 with VideoGroupObjectAdapter

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

the class SearchTagsFragment method clearSearch.

@Override
public void clearSearch() {
    mSearchQuery = null;
    for (VideoGroupObjectAdapter adapter : mSearchGroupAdapters.values()) {
        adapter.clear();
    }
    mSearchGroupAdapters.clear();
    ObjectAdapter resultsAdapter = getResultsAdapter();
    if (resultsAdapter == null) {
        return;
    }
    int size = resultsAdapter.size();
    for (int i = 0; i < size; i++) {
        // Notify about changes (could help with search autofocus)
        // first adapter is tag adapter
        detachAdapter(1);
    }
}
Also used : ObjectAdapter(androidx.leanback.widget.ObjectAdapter) VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter) VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter)

Example 4 with VideoGroupObjectAdapter

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

the class VideoGridFragment method setupAdapter.

private void setupAdapter() {
    VerticalGridPresenter presenter = new CustomVerticalGridPresenter();
    presenter.setNumberOfColumns(GridFragmentHelper.getMaxColsNum(getContext(), R.dimen.card_width, mVideoGridScale));
    setGridPresenter(presenter);
    if (mGridAdapter == null) {
        mGridAdapter = new VideoGroupObjectAdapter(mCardPresenter);
        setAdapter(mGridAdapter);
    }
}
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 5 with VideoGroupObjectAdapter

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

the class PlaybackFragment method getSuggestedItemIndex.

private int getSuggestedItemIndex() {
    if (getVideo() == null || !getVideo().hasPlaylist() || !getVideo().hasVideo()) {
        return -1;
    }
    // NOTE: skip first row. It's PlaybackControlsRow
    Object row = mRowsAdapter != null && mRowsAdapter.size() > 1 ? mRowsAdapter.get(1) : null;
    if (row instanceof ListRow) {
        VideoGroupObjectAdapter adapter = (VideoGroupObjectAdapter) ((ListRow) row).getAdapter();
        int index = adapter.indexOfAlt(getVideo());
        // select last possible item on fail
        return index == -1 ? adapter.size() - 1 : index;
    }
    return -1;
}
Also used : VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter) 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