androidx.leanback.widget.HeaderItem Java Examples

The following examples show how to use androidx.leanback.widget.HeaderItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CardExampleFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
private Row createCardRow(final CardRow cardRow) {
    switch (cardRow.getType()) {
        case CardRow.TYPE_SECTION_HEADER:
            return new SectionRow(new HeaderItem(cardRow.getTitle()));
        case CardRow.TYPE_DIVIDER:
            return new DividerRow();
        case CardRow.TYPE_DEFAULT:
        default:
            // Build main row using the ImageCardViewPresenter.
            PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenterSelector);
            for (Card card : cardRow.getCards()) {
                listRowAdapter.add(card);
            }
            return new CardListRow(new HeaderItem(cardRow.getTitle()), listRowAdapter, cardRow);
    }
}
 
Example #2
Source File: EnhancedBrowseFragment.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) {
    if (showViews) {
        HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), mApplication.getString(R.string.lbl_views));

        GridButtonPresenter mGridPresenter = new GridButtonPresenter();
        ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
        switch (itemTypeString) {
            case "Movie":
                gridRowAdapter.add(new GridButton(SUGGESTED, mApplication.getString(R.string.lbl_suggested), R.drawable.tile_suggestions));
                addStandardViewButtons(gridRowAdapter);
                break;
            case "MusicAlbum":
                gridRowAdapter.add(new GridButton(ALBUMS, TvApp.getApplication().getString(R.string.lbl_albums), R.drawable.tile_audio));
                gridRowAdapter.add(new GridButton(ARTISTS, TvApp.getApplication().getString(R.string.lbl_artists), R.drawable.tile_artists));
                gridRowAdapter.add(new GridButton(GENRES, mApplication.getString(R.string.lbl_genres), R.drawable.tile_genres));
                gridRowAdapter.add(new GridButton(SEARCH, mApplication.getString(R.string.lbl_search), R.drawable.tile_search));
                break;
            default:
                addStandardViewButtons(gridRowAdapter);
                break;
        }
        rowAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    }

}
 
Example #3
Source File: BrowseViewFragment.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) {
    if (isLiveTvLibrary) {
        //Views row
        HeaderItem gridHeader = new HeaderItem(mRowsAdapter.size(), mApplication.getString(R.string.lbl_views));

        GridButtonPresenter mGridPresenter = new GridButtonPresenter();
        ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
        gridRowAdapter.add(new GridButton(TvApp.LIVE_TV_RECORDINGS_OPTION_ID, TvApp.getApplication().getResources().getString(R.string.lbl_recorded_tv), R.drawable.tile_port_record));
        if (mApplication.canManageRecordings()) {
            gridRowAdapter.add(new GridButton(TvApp.LIVE_TV_SCHEDULE_OPTION_ID, TvApp.getApplication().getResources().getString(R.string.lbl_schedule), R.drawable.tile_port_time));
            gridRowAdapter.add(new GridButton(TvApp.LIVE_TV_SERIES_OPTION_ID, TvApp.getApplication().getResources().getString(R.string.lbl_series), R.drawable.tile_port_series_timer));
        }

        mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    } else {
        super.addAdditionalRows(rowAdapter);
    }
}
 
Example #4
Source File: BrowseFolderFragment.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) {
    super.addAdditionalRows(rowAdapter);
    if (showViews) {
        HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), mApplication.getString(R.string.lbl_views));

        GridButtonPresenter mGridPresenter = new GridButtonPresenter();
        ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
        gridRowAdapter.add(new GridButton(BY_LETTER, mApplication.getString(R.string.lbl_by_letter), R.drawable.tile_letters));
        if (itemTypeString != null && itemTypeString.equals("Movie"))
            gridRowAdapter.add(new GridButton(SUGGESTED, mApplication.getString(R.string.lbl_suggested), R.drawable.tile_suggestions));
        gridRowAdapter.add(new GridButton(GENRES, mApplication.getString(R.string.lbl_genres), R.drawable.tile_genres));
        gridRowAdapter.add(new GridButton(PERSONS, mApplication.getString(R.string.lbl_performers), R.drawable.tile_actors));
        rowAdapter.add(new ListRow(gridHeader, gridRowAdapter));
    }
}
 
