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

项目:androidtv-sample    文件:MainFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // Final initialization, modifying UI elements.
    super.onActivityCreated(savedInstanceState);

    // Prepare the manager that maintains the same background image between activities.
    prepareBackgroundManager();

    setupUIElements();
    setupEventListeners();
    prepareEntranceTransition();

    // Map category results from the database to ListRow objects.
    // This Adapter is used to render the MainFragment sidebar labels.
    mCategoryRowAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mCategoryRowAdapter);

    updateRecommendations();
}
项目: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    文件:MainFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);


    prepareBackgroundManager();
    setupUIElements();
    setupEventListeners();
    prepareEntranceTransition();

    mCategoryRowAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    loadRows();
    setAdapter(mCategoryRowAdapter);


    updateRecommendations();
}
项目: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   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    //setup background updater
    mBackgroundUpdater = new BackgroundUpdater();
    mBackgroundUpdater.initialise(getActivity(), R.color.black);

    //setup main adapter
    ListRowPresenter mainMenuRowPresenter = new ListRowPresenter();
    mainMenuRowPresenter.setShadowEnabled(false);
    mRowsAdapter = new ArrayObjectAdapter(mainMenuRowPresenter);
    setAdapter(mRowsAdapter);

    setupUIElements();
    setupEventListeners();
    setupAdapters();
    loadData();
}
项目: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());

}
项目:MediaBrowser.AndroidTv    文件:MySearchFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setSearchResultProvider(this);
    setOnItemViewClickedListener(new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            if (!(item instanceof BaseRowItem)) return;
            ItemLauncher.launch((BaseRowItem) item, TvApp.getApplication(), getActivity(), itemViewHolder);
        }
    });
    mDelayedLoad = new SearchRunnable();

    prepareBackgroundManager();
}
项目:Crowdi    文件:ManageAccountsActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manageaccounts);

    mLibrary = Library.getInstance();
    mLibrary.registerListener(this);
    mFitnessLibrary = FitnessLibrary.getInstance();
    mFitnessLibrary.registerListener(this);

    mFragmentManager = getFragmentManager();
    mBrowseFragment = (BrowseFragment) mFragmentManager.findFragmentById(R.id.id_Fragment_ManageAccountActivity);

    mBrowseFragment.setHeadersState(BrowseFragment.HEADERS_ENABLED);
    mBrowseFragment.setBadgeDrawable(getDrawable(R.drawable.browse_logo));
    mBrowseFragment.setOnItemViewClickedListener(this);

    BackgroundManager backgroundManager = BackgroundManager.getInstance(this);
    backgroundManager.attach(this.getWindow());
    backgroundManager.setDrawable(getResources().getDrawable(R.drawable.background, null));

    mArrayObjectAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    mBrowseFragment.setAdapter(mArrayObjectAdapter);

    updateUI();
}
项目:Vineyard    文件:MainFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ((BaseActivity) getActivity()).getActivityComponent().inject(this);
    mPreferencesHelper =
            VineyardApplication.get(getActivity()).getComponent().preferencesHelper();
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    mHandler = new Handler();
    mPopularText = getString(R.string.header_text_popular);
    mEditorsPicksText = getString(R.string.header_text_editors_picks);
    mEventBus.register(this);

    loadPosts();
    setAdapter(mRowsAdapter);
    prepareBackgroundManager();
    setupUIElements();
    setupListeners();
}
项目:TuentiTV    文件:MainFragment.java   
@Override public void showMainInformation(List<CardInfo> favorites, List<CardInfo> conversations,
    List<CardInfo> contacts, List<ImageInfo> mediaElements, List<IconInfo> preferences) {
  ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
  CardPresenter bigCardPresenter = new CardPresenter(CARD_WIDTH_IN_DP, CARD_HEIGHT_IN_DP);
  CardPresenter smallCarPresenter = new CardPresenter();

  addCardInfoElementsToRowsAdapter(R.string.favorites_item_title, favorites, rowsAdapter,
      smallCarPresenter, FAVORITES_ROW);
  addCardInfoElementsToRowsAdapter(R.string.recent_conversation_item_title, conversations,
      rowsAdapter, bigCardPresenter, CONVERSATIONS_ROW);
  addCardInfoElementsToRowsAdapter(R.string.contacts_item_title, contacts, rowsAdapter,
      smallCarPresenter, CONTACTS_ROW);
  addImageInfoElementsToRowAdapter(R.string.media_elements_item_title, mediaElements, rowsAdapter,
      new ImagePresenter(), MEDIA_ROW);
  addIconInfoElementsToRowAdapter(getResources().getString(R.string.preferences), preferences,
      rowsAdapter, new IconPresenter(), PREFERENCES_ROW);

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

    }
