Java 类android.support.v17.leanback.widget.HeaderItem 实例源码

项目:chaosflix-leanback    文件:OverlayFragment.java   
private Row getRelatedItems() {
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
    final Set<Long> related = mSelectedEvent.getMetadata().getRelated().keySet();
    mDisposables.add(((LeanbackBaseActivity) getActivity()).getApiServiceObservable()
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    mediaApiService -> {
                        for (long id : related) {
                            mDisposables.add(mediaApiService.getEvent(id)
                                    .observeOn(AndroidSchedulers.mainThread())
                                    .subscribe(event -> listRowAdapter.add(event)));
                        }
                        listRowAdapter.notifyArrayItemRangeChanged(0, listRowAdapter.size());
                    }
            )
    );
    HeaderItem header = new HeaderItem(0, getString(R.string.related_talks));
    return new ListRow(header, listRowAdapter);
}
项目:chaosflix-leanback    文件:HeaderItemPresenter.java   
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    HeaderItem headerItem = ((ListRow) item).getHeaderItem();
    View view = viewHolder.view;
    ImageView headerIcon = (ImageView) view.findViewById(R.id.header_icon);
    TextView headerLabel = (TextView) view.findViewById(R.id.header_label);

    Resources resources = view.getContext().getResources();
    String streamingPrefix = resources.getString(R.string.streaming_prefix);
    if (headerItem.getName().startsWith(streamingPrefix)) {
        Drawable camIcon = resources.getDrawable(R.drawable.ic_videocam_white_24dp);
        headerIcon.setImageDrawable(camIcon);
        ((ListRow) item).setHeaderItem(new HeaderItem(headerItem.getName()
                .substring(streamingPrefix.length())));
    } else {
        Drawable movieIcon = resources.getDrawable(R.drawable.ic_local_movies_white_24dp);
        headerIcon.setImageDrawable(movieIcon);
        headerLabel.setText(headerItem.getName());
    }
}
项目:androidtv-sample    文件:SearchFragment.java   
@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);
}
项目:chaosflix    文件:OverlayFragment.java   
private Row getRelatedItems() {
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
    final long[] related = mSelectedEvent.getMetadata().getRelated();
    mDisposables.add(((LeanbackBaseActivity) getActivity()).getApiServiceObservable()
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    mediaApiService -> {
                        for (long id : related) {
                            mDisposables.add(mediaApiService.getEvent(id)
                                    .observeOn(AndroidSchedulers.mainThread())
                                    .subscribe(event -> listRowAdapter.add(event)));
                        }
                        listRowAdapter.notifyArrayItemRangeChanged(0, listRowAdapter.size());
                    }
            )
    );
    HeaderItem header = new HeaderItem(0, getString(R.string.related_talks));
    return new ListRow(header, listRowAdapter);
}
项目:chaosflix    文件:ConferencesBrowseFragment.java   
private void addStreams(CardPresenter cardPresenter, List<LiveConference> liveConferences) {
        if (liveConferences.size() > 0) {
            HeaderItem streamingHeader = new HeaderItem(getString(R.string.livestreams));
            mStreamingSection = new SectionRow(streamingHeader);
            mRowsAdapter.add(0, mStreamingSection);
            for (LiveConference con : liveConferences) {
                if(!con.getConference().equals("Sendeschleife")){
                    int i = -1;
                    for (i = 0; i < con.getGroups().size(); i++) {
                        Group g = con.getGroups().get(i);
                        // setup header
                        String group = g.getGroup().length() > 0 ? g.getGroup() : con.getConference();
                        HeaderItem header = new HeaderItem(group);
                        header.setDescription(con.getConference() + " - " + con.getDescription());
                        header.setContentDescription(group);
                        // setup list
                        ArrayObjectAdapter listRowAdapter
                                = new ArrayObjectAdapter(cardPresenter);
                        listRowAdapter.addAll(listRowAdapter.size(), g.getRooms());
                        mRowsAdapter.add(i + 1, new ListRow(header, listRowAdapter));
                    }
                }
//              mRowsAdapter.add(i + 1, new DividerRow());
            }
        }
    }