Example #5
Source File: FullDetailsActivity.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
private void addInfoRows(ArrayObjectAdapter adapter) {
    if (TvApp.getApplication().getUserPreferences().get(UserPreferences.Companion.getDebuggingEnabled()) && mBaseItem.getMediaSources() != null) {
        for (MediaSourceInfo ms : mBaseItem.getMediaSources()) {
            if (ms.getMediaStreams() != null && ms.getMediaStreams().size() > 0) {
                HeaderItem header = new HeaderItem("Media Details"+(ms.getContainer() != null ? " (" +ms.getContainer()+")" : ""));
                ArrayObjectAdapter infoAdapter = new ArrayObjectAdapter(new InfoCardPresenter());
                for (MediaStream stream : ms.getMediaStreams()) {
                    infoAdapter.add(stream);
                }

                adapter.add(new ListRow(header, infoAdapter));

            }
        }
    }
}
 
Example #6
Source File: SelectServerFragment.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) {
    super.addAdditionalRows(rowAdapter);

    HeaderItem serverHeader = new HeaderItem(rowAdapter.size(), mApplication.getString(R.string.lbl_select_server));
    ItemRowAdapter serverAdapter = new ItemRowAdapter(mServers.toArray(new ServerInfo[0]), new CardPresenter(), rowAdapter);
    serverAdapter.Retrieve();
    rowAdapter.add(new ListRow(serverHeader, serverAdapter));

    HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), mApplication.getString(R.string.lbl_other_options));

    GridButtonPresenter mGridPresenter = new GridButtonPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(new GridButton(ENTER_MANUALLY, mApplication.getString(R.string.lbl_enter_manually), R.drawable.tile_edit));
    rowAdapter.add(new ListRow(gridHeader, gridRowAdapter));
}
 
Example #7
Source File: ItemRowAdapter.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
public void removeRow() {
    if (mParent == null) {
        // just clear us
        clear();
        return;
    }

    if (mParent.size() == 1) {
        // we will be removing the last row - show something and prevent the framework from crashing
        // because there is nowhere for focus to land
        ArrayObjectAdapter emptyRow = new ArrayObjectAdapter(new TextItemPresenter());
        emptyRow.add(TvApp.getApplication().getString(R.string.lbl_no_items));
        mParent.add(new ListRow(new HeaderItem(TvApp.getApplication().getString(R.string.lbl_empty)), emptyRow));
    }

    mParent.remove(mRow);
}
 
Example #8
Source File: ImageRowHeaderPresenter.java    From LeanbackTvSample with MIT License 6 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    HeaderItem headerItem = item == null ? null : ((Row) item).getHeaderItem();
    if (headerItem == null) {
        if ( viewHolder.view.findViewById(R.id.row_header) != null) {
            ((TextView)viewHolder.view.findViewById(R.id.row_header)).setText(null);
        }
        viewHolder.view.setContentDescription(null);
        viewHolder.view.setVisibility(View.GONE);

    } else {
        if (viewHolder.view.findViewById(R.id.row_header) != null) {
            ((TextView)viewHolder.view.findViewById(R.id.row_header)).setText(headerItem.getName());
        }
        viewHolder.view.setContentDescription(headerItem.getContentDescription());
        viewHolder.view.setVisibility(View.VISIBLE);
    }
}
 
Example #9
Source File: SearchFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    int titleRes;
    if (cursor != null && cursor.moveToFirst()) {
        mResultsFound = true;
        titleRes = R.string.search_results;
    } else {
        mResultsFound = false;
        titleRes = R.string.no_search_results;
    }
    mVideoCursorAdapter.changeCursor(cursor);
    HeaderItem header = new HeaderItem(getString(titleRes, mQuery));
    mRowsAdapter.clear();
    ListRow row = new ListRow(header, mVideoCursorAdapter);
    mRowsAdapter.add(row);
}
 
Example #10
Source File: ProviderTvFragment.java    From xipl with Apache License 2.0 6 votes vote down vote up
/**
 * Shows the different rows of the Fragment.
 */
private void showRows() {
    Map<String, RowsSupportFragment> tempMap = getFragmentMap();
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());

    int i = 0;

    for (Map.Entry<String, RowsSupportFragment> entry : tempMap.entrySet()) {
        HeaderItem header = new HeaderItem(i, entry.getKey());
        PageRow row = new PageRow(header);
        mRowsAdapter.add(row);
        mFragmentSparseArray.append(i, entry.getValue());
        i++;
    }

    setAdapter(mRowsAdapter);
}
 
