本文整理汇总了Java中android.support.v17.leanback.widget.ClassPresenterSelector类的典型用法代码示例。如果您正苦于以下问题:Java ClassPresenterSelector类的具体用法?Java ClassPresenterSelector怎么用?Java ClassPresenterSelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassPresenterSelector类属于android.support.v17.leanback.widget包,在下文中一共展示了ClassPresenterSelector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate DetailsFragment");
super.onCreate(savedInstanceState);
mDetailsBackground = new DetailsFragmentBackgroundController(this);
mSelectedMovie =
(Movie) getActivity().getIntent().getSerializableExtra(DetailsActivity.MOVIE);
if (mSelectedMovie != null) {
mPresenterSelector = new ClassPresenterSelector();
mAdapter = new ArrayObjectAdapter(mPresenterSelector);
setupDetailsOverviewRow();
setupDetailsOverviewRowPresenter();
setupRelatedMovieListRow();
setAdapter(mAdapter);
initializeBackground(mSelectedMovie);
setOnItemViewClickedListener(new ItemViewClickedListener());
} else {
Intent intent = new Intent(getActivity(), MainActivity.class);
startActivity(intent);
}
}
示例2: buildFilePresenter
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
private ClassPresenterSelector buildFilePresenter() {
ClassPresenterSelector filePresenterSelector = new ClassPresenterSelector();
switch (mDisplayMode) {
case GRID:
filePresenterSelector.addClassPresenter(MetaFile2.class, new PosterImageCardPresenter(getActivity()));
filePresenterSelector.addClassPresenter(Video.class, new PosterImageCardPresenter(getActivity()));
break;
case LIST:
filePresenterSelector.addClassPresenter(MetaFile2.class, new MetaFileListPresenter());
filePresenterSelector.addClassPresenter(Video.class, new VideoListPresenter(true));
break;
default:
throw new IllegalArgumentException("Invalid Display Mode! "+mDisplayMode);
}
return filePresenterSelector;
}
示例3: onPostExecute
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
@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);
}
示例4: createNewSeasonRow
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
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;
}
示例5: initializeRelatedVideosRow
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
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;
}
示例6: buildAboutAdapter
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
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;
}
示例7: onStart
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
@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();
}
示例8: setupAdapter
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
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);
}
示例9: onCreate
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
@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);
}
示例10: updateRow
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
private void updateRow(){
if ((mSearchResults==null||mSearchResults.isEmpty())&&mNfoTags==null) {
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new EmptyViewPresenter());
listRowAdapter.add(new EmptyView(getEmptyText()));
mRowsAdapter.clear();
mRowsAdapter.add(new ShadowLessListRow(new HeaderItem(getString(R.string.search_results)), listRowAdapter));
}
else {
// Prepare the result list widget
ClassPresenterSelector classPresenter = new ClassPresenterSelector();
classPresenter.addClassPresenter(SearchResult.class, new ScraperSearchResultPresenter()); // for initial search result
classPresenter.addClassPresenter(BaseTags.class, new ScraperBaseTagsPresenter()); // for detailed result info
mResultsAdapter = new ArrayObjectAdapter(classPresenter);
if(mNfoTags!=null) {
mResultsAdapter.add(0, mNfoTags);
mOffset=1;
}
if(mSearchResults!=null)
mResultsAdapter.addAll(mOffset, mSearchResults);
ListRow listRow = new ListRow(new HeaderItem(getResultsHeaderText()), mResultsAdapter);
mRowsAdapter.clear();
mRowsAdapter.add(listRow);
if(mSearchResults!=null) {
// Launch the details task to get posters, etc.
SearchResult[] array = mSearchResults.toArray(new SearchResult[mSearchResults.size()]);
mDetailsTask = new ScraperDetailsFetchTask().executeOnExecutor(mSearchExecutor,array);
}
}
}
示例11: loadRows
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
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);
}
示例12: onStart
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
@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();
}
示例13: setupAdapter
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
private void setupAdapter() {
FullWidthDetailsOverviewRowPresenter detailsPresenter =
new FullWidthDetailsOverviewRowPresenter(
new DetailsDescriptionPresenter(), new MovieDetailsOverviewLogoPresenter());
detailsPresenter.setBackgroundColor(
ContextCompat.getColor(getContext(), R.color.background_dark));
detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF);
detailsPresenter.setOnActionClickedListener(
new OnActionClickedListener() {
@Override
public void onActionClicked(Action action) {
if (action.getId() == ACTION_WATCH) {
Intent intent =
PlaybackActivity.createIntent(getContext(), mMovie.getId());
startActivity(intent);
} else {
Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT)
.show();
}
}
});
ClassPresenterSelector mPresenterSelector = new ClassPresenterSelector();
mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
mAdapter = new ArrayObjectAdapter(mPresenterSelector);
setAdapter(mAdapter);
}
示例14: setUpRows
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
private void setUpRows() {
PlaybackControlsRowPresenter controlsRowPresenter =
mPlaybackControlHelper.createControlsRowAndPresenter();
ClassPresenterSelector selector = new ClassPresenterSelector();
selector.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter);
selector.addClassPresenter(ListRow.class, new ListRowPresenter());
mRowsAdapter = new ArrayObjectAdapter(selector);
mRowsAdapter.add(mPlaybackControlHelper.getControlsRow());
mRelatedRecordingsRow = getRelatedRecordingsRow();
setAdapter(mRowsAdapter);
}
示例15: onCreatePresenterSelector
import android.support.v17.leanback.widget.ClassPresenterSelector; //导入依赖的package包/类
@Override
protected PresenterSelector onCreatePresenterSelector(
DetailsOverviewRowPresenter rowPresenter) {
ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
presenterSelector.addClassPresenter(DetailsOverviewRow.class, rowPresenter);
presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
return presenterSelector;
}