Java Code Examples for android.support.v17.leanback.widget.ArrayObjectAdapter#size()
The following examples show how to use
android.support.v17.leanback.widget.ArrayObjectAdapter#size() .
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: MainFragment.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
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 ); }
Example 2
Source File: OksusuRowSupportFragment.java From alltv with MIT License | 5 votes |
@Override public void createRows() { mRowsAdapter.clear(); if (isEmptyCategory(mType)) { createDefaultRows(); getMainFragmentAdapter().getFragmentHost().notifyDataReady(getMainFragmentAdapter()); return; } CardPresenter presenterSelector = new CardPresenter(); ArrayList<ChannelData> chList = mChannels.containsKey(mType) ? new ArrayList<>(mChannels.get(mType)) : new ArrayList<>(); Collections.reverse(chList); ArrayList<CategoryData> ctList = mCategory.containsKey(mType) ? mCategory.get(mType) : new ArrayList<>(); for (CategoryData ctData : ctList) { ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector); int index = 0; for (int i = (chList.size() - 1); i >= 0; i--) { if (ctData.getId() == chList.get(i).getCategoryId()) { chList.get(i).setItemIndex(index++); adapter.add(chList.get(i)); } } if(adapter.size() > 0) { HeaderItem headerItem = new HeaderItem(ctData.getTitle()); mRowsAdapter.add(new ListRow(headerItem, adapter)); } } if(getMainFragmentAdapter() != null) getMainFragmentAdapter().getFragmentHost().notifyDataReady(getMainFragmentAdapter()); }
Example 3
Source File: MainFragment.java From leanback-extensions with Apache License 2.0 | 5 votes |
private void refreshView() { // Refresh the grid without actually reloading it from scratch. ArrayObjectAdapter adapter = ((ArrayObjectAdapter) getAdapter()); if (adapter != null && adapter.size() > 0) { adapter.notifyArrayItemRangeChanged(0, adapter.size()); } }
Example 4
Source File: MainFragment.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
private void setupPreferences( ArrayObjectAdapter adapter ) { HeaderItem gridHeader = new HeaderItem( adapter.size(), "Preferences", null ); PreferenceCardPresenter mGridPresenter = new PreferenceCardPresenter(); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter( mGridPresenter ); gridRowAdapter.add( getResources().getString( R.string.sloth ) ); adapter.add( new ListRow( gridHeader, gridRowAdapter ) ); }
Example 5
Source File: TvingRowSupportFragment.java From alltv with MIT License | 4 votes |
@Override public void createRows() { mRowsAdapter.clear(); if (isEmptyCategory(mType)) { createDefaultRows(); getMainFragmentAdapter().getFragmentHost().notifyDataReady(getMainFragmentAdapter()); return; } if (mAuthKey != null) { String authKey = mAuthKey.get(mType); } CardPresenter presenterSelector = new CardPresenter(); ArrayList<ChannelData> chList = mChannels.containsKey(mType) ? new ArrayList<>(mChannels.get(mType)) : new ArrayList<>(); Collections.reverse(chList); ArrayList<CategoryData> ctList = mCategory.containsKey(mType) ? mCategory.get(mType) : new ArrayList<>(); for (CategoryData ctData : ctList) { ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector); int index = 0; for (int i = (chList.size() - 1); i >= 0; i--) { if (ctData.getId() == chList.get(i).getCategoryId()) { chList.get(i).setItemIndex(index++); adapter.add(chList.get(i)); } } if(adapter.size() > 0) { HeaderItem headerItem = new HeaderItem(ctData.getTitle()); mRowsAdapter.add(new ListRow(headerItem, adapter)); } } if(getMainFragmentAdapter() != null) getMainFragmentAdapter().getFragmentHost().notifyDataReady(getMainFragmentAdapter()); }
Example 6
Source File: PooqRowSupportFragment.java From alltv with MIT License | 4 votes |
@Override public void createRows() { mRowsAdapter.clear(); if (isEmptyCategory(mType)) { createDefaultRows(); getMainFragmentAdapter().getFragmentHost().notifyDataReady(getMainFragmentAdapter()); return; } if (mAuthKey != null) { String authKey = mAuthKey.get(mType); } CardPresenter presenterSelector = new CardPresenter(); ArrayList<ChannelData> chList = mChannels.containsKey(mType) ? new ArrayList<>(mChannels.get(mType)) : new ArrayList<>(); Collections.reverse(chList); ArrayList<CategoryData> ctList = mCategory.containsKey(mType) ? mCategory.get(mType) : new ArrayList<>(); for (CategoryData ctData : ctList) { ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector); int index = 0; for (int i = (chList.size() - 1); i >= 0; i--) { if (ctData.getId() == chList.get(i).getCategoryId()) { chList.get(i).setItemIndex(index++); adapter.add(chList.get(i)); } } if(adapter.size() > 0) { HeaderItem headerItem = new HeaderItem(ctData.getTitle()); mRowsAdapter.add(new ListRow(headerItem, adapter)); } } if(getMainFragmentAdapter() != null) getMainFragmentAdapter().getFragmentHost().notifyDataReady(getMainFragmentAdapter()); }