Example #11
Source File: PlaybackFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
private ArrayObjectAdapter initializeRelatedVideosRow() {
    /*
     * To add a new row to the mPlayerAdapter and not lose the controls row that is provided by the
     * glue, we need to compose a new row with the controls row and our related videos row.
     *
     * We start by creating a new {@link ClassPresenterSelector}. Then add the controls row from
     * the media player glue, then add the related videos row.
     */
    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    presenterSelector.addClassPresenter(
            mPlayerGlue.getControlsRow().getClass(), mPlayerGlue.getPlaybackRowPresenter());
    presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());

    ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(presenterSelector);

    rowsAdapter.add(mPlayerGlue.getControlsRow());

    HeaderItem header = new HeaderItem(getString(R.string.related_movies));
    ListRow row = new ListRow(header, mVideoCursorAdapter);
    rowsAdapter.add(row);

    setOnItemViewClickedListener(new ItemViewClickedListener());

    return rowsAdapter;
}
 
Example #12
Source File: PlaybackFragment.java    From androidtv-Leanback with Apache License 2.0 6 votes vote down vote up
private ArrayObjectAdapter initializeRelatedVideosRow() {
    /*
     * To add a new row to the mPlayerAdapter and not lose the controls row that is provided by the
     * glue, we need to compose a new row with the controls row and our related videos row.
     *
     * We start by creating a new {@link ClassPresenterSelector}. Then add the controls row from
     * the media player glue, then add the related videos row.
     */
    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    presenterSelector.addClassPresenter(
            mPlayerGlue.getControlsRow().getClass(), mPlayerGlue.getPlaybackRowPresenter());
    presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());

    ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(presenterSelector);

    rowsAdapter.add(mPlayerGlue.getControlsRow());

    HeaderItem header = new HeaderItem(getString(R.string.related_movies));
    ListRow row = new ListRow(header, mVideoCursorAdapter);
    rowsAdapter.add(row);

    setOnItemViewClickedListener(new ItemViewClickedListener());

    return rowsAdapter;
}
 
Example #13
Source File: PageAndListRowFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
private void createRows() {
    HeaderItem headerItem1 = new HeaderItem(HEADER_ID_1, HEADER_NAME_1);
    PageRow pageRow1 = new PageRow(headerItem1);
    mRowsAdapter.add(pageRow1);

    HeaderItem headerItem2 = new HeaderItem(HEADER_ID_2, HEADER_NAME_2);
    PageRow pageRow2 = new PageRow(headerItem2);
    mRowsAdapter.add(pageRow2);

    HeaderItem headerItem3 = new HeaderItem(HEADER_ID_3, HEADER_NAME_3);
    PageRow pageRow3 = new PageRow(headerItem3);
    mRowsAdapter.add(pageRow3);

    HeaderItem headerItem4 = new HeaderItem(HEADER_ID_4, HEADER_NAME_4);
    PageRow pageRow4 = new PageRow(headerItem4);
    mRowsAdapter.add(pageRow4);
}
 
Example #14
Source File: SearchFragment.java    From androidtv-Leanback with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    int titleRes;
    if (cursor != null && cursor.moveToFirst()) {
        mResultsFound = true;
        titleRes = R.string.search_results;
    } else {
        mResultsFound = false;
        titleRes = R.string.no_search_results;
    }
    mVideoCursorAdapter.changeCursor(cursor);
    HeaderItem header = new HeaderItem(getString(titleRes, mQuery));
    mRowsAdapter.clear();
    ListRow row = new ListRow(header, mVideoCursorAdapter);
    mRowsAdapter.add(row);
}
 
Example #15
Source File: VodTvSectionFragment.java    From xipl with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a new {@link ArrayObjectAdapter} for a new VOD content category
 *
 * @param tempMap the map used to retrieve contents
 * @param group the name of the VOD content group
 */
private void addContentRow(Map<String, List<AvContent>> tempMap, String group) {
    if (mRowsAdapter != null) {
        ArrayObjectAdapter arrayObjectAdapter = new ArrayObjectAdapter(new CardViewPresenter(getImageProcessor()));
        HeaderItem header = new HeaderItem(group);
        arrayObjectAdapter.addAll(0, tempMap.get(group));
        mRowsAdapter.add(new ListRow(header, arrayObjectAdapter));
    }
}
 