项目:chaosflix    文件:HeaderItemPresenter.java   
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    HeaderItem headerItem = ((ListRow) item).getHeaderItem();
    View view = viewHolder.view;
    ImageView headerIcon = (ImageView) view.findViewById(R.id.header_icon);
    TextView headerLabel = (TextView) view.findViewById(R.id.header_label);

    Resources resources = view.getContext().getResources();
    String streamingPrefix = resources.getString(R.string.streaming_prefix);
    if (headerItem.getName().startsWith(streamingPrefix)) {
        Drawable camIcon = resources.getDrawable(R.drawable.ic_videocam_white_24dp);
        headerIcon.setImageDrawable(camIcon);
        ((ListRow) item).setHeaderItem(new HeaderItem(headerItem.getName()
                .substring(streamingPrefix.length())));
    } else {
        Drawable movieIcon = resources.getDrawable(R.drawable.ic_local_movies_white_24dp);
        headerIcon.setImageDrawable(movieIcon);
        headerLabel.setText(headerItem.getName());
    }
}
项目:chilly    文件:IconHeaderItemPresenter.java   
@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.icon_movies, null);
    iconView.setImageDrawable(icon);

    TextView label = (TextView) rootView.findViewById(R.id.header_label);
    label.setText(headerItem.getName());
}
项目:android_packages_apps_tv    文件:SeriesRecordingDetailsFragment.java   
private ListRow createNewSeasonRow(String seasonNumber, int position) {
    String seasonTitle = seasonNumber.isEmpty() ? mSeries.getTitle()
            : getString(R.string.dvr_detail_series_season_title, seasonNumber);
    HeaderItem header = new HeaderItem(mSeasonRowCount++, seasonTitle);
    ClassPresenterSelector selector = new ClassPresenterSelector();
    selector.addClassPresenter(RecordedProgram.class, mRecordedProgramPresenter);
    ListRow row = new ListRow(header, new SeasonRowAdapter(selector,
            new Comparator<RecordedProgram>() {
                @Override
                public int compare(RecordedProgram lhs, RecordedProgram rhs) {
                    return BaseProgram.EPISODE_COMPARATOR.compare(lhs, rhs);
                }
            }, seasonNumber));
    getRowsAdapter().add(position, row);
    return row;
}
项目:TvAppRepo    文件:MainFragment.java   
private void loadRows() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());

    mApkDownloadHelper = new ApkDownloadHelper(getActivity());
    // Setup the package installer for the session
    mApkDownloadHelper.addListener(mDownloadListener);
    HeaderItem header = null;

    if (getResources().getBoolean(R.bool.ENABLE_APP_REPO)) {
        createRowApkDownloads();
    }

    if (getResources().getBoolean(R.bool.ENABLE_DOWNLOADS_ROW)) {
        createRowDownloadedApks();
    }

    createRowShortcutGenerator();

    createRowCustomShortcuts();

    createRowMisc();

    setAdapter(mRowsAdapter);
}
项目:popcorn-android    文件:PTVOverviewFragment.java   
private void setupMoreMovies() {
    HeaderItem moreMoviesHeader = new HeaderItem(1, getString(R.string.more_movies));
    MorePresenter morePresenter = new MorePresenter(getActivity());
    ArrayObjectAdapter moreRowAdapter = new ArrayObjectAdapter(morePresenter);

    // add items
    List<MediaProvider.NavInfo> navigation = mMoviesProvider.getNavigation();
    for (MediaProvider.NavInfo info : navigation) {
        moreRowAdapter.add(new MorePresenter.MoreItem(
                info.getId(),
                info.getLabel(),
                info.getIcon(),
                info));
    }

    mRowsAdapter.add(new ListRow(moreMoviesHeader, moreRowAdapter));
}
项目:popcorn-android    文件:PTVOverviewFragment.java   
private void setupMoreTVShows() {
    HeaderItem moreHeader = new HeaderItem(1, getString(R.string.more_shows));
    MorePresenter morePresenter = new MorePresenter(getActivity());
    ArrayObjectAdapter moreRowAdapter = new ArrayObjectAdapter(morePresenter);

    // add items
    List<MediaProvider.NavInfo> navigation = mShowsProvider.getNavigation();
    for (MediaProvider.NavInfo info : navigation) {
        moreRowAdapter.add(new MorePresenter.MoreItem(
                info.getId(),
                info.getLabel(),
                info.getIcon(),
                info));
    }

    mRowsAdapter.add(new ListRow(moreHeader, moreRowAdapter));
}
项目:leanback-showcase    文件:CardExampleFragment.java   
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);
    }
}
项目:leanback-showcase    文件:PageAndListRowFragment.java   
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);
}
项目:sbs-android-tv    文件:DetailsFragment.java   
private void updateRelatedEpisodes(Map<String, List<EpisodeBaseModel>> others) {
    boolean updated = false;
    ArrayObjectAdapter adapter = (ArrayObjectAdapter) getAdapter();
    for (Map.Entry<String, List<EpisodeBaseModel>> list : others.entrySet()) {
        String title = list.getKey();
        Log.d(TAG, "More: " + title);
        if (ContentManagerBase.OTHER_EPISODES.equals(title)) {
            otherEpisodes.addAll(otherEpisodes.size(), list.getValue());
        } else {
            ArrayObjectAdapter more = new ArrayObjectAdapter(new CardSelector());
            more.addAll(0, list.getValue());
            adapter.add(new ListRow(new HeaderItem(0, title), more));
        }
        updated = true;
    }
    if (updated) {
        adapter.notifyArrayItemRangeChanged(0, adapter.size());
    }
}
项目:android-tv-leanback    文件:LeanbackBrowseFragment.java   
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());
    setOnItemViewSelectedListener(getDefaultItemSelectedListener());

    bgHelper = new BackgroundHelper(getActivity());
    bgHelper.prepareBackgroundManager();

}
项目:android-tv-leanback    文件:LeanbackBrowseFragment.java   
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());

}
项目:android-tv-leanback    文件:LeanbackBrowseFragment.java   
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());
    setOnItemViewSelectedListener(getDefaultItemSelectedListener());

    bgHelper = new BackgroundHelper(getActivity());
    bgHelper.prepareBackgroundManager();

}
项目:android-tv-leanback    文件:LeanbackBrowseFragment.java   
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

}
项目:android-tv-leanback    文件:LeanbackBrowseFragment.java   
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());

}
项目:spotify-tv    文件:SearchFragment.java   
private void searchArtists(String query) {
    SpotifyTvApplication.getInstance().getSpotifyService().searchArtists(query, getSearchOptions(), new Callback<ArtistsPager>() {
        @Override
        public void success(ArtistsPager artistsPager, Response response) {
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new ArtistCardPresenter());
            for (Artist artist : artistsPager.artists.items) {
                listRowAdapter.add(artist);
            }
            HeaderItem header = new HeaderItem(getString(R.string.artists));
            mRowsAdapter.add(new ListRow(header, listRowAdapter));

            // TODO next pages ?
        }

        @Override
        public void failure(RetrofitError error) {

        }
    });
}
项目:spotify-tv    文件:SearchFragment.java   
private void searchAlbums(String query) {
    SpotifyTvApplication.getInstance().getSpotifyService().searchAlbums(query, getSearchOptions(), new Callback<AlbumsPager>() {
        @Override
        public void success(AlbumsPager albumsPager, Response response) {
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new AlbumCardPresenter());
            for (AlbumSimple artist : albumsPager.albums.items) {
                listRowAdapter.add(artist);
            }
            HeaderItem header = new HeaderItem(getString(R.string.albums));
            mRowsAdapter.add(new ListRow(header, listRowAdapter));

            // TODO next pages ?
        }

        @Override
        public void failure(RetrofitError error) {

        }
    });
}
项目:spotify-tv    文件:SearchFragment.java   
private void searchSongs(String query) {
    SpotifyTvApplication.getInstance().getSpotifyService().searchTracks(query, getSearchOptions(), new Callback<TracksPager>() {
        @Override
        public void success(TracksPager tracksPager, Response response) {
            mTrackRowAdapter = new ArrayObjectAdapter(new TrackCardPresenter());
            for (Track track : tracksPager.tracks.items) {
                mTrackRowAdapter.add(track);
            }
            HeaderItem header = new HeaderItem(getString(R.string.songs));
            mRowsAdapter.add(new ListRow(header, mTrackRowAdapter));

            // TODO next pages ?
        }

        @Override
        public void failure(RetrofitError error) {

        }
    });
}
项目:spotify-tv    文件:SearchFragment.java   
private void searchPlaylists(String query) {
    SpotifyTvApplication.getInstance().getSpotifyService().searchPlaylists(query, getSearchOptions(), new Callback<PlaylistsPager>() {
        @Override
        public void success(PlaylistsPager playlistsPager, Response response) {
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new PlaylistCardPresenter());
            for (PlaylistSimple playlistSimple : playlistsPager.playlists.items) {
                listRowAdapter.add(playlistSimple);
            }
            HeaderItem header = new HeaderItem(getString(R.string.playlists));
            mRowsAdapter.add(new ListRow(header, listRowAdapter));

            // TODO next pages ?
        }

        @Override
        public void failure(RetrofitError error) {

        }
    });
}
项目:MediaBrowser.AndroidTv    文件:SelectServerFragment.java   
@Override
protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) {
    super.addAdditionalRows(rowAdapter);

    setHeadersState(HEADERS_DISABLED);


    HeaderItem serverHeader = new HeaderItem(rowAdapter.size(), "Select a server", null);
    ItemRowAdapter serverAdapter = new ItemRowAdapter(mServers.toArray(new ServerInfo[mServers.size()]), new CardPresenter(), rowAdapter);
    serverAdapter.Retrieve();
    rowAdapter.add(new ListRow(serverHeader, serverAdapter));

    HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), "Other options", null);

    GridButtonPresenter mGridPresenter = new GridButtonPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(new GridButton(ENTER_MANUALLY, "Enter Manually", R.drawable.edit));
    gridRowAdapter.add(new GridButton(LOGIN_CONNECT, "Login with Connect", R.drawable.chain));
    rowAdapter.add(new ListRow(gridHeader, gridRowAdapter));
}
项目:MediaBrowser.AndroidTv    文件:SelectUserFragment.java   
@Override
protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) {
    super.addAdditionalRows(rowAdapter);

    setHeadersState(HEADERS_DISABLED);

    HeaderItem usersHeader = new HeaderItem(rowAdapter.size(), "Select a user", null);
    ItemRowAdapter usersAdapter = new ItemRowAdapter(mServer, new CardPresenter(), rowAdapter);
    usersAdapter.Retrieve();
    rowAdapter.add(new ListRow(usersHeader, usersAdapter));

    HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), "Other options", null);

    GridButtonPresenter mGridPresenter = new GridButtonPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(new GridButton(ENTER_MANUALLY, "Enter Manually", R.drawable.edit));
    gridRowAdapter.add(new GridButton(LOGIN_CONNECT, "Login with Connect", R.drawable.chain));
    rowAdapter.add(new ListRow(gridHeader, gridRowAdapter));
}
项目:MediaBrowser.AndroidTv    文件:MySearchFragment.java   
@Override
public void run() {
    //Get search results by type
    SearchQuery people = getSearchQuery(new String[] {"Person"});
    ItemRowAdapter peopleAdapter = new ItemRowAdapter(people, new CardPresenter(), mRowsAdapter);
    ListRow peopleRow = new ListRow(new HeaderItem("People",""), peopleAdapter);
    peopleAdapter.setRow(peopleRow);
    peopleAdapter.Retrieve();

    SearchQuery tv = getSearchQuery(new String[] {"Series","Episode"});
    ItemRowAdapter tvAdapter = new ItemRowAdapter(tv, new CardPresenter(), mRowsAdapter);
    ListRow tvRow = new ListRow(new HeaderItem("TV",""), tvAdapter);
    tvAdapter.setRow(tvRow);
    tvAdapter.Retrieve();

    SearchQuery movies = getSearchQuery(new String[] {"Movie", "BoxSet"});
    ItemRowAdapter movieAdapter = new ItemRowAdapter(movies, new CardPresenter(), mRowsAdapter);
    ListRow movieRow = new ListRow(new HeaderItem("Movies",""), movieAdapter);
    movieAdapter.setRow(movieRow);
    movieAdapter.Retrieve();

}
项目:MediaBrowser.AndroidTv    文件:BrowseFolderFragment.java   
@Override
protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) {
    super.addAdditionalRows(rowAdapter);
    if (showViews) {
        HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), "Views", null);

        GridButtonPresenter mGridPresenter = new GridButtonPresenter();
        ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
        gridRowAdapter.add(new GridButton(BY_LETTER, "By Letter", R.drawable.byletter));
        if (itemTypeString != null && itemTypeString.equals("Movie"))
            gridRowAdapter.add(new GridButton(SUGGESTED, "Suggested", R.drawable.suggestions));
        gridRowAdapter.add(new GridButton(GENRES, "Genres", R.drawable.genres));
        gridRowAdapter.add(new GridButton(PERSONS, "Performers", R.drawable.actors));
        rowAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    }
}
项目:iview-android-tv    文件:DetailsFragment.java   
private void updateRelatedEpisodes(Map<String, List<EpisodeBaseModel>> others) {
    boolean updated = false;
    ArrayObjectAdapter adapter = (ArrayObjectAdapter) getAdapter();
    for (Map.Entry<String, List<EpisodeBaseModel>> list : others.entrySet()) {
        String title = list.getKey();
        Log.d(TAG, "More: " + title);
        if (ContentManagerBase.OTHER_EPISODES.equals(title)) {
            otherEpisodes.addAll(otherEpisodes.size(), list.getValue());
        } else {
            ArrayObjectAdapter more = new ArrayObjectAdapter(new CardSelector());
            more.addAll(0, list.getValue());
            adapter.add(new ListRow(new HeaderItem(0, title), more));
        }
        updated = true;
    }
    if (updated) {
        adapter.notifyArrayItemRangeChanged(0, adapter.size());
    }
}
项目:Vineyard    文件:SearchFragment.java   
private void setListAdapterData(String title, String tag) {
    if (mPostResultsAdapter != null) {
        mResultsAdapter.remove(mPostResultsAdapter);
    }
    if (mPostResultsAdapter == null) {
        mPostResultsAdapter = new PostAdapter(getActivity(), tag);
    }
    mResultsAdapter.removeItems(1, 1);
    final HeaderItem postResultsHeader = new HeaderItem(1, getString(R.string.text_post_results_title, title));
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            mResultsAdapter.add(new ListRow(postResultsHeader, mPostResultsAdapter));
        }
    });

    mPostResultsAdapter.setTag(tag);
    mPostResultsAdapter.setAnchor("");
    mPostResultsAdapter.setNextPage(1);
    if (!mPostResultsAdapter.shouldShowLoadingIndicator()) {
        mPostResultsAdapter.removeItems(1, mPostResultsAdapter.size() - 2);
    } else {
        mPostResultsAdapter.clear();
    }
}
项目:AndroidDemoProjects    文件:MainFragment.java   
private void loadRows() {

        ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter( new ListRowPresenter() );
        CardPresenter cardPresenter = new CardPresenter();

        List<String> categories = getCategories();
        if( categories == null || categories.isEmpty() )
            return;

        for( String category : categories ) {
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter( cardPresenter );
            for( Movie movie : mMovies ) {
                if( category.equalsIgnoreCase( movie.getCategory() ) )
                    listRowAdapter.add( movie );
            }
            if( listRowAdapter.size() > 0 ) {
                HeaderItem header = new HeaderItem( rowsAdapter.size() - 1, category, null );
                rowsAdapter.add( new ListRow( header, listRowAdapter ) );
            }
        }

        setupPreferences( rowsAdapter );
        setAdapter( rowsAdapter );

    }
