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

项目: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());
    }
}
项目:aos-Video    文件:TvshowMoreDetailsFragment.java   
@Override
protected void onPostExecute(Void avoid) {
    ClassPresenterSelector ps = new ClassPresenterSelector();
    ps.addClassPresenter(DetailsOverviewRow.class, mOverviewRowPresenter);
    ps.addClassPresenter(PlotAndGenresRow.class, new PlotAndGenresRowPresenter(16,mColor)); // 16 lines max to fit on screen
    ps.addClassPresenter(FullTextRow.class, new FullTextRowPresenter(18,mColor)); // 18 lines max to fit on screen
    ps.addClassPresenter(ListRow.class, new ListRowPresenter());
    mOverviewRowPresenter.setBackgroundColor(mColor);
    mRowsAdapter = new ArrayObjectAdapter(ps);
    mRowsAdapter.clear();
    // Add all the non-null rows
    for (Row row : new Row[] {mDetailsRow, mPlotAndGenresRow, mCastRow, mPostersRow, mBackdropsRow, mWebLinksRow}) {
        if (row!=null) {
            mRowsAdapter.add(row);
        }
    }
    setAdapter(mRowsAdapter);
}
项目: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   
@Override
public void onRecordedProgramsRemoved(RecordedProgram... recordedPrograms) {
    for (RecordedProgram recordedProgram : recordedPrograms) {
        if (TextUtils.equals(recordedProgram.getSeriesId(), mSeries.getSeriesId())) {
            ListRow row = getSeasonRow(recordedProgram.getSeasonNumber(), false);
            if (row != null) {
                SeasonRowAdapter adapter = (SeasonRowAdapter) row.getAdapter();
                adapter.remove(recordedProgram);
                if (adapter.isEmpty()) {
                    getRowsAdapter().remove(row);
                    if (getRowsAdapter().size() == 1) {
                        // No season rows left. Only DetailsOverviewRow
                        mActionsAdapter.clear(ACTION_DELETE);
                    }
                }
            }
            if (recordedProgram.getId() == mRecommendRecordedProgram.getId()) {
                updateWatchAction();
            }
        }
    }
}
项目:android_packages_apps_tv    文件:SeriesRecordingDetailsFragment.java   
private ListRow getSeasonRow(String seasonNumber, boolean createNewRow) {
    seasonNumber = TextUtils.isEmpty(seasonNumber) ? "" : seasonNumber;
    ArrayObjectAdapter rowsAdaptor = getRowsAdapter();
    for (int i = rowsAdaptor.size() - 1; i >= 0; i--) {
        Object row = rowsAdaptor.get(i);
        if (row instanceof ListRow) {
            int compareResult = BaseProgram.numberCompare(seasonNumber,
                    ((SeasonRowAdapter) ((ListRow) row).getAdapter()).mSeasonNumber);
            if (compareResult == 0) {
                return (ListRow) row;
            } else if (compareResult < 0) {
                return createNewRow ? createNewSeasonRow(seasonNumber, i + 1) : null;
            }
        }
    }
    return createNewRow ? createNewSeasonRow(seasonNumber, rowsAdaptor.size()) : null;
}
项目: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;
}
项目: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));
}
项目: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());
    }
}
项目:danish-media-license    文件:BrowseFragment.java   
@Override
public void onLoadFinished(Loader<List<Category>> loader, List<Category> data) {
  Log.d(TAG, "onLoadFinished");
  LoadingHelper.hideLoading(this);
  rows.clear();
  if (data == null) {
    Log.w(TAG, "No data returned by loader");
    createSettingsRow();
    return;
  }
  for (Category category : data) {
    ListRow categoryRow = createCategoryRow(category);
    rows.add(categoryRow);
  }
  createSettingsRow();
}
项目: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    文件:StdBrowseFragment.java   
@Override
public void onResume() {
    super.onResume();

    //Re-retrieve anything that needs it but delay slightly so we don't take away gui landing
    if (mRowsAdapter != null) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < mRowsAdapter.size(); i++) {
                    if (mRowsAdapter.get(i) instanceof ListRow) {
                        if (((ListRow) mRowsAdapter.get(i)).getAdapter() instanceof ItemRowAdapter) {
                            ((ItemRowAdapter) ((ListRow) mRowsAdapter.get(i)).getAdapter()).ReRetrieveIfNeeded();
                        }
                    }
                }
            }
        },1500);
    }
}
项目:MediaBrowser.AndroidTv    文件:StdBrowseFragment.java   
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                           RowPresenter.ViewHolder rowViewHolder, Row row) {
    if (!(item instanceof BaseRowItem)) {
        //fill in default background
        mBackgroundUrl = null;
        startBackgroundTimer();
        return;
    }

    BaseRowItem rowItem = (BaseRowItem) item;

    //mApplication.getLogger().Debug("Selected Item "+rowItem.getIndex() + " type: "+ (rowItem.getItemType().equals(BaseRowItem.ItemType.BaseItem) ? rowItem.getBaseItem().getType() : "other"));
    ItemRowAdapter adapter = (ItemRowAdapter) ((ListRow)row).getAdapter();
    adapter.loadMoreItemsIfNeeded(rowItem.getIndex());

    mBackgroundUrl = rowItem.getBackdropImageUrl();
    startBackgroundTimer();

}
项目: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    文件:AboutDetailsFragment.java   
private ArrayObjectAdapter buildAboutAdapter() {
    DetailsOverviewRowPresenter rowPresenter = new DetailsOverviewRowPresenter(new AboutDetailsDescriptionPresenter());
    rowPresenter.setBackgroundColor(getResources().getColor(R.color.about_background));
    rowPresenter.setOnActionClickedListener(new OnActionClickedListener() {

        @Override
        public void onActionClicked(Action action) {}
    });

    ClassPresenterSelector selector = new ClassPresenterSelector();
    selector.addClassPresenter(DetailsOverviewRow.class, rowPresenter);
    selector.addClassPresenter(ListRow.class, new ListRowPresenter());

    ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(selector);

    rowsAdapter.add(generateAboutMeRow());
    rowsAdapter.add(generateAboutGDGRow());

    return rowsAdapter;
}
项目: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));
        }
    }
}