Example #16
Source File: TvManager.java    From jellyfin-androidtv with GNU General Public License v2.0 5 votes vote down vote up
private static void addRow(List<BaseItemDto> timers, Presenter presenter, ArrayObjectAdapter rowAdapter) {
    ItemRowAdapter scheduledAdapter = new ItemRowAdapter(timers, presenter, rowAdapter, true);
    scheduledAdapter.Retrieve();
    ListRow scheduleRow = new ListRow(new HeaderItem(TimeUtils.getFriendlyDate(TimeUtils.convertToLocalDate(timers.get(0).getStartDate()), true)), scheduledAdapter);
    rowAdapter.add(scheduleRow);

}
 
Example #17
Source File: VideoDetailsFragment.java    From androidtv-Leanback with Apache License 2.0 5 votes vote down vote up
private void setupMovieListRow() {
    String subcategories[] = {getString(R.string.related_movies)};

    // Generating related video list.
    String category = mSelectedVideo.category;

    Bundle args = new Bundle();
    args.putString(VideoContract.VideoEntry.COLUMN_CATEGORY, category);
    getLoaderManager().initLoader(RELATED_VIDEO_LOADER, args, this);

    HeaderItem header = new HeaderItem(0, subcategories[0]);
    mAdapter.add(new ListRow(header, mVideoCursorAdapter));
}
 
Example #18
Source File: FullDetailsActivity.java    From jellyfin-androidtv with GNU General Public License v2.0 5 votes vote down vote up
protected void addItemRow(ArrayObjectAdapter parent, ItemRowAdapter row, int index, String headerText) {
    HeaderItem header = new HeaderItem(index, headerText);
    ListRow listRow = new ListRow(header, row);
    parent.add(listRow);
    row.setRow(listRow);
    row.Retrieve();
}
 
Example #19
Source File: IconHeaderItemPresenter.java    From androidtv-Leanback with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    HeaderItem headerItem = ((ListRow) item).getHeaderItem();
    View rootView = viewHolder.view;
    rootView.setFocusable(true);

    ImageView iconView = (ImageView) rootView.findViewById(R.id.header_icon);
    Drawable icon = rootView.getResources().getDrawable(R.drawable.android_header, null);
    iconView.setImageDrawable(icon);

    TextView label = (TextView) rootView.findViewById(R.id.header_label);
    label.setText(headerItem.getName());
}
 
Example #20
Source File: BrowseRecordingsFragment.java    From jellyfin-androidtv with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) {
    HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), mApplication.getString(R.string.lbl_views));

    GridButtonPresenter mGridPresenter = new GridButtonPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(new GridButton(SCHEDULE, TvApp.getApplication().getString(R.string.lbl_schedule), R.drawable.tile_port_time));
    gridRowAdapter.add(new GridButton(SERIES, mActivity.getString(R.string.lbl_series_recordings), R.drawable.tile_port_series_timer));
    rowAdapter.add(new ListRow(gridHeader, gridRowAdapter));
}
 
Example #21
Source File: HomeFragmentFooterRow.java    From jellyfin-androidtv with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void addToRowsAdapter(CardPresenter cardPresenter, ArrayObjectAdapter rowsAdapter) {
    HeaderItem header = new HeaderItem(rowsAdapter.size(), activity.getString(R.string.lbl_settings));
    GridButtonPresenter presenter = new GridButtonPresenter();

    ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenter);
    adapter.add(new GridButton(SETTINGS, activity.getString(R.string.lbl_settings), R.drawable.tile_settings));
    adapter.add(new GridButton(LOGOUT, activity.getString(R.string.lbl_logout), R.drawable.tile_logout));

    rowsAdapter.add(new ListRow(header, adapter));
}
 
Example #22
Source File: IconHeaderItemPresenter.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    HeaderItem headerItem = ((ListRow) item).getHeaderItem();
    View rootView = viewHolder.view;
    rootView.setFocusable(true);

    ImageView iconView = (ImageView) rootView.findViewById(R.id.header_icon);
    Drawable icon = rootView.getResources().getDrawable(R.drawable.android_header, null);
    iconView.setImageDrawable(icon);

    TextView label = (TextView) rootView.findViewById(R.id.header_label);
    label.setText(headerItem.getName());
}
 