项目:adt-leanback-support    文件:RowsSupportFragment.java   
private void setupSharedViewPool(ItemBridgeAdapter.ViewHolder bridgeVh) {
    RowPresenter rowPresenter = (RowPresenter) bridgeVh.getPresenter();
    RowPresenter.ViewHolder rowVh = rowPresenter.getRowViewHolder(bridgeVh.getViewHolder());

    if (rowVh instanceof ListRowPresenter.ViewHolder) {
        HorizontalGridView view = ((ListRowPresenter.ViewHolder) rowVh).getGridView();
        // Recycled view pool is shared between all list rows
        if (mRecycledViewPool == null) {
            mRecycledViewPool = view.getRecycledViewPool();
        } else {
            view.setRecycledViewPool(mRecycledViewPool);
        }

        ItemBridgeAdapter bridgeAdapter =
                ((ListRowPresenter.ViewHolder) rowVh).getBridgeAdapter();
        if (mPresenterMapper == null) {
            mPresenterMapper = bridgeAdapter.getPresenterMapper();
        } else {
            bridgeAdapter.setPresenterMapper(mPresenterMapper);
        }
    }
}
项目:adt-leanback-support    文件:RowsFragment.java   
private void setupSharedViewPool(ItemBridgeAdapter.ViewHolder bridgeVh) {
    RowPresenter rowPresenter = (RowPresenter) bridgeVh.getPresenter();
    RowPresenter.ViewHolder rowVh = rowPresenter.getRowViewHolder(bridgeVh.getViewHolder());

    if (rowVh instanceof ListRowPresenter.ViewHolder) {
        HorizontalGridView view = ((ListRowPresenter.ViewHolder) rowVh).getGridView();
        // Recycled view pool is shared between all list rows
        if (mRecycledViewPool == null) {
            mRecycledViewPool = view.getRecycledViewPool();
        } else {
            view.setRecycledViewPool(mRecycledViewPool);
        }

        ItemBridgeAdapter bridgeAdapter =
                ((ListRowPresenter.ViewHolder) rowVh).getBridgeAdapter();
        if (mPresenterMapper == null) {
            mPresenterMapper = bridgeAdapter.getPresenterMapper();
        } else {
            bridgeAdapter.setPresenterMapper(mPresenterMapper);
        }
    }
}
项目:androidtv-Leanback    文件:MainFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // Final initialization, modifying UI elements.
    super.onActivityCreated(savedInstanceState);

    // Prepare the manager that maintains the same background image between activities.
    prepareBackgroundManager();

    setupUIElements();
    setupEventListeners();
    prepareEntranceTransition();

    // Map category results from the database to ListRow objects.
    // This Adapter is used to render the MainFragment sidebar labels.
    mCategoryRowAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mCategoryRowAdapter);

    updateRecommendations();
}
项目: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;
}
项目: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;
}
项目: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    文件: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    文件:MoreSamplesFragment.java   
private void loadRows() {
    rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());

    HeaderItem gridHeader = new HeaderItem(1, getString(R.string.more_samples));
    GridItemPresenter gridPresenter = new GridItemPresenter(this);

    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(gridPresenter);
    gridRowAdapter.add(getString(R.string.grid_view));
    gridRowAdapter.add(getString(R.string.guidedstep_first_title));
    gridRowAdapter.add(getString(R.string.error_fragment));
    gridRowAdapter.add(getString(R.string.personal_settings));

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

    setAdapter(rowsAdapter);
}
项目:BuildingForAndroidTV    文件:CustomRowsFragment.java   
@Override
public void onLoadFinished(Loader<HashMap<String, List<Movie>>> arg0,
                           HashMap<String, List<Movie>> data) {

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

    int i = 0;

    for (Map.Entry<String, List<Movie>> entry : data.entrySet()) {
        ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
        List<Movie> list = entry.getValue();

        for (int j = 0; j < list.size(); j++) {
            listRowAdapter.add(list.get(j));
        }
        HeaderItem header = new HeaderItem(i, entry.getKey());
        i++;
        rowsAdapter.add(new ListRow(header, listRowAdapter));
    }

    setAdapter(rowsAdapter);

    updateRecommendations();
}
项目:BuildingForAndroidTV    文件:SearchFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setSearchResultProvider(this);
    setOnItemViewClickedListener(new ItemViewClickedListener());
    if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
        // SpeechRecognitionCallback is not required and if not provided recognition will be handled
        // using internal speech recognizer, in which case you must have RECORD_AUDIO permission
        setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
            @Override
            public void recognizeSpeech() {
                if (DEBUG) Log.v(TAG, "recognizeSpeech");
                try {
                    startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
                } catch (ActivityNotFoundException e) {
                    Log.e(TAG, "Cannot find activity for speech recognizer", e);
                }
            }
        });
    }
}
项目:HelloTV    文件:MainFragment.java   
private void loadRows() {
    List<Movie> list = MovieList.setupMovies();

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

    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]);
        mRowsAdapter.add(new ListRow(header, listRowAdapter));
    }

    HeaderItem gridHeader = new HeaderItem(i, "PREFERENCES");

    GridItemPresenter mGridPresenter = new GridItemPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(getResources().getString(R.string.grid_view));
    gridRowAdapter.add(getString(R.string.error_fragment));
    gridRowAdapter.add(getResources().getString(R.string.personal_settings));
    mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    setAdapter(mRowsAdapter);

}
项目:lostfilm-android-client    文件:MainFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mJobHelper = new JobHelper(getActivity());
    mDatabaseManager = new DatabaseManager();
    mCategoriesAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mCategoriesAdapter);
    prepareBackgroundManager();
    setupUI();
    setOnItemViewClickedListener(this);
    setOnItemViewSelectedListener(this);
    mJobHelper.scheduleTvShowsUpdate();
}
项目:lostfilm-android-client    文件:TvShowFragment.java   
private void updateData() {
    mCategoriesAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    for (Season season : mTvShow.getSeasons()) {
        ArrayObjectAdapter episodeAdapter = new ArrayObjectAdapter(new EpisodePresenter());
        episodeAdapter.addAll(0, season.getEpisodes());
        if (season.isHasFullSeasonDownloadUrl()) {
            episodeAdapter.add(new Episode("99", getString(R.string.full_season), season, -1, null));
        }
        mCategoriesAdapter.add(new ListRow(new HeaderItem(season.getName()), episodeAdapter));
    }
    setAdapter(mCategoriesAdapter);
}
项目:garras    文件:VideoDetailsFragment.java   
private void setupRelatedMovieListRow() {
    String subcategories[] = {getString(R.string.related_movies)};
    List<Movie> list = MovieList.getList();

    Collections.shuffle(list);
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
    for (int j = 0; j < NUM_COLS; j++) {
        listRowAdapter.add(list.get(j % 5));
    }

    HeaderItem header = new HeaderItem(0, subcategories[0]);
    mAdapter.add(new ListRow(header, listRowAdapter));
    mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
}
项目:tubik    文件:MainFragment.java   
private void loadRows() {
    List<Movie> list = MovieList.setupMovies();

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

    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]);
        mRowsAdapter.add(new ListRow(header, listRowAdapter));
    }

    HeaderItem gridHeader = new HeaderItem(i, "PREFERENCES");

    GridItemPresenter mGridPresenter = new GridItemPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(getResources().getString(R.string.grid_view));
    gridRowAdapter.add(getString(R.string.error_fragment));
    gridRowAdapter.add(getResources().getString(R.string.personal_settings));
    mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    setAdapter(mRowsAdapter);

}
项目:androidtv-sample    文件:PlaybackOverlayFragment.java   
@Override
public void onStart() {
    super.onStart();

    // Set up UI
    Video video = getActivity().getIntent().getParcelableExtra(VideoDetailsActivity.VIDEO);
    if (!updateSelectedVideo(video)) {
        return;
    }

    mGlue = new PlaybackControlHelper(getActivity(), this, mSelectedVideo);
    PlaybackControlsRowPresenter controlsRowPresenter = mGlue.createControlsRowAndPresenter();
    PlaybackControlsRow controlsRow = mGlue.getControlsRow();
    mMediaControllerCallback = mGlue.createMediaControllerCallback();

    mMediaController = getActivity().getMediaController();
    mMediaController.registerCallback(mMediaControllerCallback);

    ClassPresenterSelector ps = new ClassPresenterSelector();
    ps.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter);
    ps.addClassPresenter(ListRow.class, new ListRowPresenter());
    mRowsAdapter = new ArrayObjectAdapter(ps);
    mRowsAdapter.add(controlsRow);
    addOtherRows();
    updatePlaybackRow();
    setAdapter(mRowsAdapter);

    startPlaying();
}
项目:androidtv-sample    文件:VideoDetailsFragment.java   
private void setupAdapter() {
    // Set detail background and style.
    FullWidthDetailsOverviewRowPresenter detailsPresenter =
            new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(),
                    new MovieDetailsOverviewLogoPresenter());

    detailsPresenter.setBackgroundColor(
            ContextCompat.getColor(getActivity(), R.color.selected_background));
    detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF);

    // Hook up transition element.
    mHelper = new FullWidthDetailsOverviewSharedElementHelper();
    mHelper.setSharedElementEnterTransition(getActivity(),
            VideoDetailsActivity.SHARED_ELEMENT_NAME);
    detailsPresenter.setListener(mHelper);
    detailsPresenter.setParticipatingEntranceTransition(false);
    prepareEntranceTransition();

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(VideoDetailsActivity.VIDEO, mSelectedVideo);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    mPresenterSelector = new ClassPresenterSelector();
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
    mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
    mAdapter = new ArrayObjectAdapter(mPresenterSelector);
    setAdapter(mAdapter);
}
项目:androidtv-sample    文件:SearchFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    mVideoCursorAdapter.setMapper(new VideoCursorMapper());

    setSearchResultProvider(this);
    setOnItemViewClickedListener(new ItemViewClickedListener());
    if (DEBUG) {
        Log.d(TAG, "User is initiating a search. Do we have RECORD_AUDIO permission? " +
            hasPermission(Manifest.permission.RECORD_AUDIO));
    }
    if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
        if (DEBUG) {
            Log.d(TAG, "Does not have RECORD_AUDIO, using SpeechRecognitionCallback");
        }
        // SpeechRecognitionCallback is not required and if not provided recognition will be
        // handled using internal speech recognizer, in which case you must have RECORD_AUDIO
        // permission
        setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
            @Override
            public void recognizeSpeech() {
                try {
                    startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
                } catch (ActivityNotFoundException e) {
                    Log.e(TAG, "Cannot find activity for speech recognizer", e);
                }
            }
        });
    } else if (DEBUG) {
        Log.d(TAG, "We DO have RECORD_AUDIO");
    }
}
项目:leanback-extensions    文件:MainFragment.java   
private void loadRows() {
    List<Movie> list = MovieList.setupMovies();

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    CardPresenterSelector cardPresenterSelector = new CardPresenterSelector();

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

    HeaderItem gridHeader = new HeaderItem(i, "Misc");

    GridItemPresenter mGridPresenter = new GridItemPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(getResources().getString(R.string.justified_vertical_grid_view));
    gridRowAdapter.add(getString(R.string.loading_fragment));
    mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    setAdapter(mRowsAdapter);

}
项目:leanback-homescreen-channels    文件:TvSearchFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setSearchResultProvider(this);
    setOnItemViewClickedListener(getDefaultItemClickedListener());
    mDelayedLoad = new SearchRunnable();
}
项目:aos-Video    文件:ManualScrappingSearchFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mScraper = new Scraper(getActivity());
    mSearchExecutor = new SerialExecutor();

    ClassPresenterSelector rowsPresenterSelector = new ClassPresenterSelector();
    rowsPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
    rowsPresenterSelector.addClassPresenter(ShadowLessListRow.class, new ShadowLessRowPresenter());
    mRowsAdapter = new ArrayObjectAdapter(rowsPresenterSelector);

    setBadgeDrawable(getResources().getDrawable(R.mipmap.video2));
    setSearchResultProvider(this);
    setOnItemViewClickedListener(new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            if (item instanceof BaseTags) {
                saveTagsAndFinish((BaseTags) item);
            }
        }
    });
    mSpeechRecognitionCallback = new SpeechRecognitionCallback() {

        @Override
        public void recognizeSpeech() {

            // ACTION_RECOGNIZE_SPEECH
            try{
                startActivityForResult(getRecognizerIntent(), SEARCH_REQUEST_CODE);
            }catch (ActivityNotFoundException e){/*non google device*/}
        }
    };
    setSpeechRecognitionCallback(mSpeechRecognitionCallback);
}
项目:aos-Video    文件:NetworkRootFragment.java   
private void loadRows() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());

    ClassPresenterSelector classPresenter = new ClassPresenterSelector();
    classPresenter.addClassPresenter(NetworkShortcut.class, new NetworkShortcutPresenter());
    classPresenter.addClassPresenter(Box.class, new RescanBoxItemPresenter()); // for the rescan item
    mIndexedFoldersAdapter = new ArrayObjectAdapter(classPresenter);
    mIndexedFoldersListRow = new ListRow(
            new HeaderItem(getString(R.string.indexed_folders)),
            mIndexedFoldersAdapter);
    mRowsAdapter.add(mIndexedFoldersListRow);

    mSmbDiscoveryAdapter = new ArrayObjectAdapter(new SmbSharePresenter());
    mRowsAdapter.add(new ListRow(
            new HeaderItem(getString(R.string.network_shared_folders)),
            mSmbDiscoveryAdapter));
    if(UpnpAvailability.isUpnpAvaialbe()) {
        mUpnpDiscoveryAdapter = new ArrayObjectAdapter(new SmbSharePresenter());
        mRowsAdapter.add(new ListRow(
                new HeaderItem(getString(R.string.network_media_servers)),
                mUpnpDiscoveryAdapter));
    }

    mFtpShortcutsAdapter = new ArrayObjectAdapter(new NetworkShortcutPresenter());
    mRowsAdapter.add(new ListRow(
            new HeaderItem(getString(R.string.ftp_shortcuts)),
            mFtpShortcutsAdapter));

    setOnItemViewClickedListener(mClickListener);

    setAdapter(mRowsAdapter);
}
项目:aos-Video    文件:MarkAsWatchedFragment.java   
private void loadRows() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());

    mSeasonsAdapter = new CursorObjectAdapter(new SeasonPresenter(getActivity()));
    mSeasonsAdapter.setMapper(new CompatibleCursorMapperConverter(new SeasonCursorMapper()));
    mSeasonsListRow = new ListRow(
            new HeaderItem(getString(R.string.how_to_mark_season_watched)),
            mSeasonsAdapter);
    mRowsAdapter.add(mSeasonsListRow);

    setAdapter(mRowsAdapter);
}
项目:aos-Video    文件:MoviesByFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    mSortOrder = mPrefs.getString(getSortOrderParamKey(), MoviesLoader.DEFAULT_SORT);

    Resources r = getResources();
    BackgroundManager bgMngr = BackgroundManager.getInstance(getActivity());
    bgMngr.attach(getActivity().getWindow());
    bgMngr.setColor(r.getColor(R.color.leanback_background));

    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);

    // set fastLane (or headers) background color
    setBrandColor(r.getColor(R.color.leanback_side));

    // set search icon color
    setSearchAffordanceColor(r.getColor(R.color.lightblueA200));

    setupEventListeners();

    RowPresenter rowPresenter = new ListRowPresenter();
    rowPresenter.setHeaderPresenter(new RowHeaderPresenter());
    mRowsAdapter = new ArrayObjectAdapter(rowPresenter);
    setAdapter(mRowsAdapter);

    mVideoPresenter = new PosterImageCardPresenter(getActivity());
    mVideoMapper = new CompatibleCursorMapperConverter(new VideoCursorMapper());

    getLoaderManager().initLoader(-1, null, this);
}
项目:aos-Video    文件:SelectableListRowPresenter.java   
@Override
protected void onBindRowViewHolder(RowPresenter.ViewHolder holder, Object item) {
    super.onBindRowViewHolder(holder, item);

    setSelectedPosition((ListRowPresenter.ViewHolder)holder,((SelectableListRow)item).getStartingSelectedPosition());
    Log.d("changedebug", "onBindRowViewHolder " + ((ListRowPresenter.ViewHolder) holder).getGridView().getAdapter().getItemCount());

}