Java Code Examples for android.support.v17.leanback.widget.ArrayObjectAdapter#addAll()

The following examples show how to use android.support.v17.leanback.widget.ArrayObjectAdapter#addAll() . 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: DetailsFragment.java    From iview-android-tv with MIT License 6 votes vote down vote up
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());
    }
}
 
Example 2
Source File: BrowseFragment.java    From Amphitheatre with Apache License 2.0 6 votes vote down vote up
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));
        }
    }
}
 
Example 3
Source File: BrowseFragment.java    From Amphitheatre with Apache License 2.0 6 votes vote down vote up
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));
        }
    }
}
 
Example 4
Source File: TvSearchFragment.java    From leanback-homescreen-channels with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    // Search for query and collate results.
    mRowsAdapter.clear();
    ArrayObjectAdapter searchRowAdapter =
            new ArrayObjectAdapter(new SearchPresenterSelector());
    searchRowAdapter.add(new AddPlaylistButton());
    searchRowAdapter.addAll(1, SampleClipApi.getSearchResults(mQuery));
    HeaderItem header =
            new HeaderItem(0, getResources().getString(R.string.search_results));
    mRowsAdapter.add(new ListRow(header, searchRowAdapter));

}
 
Example 5
Source File: SearchFragment.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
private void loadRows(String query, int type) {
    ArrayList<MediaWrapper> mediaList = MediaLibrary.getInstance().searchMedia(query);
    final ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter(mActivity));
    listRowAdapter.addAll(0, mediaList);
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results));
            mRowsAdapter.add(new ListRow(header, listRowAdapter));
        }
    });
}
 
Example 6
Source File: SearchFragment.java    From iview-android-tv with MIT License 5 votes vote down vote up
@Override
public void run() {
    Log.d(TAG, "Searching: " + query);
    List<EpisodeBaseModel> results = getContentManger().searchShows(query);
    ArrayObjectAdapter row = new ArrayObjectAdapter(new CardSelector());
    row.addAll(0, results);
    HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results));
    adapter.add(new ListRow(header, row));
}
 
Example 7
Source File: TVSearchFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void run() {
	// you should fetch your data here and update the adapter
	// accordingly
	mRowsAdapter.clear();
	ArrayObjectAdapter adapter = new ArrayObjectAdapter(new CardPresenter());
	adapter.addAll(0, MovieList.list);
	HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results), null);
	mRowsAdapter.add(new ListRow(header, adapter));
}
 
Example 8
Source File: TVSearchFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void run() {
	// you should fetch your data here and update the adapter
	// accordingly
	mRowsAdapter.clear();
	ArrayObjectAdapter adapter = new ArrayObjectAdapter(new CardPresenter());
	adapter.addAll(0, MovieList.list);
	HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results), null);
	mRowsAdapter.add(new ListRow(header, adapter));
}
 
Example 9
Source File: TVSearchFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void run() {
	// you should fetch your data here and update the adapter
	// accordingly
	mRowsAdapter.clear();
	ArrayObjectAdapter adapter = new ArrayObjectAdapter(new CardPresenter());
	adapter.addAll(0, MovieList.list);
	HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results), null);
	mRowsAdapter.add(new ListRow(header, adapter));
}
 
Example 10
Source File: TVGridFragment.java    From BuildingForAndroidTV with MIT License 4 votes vote down vote up
private void loadRows() {
	ArrayObjectAdapter adapter = new ArrayObjectAdapter(new CardPresenter());
	adapter.addAll(0, MovieList.list);
	setAdapter(adapter);
}
 
Example 11
Source File: TVGridFragment.java    From BuildingForAndroidTV with MIT License 4 votes vote down vote up
private void loadRows() {
	ArrayObjectAdapter adapter = new ArrayObjectAdapter(new CardPresenter());
	adapter.addAll(0, MovieList.list);
	setAdapter(adapter);
}
 
Example 12
Source File: TVGridFragment.java    From BuildingForAndroidTV with MIT License 4 votes vote down vote up
private void loadRows() {
	ArrayObjectAdapter adapter = new ArrayObjectAdapter(new CardPresenter());
	adapter.addAll(0, MovieList.list);
	setAdapter(adapter);
}