Example #23
Source File: VideoDetailsFragment.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
private void setupMovieListRow() {
    String subcategories[] = {getString(R.string.related_movies)};

    // Generating related video list.
    String category = mSelectedVideo.category;

    Bundle args = new Bundle();
    args.putString(VideoContract.VideoEntry.COLUMN_CATEGORY, category);
    getLoaderManager().initLoader(RELATED_VIDEO_LOADER, args, this);

    HeaderItem header = new HeaderItem(0, subcategories[0]);
    mAdapter.add(new ListRow(header, mVideoCursorAdapter));
}
 
Example #24
Source File: PageAndListRowFragment.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
private ListRow createCardRow(CardRow cardRow) {
    SettingsIconPresenter iconCardPresenter = new SettingsIconPresenter(getActivity());
    ArrayObjectAdapter adapter = new ArrayObjectAdapter(iconCardPresenter);
    for(Card card : cardRow.getCards()) {
        adapter.add(card);
    }

    HeaderItem headerItem = new HeaderItem(cardRow.getTitle());
    return new CardListRow(headerItem, adapter, cardRow);
}
 
Example #25
Source File: PageAndListRowFragment.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
private Row createCardRow(CardRow cardRow) {
    PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
    ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector);
    for (Card card : cardRow.getCards()) {
        adapter.add(card);
    }

    HeaderItem headerItem = new HeaderItem(cardRow.getTitle());
    return new CardListRow(headerItem, adapter, cardRow);
}
 
Example #26
Source File: RowModule.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
@Provides
@PerFragment
ListRow provideRelatedListRow(
        @ListAdapterForRelatedRowQualifier ListAdapter<VideoEntity> relatedRowAdapter) {

    HeaderItem mRelatedRowHeaderItem = new HeaderItem(RELATED_ROW);
    return new ListRow(mRelatedRowHeaderItem,relatedRowAdapter);
}
 
