Search in sources :

Example 6 with VideoGroupObjectAdapter

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

the class PlaybackFragment method updateSuggestions.

@Override
public void updateSuggestions(VideoGroup group) {
    if (mRowsAdapter == null) {
        Log.e(TAG, "Related videos row not initialized yet.");
        return;
    }
    HeaderItem rowHeader = new HeaderItem(group.getTitle());
    // Create unique int from category.
    int mediaGroupId = group.getId();
    VideoGroupObjectAdapter existingAdapter = mMediaGroupAdapters.get(mediaGroupId);
    if (existingAdapter == null) {
        VideoGroupObjectAdapter mediaGroupAdapter = new VideoGroupObjectAdapter(group, mCardPresenter);
        mMediaGroupAdapters.put(mediaGroupId, mediaGroupAdapter);
        ListRow row = new ListRow(rowHeader, mediaGroupAdapter);
        mRowsAdapter.add(row);
    } else {
        freeze(true);
        // continue row
        existingAdapter.append(group);
        freeze(false);
    }
}
Also used : VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter) HeaderItem(androidx.leanback.widget.HeaderItem) ListRow(androidx.leanback.widget.ListRow)

Example 7 with VideoGroupObjectAdapter

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

the class SearchTagsFragment method checkScrollEnd.

private void checkScrollEnd(Video item) {
    VideoGroupObjectAdapter resultsAdapter = getItemResultsAdapter(item);
    if (resultsAdapter == null) {
        return;
    }
    int size = resultsAdapter.size();
    int index = resultsAdapter.indexOf(item);
    if (index > (size - ViewUtil.ROW_SCROLL_CONTINUE_NUM)) {
        mSearchPresenter.onScrollEnd((Video) resultsAdapter.get(size - 1));
    }
}
Also used : VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter)

Example 8 with VideoGroupObjectAdapter

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

the class SearchTagsFragment method update.

public void update(VideoGroup group) {
    int action = group.getAction();
    if (action == VideoGroup.ACTION_REPLACE) {
        clearSearch();
    } else if (action == VideoGroup.ACTION_SYNC) {
        VideoGroupObjectAdapter adapter = mSearchGroupAdapters.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 = mSearchGroupAdapters.get(mediaGroupId);
    if (existingAdapter == null) {
        VideoGroupObjectAdapter mediaGroupAdapter = new VideoGroupObjectAdapter(group, mCardPresenter);
        mSearchGroupAdapters.put(mediaGroupId, mediaGroupAdapter);
        attachAdapter(getResultsAdapter().size(), rowHeader, mediaGroupAdapter);
    } else {
        Log.d(TAG, "Continue row %s %s", group.getTitle(), System.currentTimeMillis());
        freeze(true);
        // continue row
        existingAdapter.append(group);
        freeze(false);
    }
}
Also used : VideoGroupObjectAdapter(com.liskovsoft.smartyoutubetv2.tv.adapter.VideoGroupObjectAdapter) HeaderItem(androidx.leanback.widget.HeaderItem)

Example 9 with VideoGroupObjectAdapter

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

the class SearchTagsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    // Real restore takes place in the presenter
    super.onCreate(null);
    mIsFragmentCreated = true;
    mSearchPresenter = SearchPresenter.instance(getContext());
    mSearchPresenter.setView(this);
    mCardPresenter = new VideoCardPresenter();
    mSearchGroupAdapters = new HashMap<>();
    // mItemResultsAdapter = new VideoGroupObjectAdapter(mCardPresenter);
    mSearchData = SearchData.instance(getContext());
    setupEventListeners();
    // setItemResultsAdapter(mItemResultsAdapter);
    setSearchTagsProvider(new MediaServiceSearchTagProvider());
    enableKeyboardAutoShow(mSearchData.isKeyboardAutoShowEnabled());
}
Also used : MediaServiceSearchTagProvider(com.liskovsoft.smartyoutubetv2.common.app.models.search.MediaServiceSearchTagProvider) VideoCardPresenter(com.liskovsoft.smartyoutubetv2.tv.presenter.VideoCardPresenter)

Example 10 with VideoGroupObjectAdapter

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

the class ViewUtil method isListRowEmpty.

public static boolean isListRowEmpty(Object obj) {
    if (obj instanceof ListRow) {
        ListRow row = (ListRow) obj;
        VideoGroupObjectAdapter adapter = (VideoGroupObjectAdapter) row.getAdapter();
        return adapter == null || adapter.size() == 0;
    }
    return true;
}
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