项目:androidtv-Leanback    文件:PlaybackFragment.java   
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;
}
项目:androidtv-Leanback    文件:SearchFragment.java   
@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);
}
项目:TickTank_old    文件:TankLevelSearchRunnable.java   
private Row generateSearchResults(LevelType levelType) {
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new TankLevelPresenter());

    for (int x = 0; x < LevelFactory.getLevelCount(levelType); x++) {
        TankLevelItem tankLevel = new TankLevelItem();

        final int levelIndex = x + 1;
        tankLevel.setDescription(LevelFactory.getDescription(context, levelType, levelIndex));
        tankLevel.setBackground(LevelFactory.getLevelBackground(context, levelType, levelIndex));
        tankLevel.setLevelIndex(levelIndex);
        tankLevel.setLevelType(levelType);

        listRowAdapter.add(tankLevel);
    }

    final String packageName = context.getApplicationContext().getPackageName();
    final String headerName = context.getString(R.string.menu_land);
    final String headerImageUri = "android.resource://" + packageName + "/" + R.drawable.menu_land_icon;

    HeaderItem header = new HeaderItem(headerName, headerImageUri);
    return new ListRow(header, listRowAdapter);
}
项目:TickTank_old    文件:TickTankMenuFragment.java   
private Row generateLandLevelRow() {
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new TankLevelPresenter());

    for (int x = 0; x < LevelFactory.getLevelCount(LevelType.LAND); x++) {
        TankLevelItem tankLevel = new TankLevelItem();

        final int levelIndex = x + 1;
        tankLevel.setDescription(LevelFactory.getDescription(getActivity(), LevelType.LAND, levelIndex));
        tankLevel.setBackground(LevelFactory.getLevelBackground(getActivity(), LevelType.LAND, levelIndex));
        tankLevel.setLevelIndex(levelIndex);
        tankLevel.setLevelType(LevelType.LAND);

        listRowAdapter.add(tankLevel);
    }

    final String packageName = getActivity().getApplicationContext().getPackageName();
    final String headerName = getString(R.string.menu_land);
    final String headerImageUri = "android.resource://" + packageName + "/" + R.drawable.menu_land_icon;

    HeaderItem header = new HeaderItem(headerName, headerImageUri);
    return new ListRow(header, listRowAdapter);
}
项目:TickTank_old    文件:TickTankMenuFragment.java   
private Row generateWaterLevelRow() {
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new TankLevelPresenter());

    for (int x = 0; x < LevelFactory.getLevelCount(LevelType.WATER); x++) {
        TankLevelItem tankLevel = new TankLevelItem();

        final int levelIndex = x + 1;
        tankLevel.setDescription(LevelFactory.getDescription(getActivity(), LevelType.WATER, levelIndex));
        tankLevel.setBackground(LevelFactory.getLevelBackground(getActivity(), LevelType.WATER, levelIndex));
        tankLevel.setLevelIndex(levelIndex);
        tankLevel.setLevelType(LevelType.WATER);

        listRowAdapter.add(tankLevel);
    }

    final String packageName = getActivity().getApplicationContext().getPackageName();
    final String headerName = getString(R.string.menu_water);
    final String headerImageUri = "android.resource://" + packageName + "/" + R.drawable.menu_water_icon;

    HeaderItem header = new HeaderItem(headerName, headerImageUri);
    return new ListRow(header, listRowAdapter);
}
项目:Amphitheatre    文件:BrowseFragment.java   
private void addRecentlyAddedTvShows(List<Video> tvShows, ListRow unMatchedRow) {
    if (!tvShows.isEmpty()) {
        ListRow row = findListRow(getString(R.string.recently_added_tv_episodes));
        if (row != null) {
            ((ArrayObjectAdapter) row.getAdapter()).clear();
            ((ArrayObjectAdapter) row.getAdapter()).addAll(0, tvShows);
        } else {
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mTvShowsCardPresenter);
            listRowAdapter.addAll(0, tvShows);

            HeaderItem header = new HeaderItem(0, getString(R.string.recently_added_tv_episodes), null);
            int index = mAdapter.size() > 1 ? mAdapter.size() - 1 : 0;
            if (unMatchedRow != null) index -= 1;
            mAdapter.add(index, new ListRow(header, listRowAdapter));
        }
    }
}
项目:Amphitheatre    文件:BrowseFragment.java   
private void addRecentlyAddedMovies(List<Video> movies, ListRow unMatchedRow) {
    if (!movies.isEmpty()) {
        ListRow row = findListRow(getString(R.string.recently_added_movies));
        if (row != null) {
            ((ArrayObjectAdapter) row.getAdapter()).clear();
            ((ArrayObjectAdapter) row.getAdapter()).addAll(0, movies);
        } else {
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mCardPresenter);
            listRowAdapter.addAll(0, movies);

            HeaderItem header = new HeaderItem(0, getString(R.string.recently_added_movies), null);
            int index = mAdapter.size() > 1 ? mAdapter.size() - 1 : 0;
            if (unMatchedRow != null) index -= 1;
            mAdapter.add(index, new ListRow(header, listRowAdapter));
        }
    }
}
项目:Amphitheatre    文件:SearchFragment.java   
private void loadRows(String query) {
    mListRowAdapter.clear();

    Map<String, Video> searchMap = new HashMap<String, Video>();

    for (Video video : allVideos) {
        if (video == null || video.getName() == null) {
            continue;
        }

        if (video.getName().toLowerCase().contains(query.toLowerCase())) {
            if (!searchMap.containsKey(video.getName())) {
                searchMap.put(video.getName(), video);
            }
        }
    }

    mListRowAdapter.addAll(0, searchMap.values());

    HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results), null);
    mRowsAdapter.add(new ListRow(header, mListRowAdapter));
}
项目:BuildingForAndroidTV    文件:CustomRowsFragment.java   
private void loadRows() {
    rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    cardPresenter = new CardPresenter();

    List<Movie> list = MovieList.setupMovies();

    int i;
    for (i = 0; i < NUM_ROWS; i++) {
        if (i != 0) {
            Collections.shuffle(list);
        }
        ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
        for (int j = 0; j < NUM_COLS; j++) {
            listRowAdapter.add(list.get(j % 5));
        }
        HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null);
        rowsAdapter.add(new ListRow(header, listRowAdapter));
    }

    setAdapter(rowsAdapter);
}
项目:BuildingForAndroidTV    文件:CustomHeadersFragment.java   
private void setHeaderAdapter() {
    adapter = new ArrayObjectAdapter();

    LinkedHashMap<Integer, CustomRowsFragment> fragments = ((TVDemoActivity) getActivity()).getFragments();

    int id = 0;
    for (int i = 0; i < fragments.size(); i++) {
        HeaderItem header = new HeaderItem(id, "Category " + i, null);
        ArrayObjectAdapter innerAdapter = new ArrayObjectAdapter();
        innerAdapter.add(fragments.get(i));
        adapter.add(id, new ListRow(header, innerAdapter));
        id++;
    }

    setAdapter(adapter);
}