Example #27
Source File: StdBrowseFragment.java    From jellyfin-androidtv with GNU General Public License v2.0 4 votes vote down vote up
public void loadRows(List<BrowseRowDef> rows) {

        mRowsAdapter = new ArrayObjectAdapter(new PositionableListRowPresenter());
        mCardPresenter = new CardPresenter();

        for (BrowseRowDef def : rows) {
            HeaderItem header = new HeaderItem(def.getHeaderText());
            ItemRowAdapter rowAdapter;
            switch (def.getQueryType()) {
                case NextUp:
                    rowAdapter = new ItemRowAdapter(def.getNextUpQuery(), true, mCardPresenter, mRowsAdapter);
                    break;
                case LatestItems:
                    rowAdapter = new ItemRowAdapter(def.getLatestItemsQuery(), true, mCardPresenter, mRowsAdapter);
                    break;
                case Season:
                    rowAdapter = new ItemRowAdapter(def.getSeasonQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case Upcoming:
                    rowAdapter = new ItemRowAdapter(def.getUpcomingQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case Views:
                    rowAdapter = new ItemRowAdapter(new ViewQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case SimilarSeries:
                    rowAdapter = new ItemRowAdapter(def.getSimilarQuery(), QueryType.SimilarSeries, mCardPresenter, mRowsAdapter);
                    break;
                case SimilarMovies:
                    rowAdapter = new ItemRowAdapter(def.getSimilarQuery(), QueryType.SimilarMovies, mCardPresenter, mRowsAdapter);
                    break;
                case Persons:
                    rowAdapter = new ItemRowAdapter(def.getPersonsQuery(), def.getChunkSize(), mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvChannel:
                    rowAdapter = new ItemRowAdapter(def.getTvChannelQuery(), 40, mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvProgram:
                    rowAdapter = new ItemRowAdapter(def.getProgramQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvRecording:
                    rowAdapter = new ItemRowAdapter(def.getRecordingQuery(), def.getChunkSize(), mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvRecordingGroup:
                    rowAdapter = new ItemRowAdapter(def.getRecordingGroupQuery(), mCardPresenter, mRowsAdapter);
                    break;
                default:
                    rowAdapter = new ItemRowAdapter(def.getQuery(), def.getChunkSize(), def.getPreferParentThumb(), def.isStaticHeight(), mCardPresenter, mRowsAdapter, def.getQueryType());
                    break;
            }

            rowAdapter.setReRetrieveTriggers(def.getChangeTriggers());

            ListRow row = new ListRow(header, rowAdapter);
            mRowsAdapter.add(row);
            rowAdapter.setRow(row);
            rowAdapter.Retrieve();
        }

        addAdditionalRows(mRowsAdapter);

        setAdapter(mRowsAdapter);

    }
 
Example #28
Source File: EnhancedBrowseFragment.java    From jellyfin-androidtv with GNU General Public License v2.0 4 votes vote down vote up
public void loadRows(List<BrowseRowDef> rows) {

        mRowsAdapter = new ArrayObjectAdapter(new PositionableListRowPresenter());
        mCardPresenter = new CardPresenter(false, 280);
        ClassPresenterSelector ps = new ClassPresenterSelector();
        ps.addClassPresenter(BaseRowItem.class, mCardPresenter);
        ps.addClassPresenter(GridButton.class, new GridButtonPresenter(false, 310, 280));


        for (BrowseRowDef def : rows) {
            HeaderItem header = new HeaderItem(def.getHeaderText());
            ItemRowAdapter rowAdapter;
            switch (def.getQueryType()) {
                case NextUp:
                    rowAdapter = new ItemRowAdapter(def.getNextUpQuery(), true, mCardPresenter, mRowsAdapter);
                    break;
                case LatestItems:
                    rowAdapter = new ItemRowAdapter(def.getLatestItemsQuery(), true, mCardPresenter, mRowsAdapter);
                    break;
                case Season:
                    rowAdapter = new ItemRowAdapter(def.getSeasonQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case Upcoming:
                    rowAdapter = new ItemRowAdapter(def.getUpcomingQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case Views:
                    rowAdapter = new ItemRowAdapter(new ViewQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case SimilarSeries:
                    rowAdapter = new ItemRowAdapter(def.getSimilarQuery(), QueryType.SimilarSeries, mCardPresenter, mRowsAdapter);
                    break;
                case SimilarMovies:
                    rowAdapter = new ItemRowAdapter(def.getSimilarQuery(), QueryType.SimilarMovies, mCardPresenter, mRowsAdapter);
                    break;
                case Persons:
                    rowAdapter = new ItemRowAdapter(def.getPersonsQuery(), def.getChunkSize(), mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvChannel:
                    rowAdapter = new ItemRowAdapter(def.getTvChannelQuery(), 40, mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvProgram:
                    rowAdapter = new ItemRowAdapter(def.getProgramQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvRecording:
                    rowAdapter = new ItemRowAdapter(def.getRecordingQuery(), def.getChunkSize(), mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvRecordingGroup:
                    rowAdapter = new ItemRowAdapter(def.getRecordingGroupQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case Premieres:
                    rowAdapter = new ItemRowAdapter(def.getQuery(), def.getChunkSize(), def.getPreferParentThumb(), def.isStaticHeight(), mCardPresenter, mRowsAdapter, def.getQueryType());
                    break;
                case SeriesTimer:
                    rowAdapter = new ItemRowAdapter(def.getSeriesTimerQuery(), mCardPresenter, mRowsAdapter);
                    break;
                default:
                    rowAdapter = new ItemRowAdapter(def.getQuery(), def.getChunkSize(), def.getPreferParentThumb(), def.isStaticHeight(), ps, mRowsAdapter, def.getQueryType());
                    break;
            }

            rowAdapter.setReRetrieveTriggers(def.getChangeTriggers());

            ListRow row = new ListRow(header, rowAdapter);
            mRowsAdapter.add(row);
            rowAdapter.setRow(row);
            rowAdapter.Retrieve();
        }

        addAdditionalRows(mRowsAdapter);

        mRowsFragment.setAdapter(mRowsAdapter);

    }
 
Example #29
Source File: BrowseRecordingsFragment.java    From jellyfin-androidtv with GNU General Public License v2.0 4 votes vote down vote up
private void addNext24Timers() {
    final TimerQuery scheduled = new TimerQuery();
    final long ticks24 = 1000 * 60 * 60 * 24;
    TvApp.getApplication().getApiClient().GetLiveTvTimersAsync(scheduled, new Response<TimerInfoDtoResult>() {
        @Override
        public void onResponse(TimerInfoDtoResult response) {
            List<BaseItemDto> nearTimers = new ArrayList<>();
            long next24 = System.currentTimeMillis() + ticks24;
            //Get scheduled items for next 24 hours
            for (TimerInfoDto timer : response.getItems()) {
                if (TimeUtils.convertToLocalDate(timer.getStartDate()).getTime() <= next24) {
                    BaseItemDto programInfo = timer.getProgramInfo();
                    if (programInfo == null) {
                        programInfo = new BaseItemDto();
                        programInfo.setId(timer.getId());
                        programInfo.setChannelName(timer.getChannelName());
                        programInfo.setName(Utils.getSafeValue(timer.getName(), "Unknown"));
                        Timber.w("No program info for timer %s.  Creating one...", programInfo.getName());
                        programInfo.setBaseItemType(BaseItemType.Program);
                        programInfo.setTimerId(timer.getId());
                        programInfo.setSeriesTimerId(timer.getSeriesTimerId());
                        programInfo.setStartDate(timer.getStartDate());
                        programInfo.setEndDate(timer.getEndDate());
                    }
                    programInfo.setLocationType(LocationType.Virtual);
                    nearTimers.add(programInfo);
                }
            }
            if (nearTimers.size() > 0) {
                ItemRowAdapter scheduledAdapter = new ItemRowAdapter(nearTimers, mCardPresenter, mRowsAdapter, true);
                scheduledAdapter.Retrieve();
                ListRow scheduleRow = new ListRow(new HeaderItem("Scheduled in Next 24 Hours"), scheduledAdapter);
                mRowsAdapter.add(0, scheduleRow);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mRowsFragment.setSelectedPosition(0, true);
                    }
                }, 500);
            }
        }

        @Override
        public void onError(Exception exception) {
                Utils.showToast(mApplication, exception.getLocalizedMessage());
                }

    });
}
 
Example #30
Source File: CustomBrowseFragment.java    From jellyfin-androidtv with GNU General Public License v2.0 4 votes vote down vote up
public void loadRows(List<BrowseRowDef> rows) {

        mRowsAdapter = new ArrayObjectAdapter(new PositionableListRowPresenter());
        mCardPresenter = new CardPresenter();

        for (BrowseRowDef def : rows) {
            HeaderItem header = new HeaderItem(def.getHeaderText());
            ItemRowAdapter rowAdapter;
            switch (def.getQueryType()) {
                case NextUp:
                    rowAdapter = new ItemRowAdapter(def.getNextUpQuery(), true, mCardPresenter, mRowsAdapter);
                    break;
                case Season:
                    rowAdapter = new ItemRowAdapter(def.getSeasonQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case Upcoming:
                    rowAdapter = new ItemRowAdapter(def.getUpcomingQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case Views:
                    rowAdapter = new ItemRowAdapter(new ViewQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case SimilarSeries:
                    rowAdapter = new ItemRowAdapter(def.getSimilarQuery(), QueryType.SimilarSeries, mCardPresenter, mRowsAdapter);
                    break;
                case SimilarMovies:
                    rowAdapter = new ItemRowAdapter(def.getSimilarQuery(), QueryType.SimilarMovies, mCardPresenter, mRowsAdapter);
                    break;
                case Persons:
                    rowAdapter = new ItemRowAdapter(def.getPersonsQuery(), def.getChunkSize(), mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvChannel:
                    rowAdapter = new ItemRowAdapter(def.getTvChannelQuery(), 40, mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvProgram:
                    rowAdapter = new ItemRowAdapter(def.getProgramQuery(), mCardPresenter, mRowsAdapter);
                    break;
                case LiveTvRecording:
                    rowAdapter = new ItemRowAdapter(def.getRecordingQuery(), def.getChunkSize(), mCardPresenter, mRowsAdapter);
                    break;
                default:
                    rowAdapter = new ItemRowAdapter(def.getQuery(), def.getChunkSize(), def.getPreferParentThumb(), def.isStaticHeight(), mCardPresenter, mRowsAdapter);
                    break;
            }

            rowAdapter.setReRetrieveTriggers(def.getChangeTriggers());

            ListRow row = new ListRow(header, rowAdapter);
            mRowsAdapter.add(row);
            rowAdapter.setRow(row);
            rowAdapter.Retrieve();
        }

        addAdditionalRows(mRowsAdapter);

        mRowsFragment.setAdapter(mRowsAdapter);

    }