android.support.v17.leanback.widget.ClassPresenterSelector Java Examples
The following examples show how to use
android.support.v17.leanback.widget.ClassPresenterSelector.
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: VideoDetailsFragment.java From leanback-assistant with Apache License 2.0 | 5 votes |
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); }
Example #2
Source File: DetailFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
@Override public void showCardInfo(final CardInfo cardInfo) { new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... params) { Bitmap detailImage = null; try { detailImage = Picasso.with(getActivity()) .load(cardInfo.getCardImageUrl()) .placeholder(R.drawable.icn_wink) .error(R.drawable.icn_wink) .resize(Util.convertDpToPixel(getActivity(), DETAIL_THUMB_WIDTH), Util.convertDpToPixel(getActivity(), DETAIL_THUMB_HEIGHT)) .centerCrop() .get(); } catch (IOException e) { //Empty } return detailImage; } @Override protected void onPostExecute(Bitmap bitmap) { DetailsOverviewRow detailRow = configureDetailsOverviewRow(cardInfo, bitmap); ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter()); dorPresenter.setBackgroundColor(getResources().getColor(R.color.primary_color)); dorPresenter.setStyleLarge(false); presenterSelector.addClassPresenter(DetailsOverviewRow.class, dorPresenter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); adapter = new ArrayObjectAdapter(presenterSelector); adapter.add(detailRow); setAdapter(adapter); } }.execute(); }
Example #3
Source File: DetailRowBuilderTask.java From Amphitheatre with Apache License 2.0 | 5 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter(mActivity)); dorPresenter.setBackgroundColor(mActivity.getResources().getColor(R.color.fastlane_background)); dorPresenter.setStyleLarge(true); dorPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_PLAY) { VideoUtils.playVideo(new WeakReference<Activity>(mActivity), mVideo); } else if (action.getId() == ACTION_VIEW_TRAILER) { Uri trailerUri = Uri.parse(mVideo.getMovie().getTrailer()); mActivity.startActivity(new Intent(Intent.ACTION_VIEW, trailerUri)); } else { Toast.makeText(mActivity, action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, dorPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); addGroups(adapter); if (mRowBuilderTaskListener != null) { mRowBuilderTaskListener.taskCompleted(adapter); } }
Example #4
Source File: VideoDetailsFragment.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
@Override protected void onPostExecute( DetailsOverviewRow detailRow ) { if( detailRow == null ) return; ClassPresenterSelector ps = new ClassPresenterSelector(); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter( new DetailsDescriptionPresenter() ); // set detail background and style dorPresenter.setBackgroundColor( getResources().getColor( R.color.detail_background ) ); dorPresenter.setStyleLarge( true ); dorPresenter.setOnActionClickedListener( new OnActionClickedListener() { @Override public void onActionClicked( Action action ) { if (action.getId() == ACTION_WATCH ) { Intent intent = new Intent( getActivity(), PlayerActivity.class ); intent.putExtra( EXTRA_MOVIE, mSelectedMovie ); intent.putExtra( EXTRA_SHOULD_AUTO_START, true ); startActivity( intent ); } } }); ps.addClassPresenter( DetailsOverviewRow.class, dorPresenter ); ps.addClassPresenter( ListRow.class, new ListRowPresenter() ); ArrayObjectAdapter adapter = new ArrayObjectAdapter( ps ); adapter.add( detailRow ); loadRelatedMedia( adapter ); setAdapter( adapter ); }
Example #5
Source File: AppDetailsFragment.java From TvAppRepo with Apache License 2.0 | 4 votes |
private void setupAdapter() { mPresenterSelector = new ClassPresenterSelector(); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
Example #6
Source File: VideoDetailsFragment.java From android-tv-leanback with Apache License 2.0 | 4 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext())); detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_PLAY) { Intent intent = new Intent(getActivity(), PlayerActivity.class); intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); /** bonus code for adding related items to details fragment **/ // <START> ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); String subcategories[] = { "You may also like" }; CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter())); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter); manager.startDataLoading(); HeaderItem header = new HeaderItem(0, subcategories[0]); adapter.add(new ListRow(header, rowAdapter)); setAdapter(adapter); // <END> }
Example #7
Source File: VideoDetailsFragment.java From android-tv-leanback with Apache License 2.0 | 4 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext())); detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_PLAY) { Intent intent = new Intent(getActivity(), PlayerActivity.class); intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); /** bonus code for adding related items to details fragment **/ // <START> ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); String subcategories[] = { "You may also like" }; CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter())); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter); manager.startDataLoading(); HeaderItem header = new HeaderItem(0, subcategories[0]); adapter.add(new ListRow(header, rowAdapter)); setAdapter(adapter); // <END> }
Example #8
Source File: VideoDetailsFragment.java From android-tv-leanback with Apache License 2.0 | 4 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext())); detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_PLAY) { Intent intent = new Intent(getActivity(), PlayerActivity.class); intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); /** bonus code for adding related items to details fragment **/ // <START> ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); String subcategories[] = { "You may also like" }; CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter())); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter); manager.startDataLoading(); HeaderItem header = new HeaderItem(0, subcategories[0]); adapter.add(new ListRow(header, rowAdapter)); setAdapter(adapter); // <END> }
Example #9
Source File: VideoDetailsFragment.java From android-tv-leanback with Apache License 2.0 | 4 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext())); detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_PLAY) { Intent intent = new Intent(getActivity(), PlayerActivity.class); intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); /** bonus code for adding related items to details fragment **/ // <START> ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); String subcategories[] = { "You may also like" }; CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter())); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter); manager.startDataLoading(); HeaderItem header = new HeaderItem(0, subcategories[0]); adapter.add(new ListRow(header, rowAdapter)); setAdapter(adapter); // <END> }
Example #10
Source File: VideoDetailsFragment.java From CumulusTV with MIT License | 4 votes |
private void setupAdapter() { mPresenterSelector = new ClassPresenterSelector(); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
Example #11
Source File: RichAppLinkDetailsFragment.java From androidtv-sample-inputs with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String displayNumber = getActivity().getIntent().getStringExtra( RichFeedUtil.EXTRA_DISPLAY_NUMBER); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter( new DetailsDescriptionPresenter()); dorPresenter.setSharedElementEnterTransition(getActivity(), "RichAppLinkDetailsFragment"); DetailsOverviewRow row = new DetailsOverviewRow(displayNumber); Resources res = getResources(); Bitmap bitmap = BitmapFactory.decodeResource(res, R.drawable.your_company); int length = Math.min(bitmap.getWidth(), bitmap.getHeight()); Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, (bitmap.getWidth() - length) / 2, (bitmap.getHeight() - length) / 2, length, length); row.setImageBitmap(getActivity(), croppedBitmap); Action action1 = new Action(0, res.getString(R.string.details_fragment_action_1)); Action action2 = new Action(1, res.getString(R.string.details_fragment_action_2)); row.addAction(action1); row.addAction(action2); ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); dorPresenter.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.detail_background)); dorPresenter.setStyleLarge(true); dorPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { getActivity().finish(); } }); presenterSelector.addClassPresenter(DetailsOverviewRow.class, dorPresenter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector); adapter.add(row); setAdapter(adapter); }
Example #12
Source File: TVVideoDetailsFragment.java From BuildingForAndroidTV with MIT License | 4 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter()); // set detail background and style dorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background)); dorPresenter.setStyleLarge(true); dorPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH_TRAILER) { Intent intent = new Intent(getActivity(), PlayerActivity.class); intent.putExtra(getResources().getString(R.string.movie), selectedMovie); intent.putExtra(getResources().getString(R.string.should_start), true); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, dorPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); String subcategories[] = { getString(R.string.related_movies) }; List<Movie> list = MovieList.list; 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], null); adapter.add(new ListRow(header, listRowAdapter)); setAdapter(adapter); }
Example #13
Source File: TVVideoDetailsFragment.java From BuildingForAndroidTV with MIT License | 4 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter()); // set detail background and style dorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background)); dorPresenter.setStyleLarge(true); dorPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH_TRAILER) { Intent intent = new Intent(getActivity(), PlayerActivity.class); intent.putExtra(getResources().getString(R.string.movie), selectedMovie); intent.putExtra(getResources().getString(R.string.should_start), true); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, dorPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); String subcategories[] = { getString(R.string.related_movies) }; List<Movie> list = MovieList.list; 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], null); adapter.add(new ListRow(header, listRowAdapter)); setAdapter(adapter); }
Example #14
Source File: TVVideoDetailsFragment.java From BuildingForAndroidTV with MIT License | 4 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter()); // set detail background and style dorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background)); dorPresenter.setStyleLarge(true); dorPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH_TRAILER) { Intent intent = new Intent(getActivity(), PlayerActivity.class); intent.putExtra(getResources().getString(R.string.movie), selectedMovie); intent.putExtra(getResources().getString(R.string.should_start), true); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, dorPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); String subcategories[] = { getString(R.string.related_movies) }; List<Movie> list = MovieList.list; 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], null); adapter.add(new ListRow(header, listRowAdapter)); setAdapter(adapter); }
Example #15
Source File: MovieDetailsFragment.java From BuildingForAndroidTV with MIT License | 4 votes |
private void setupAdapter() { mPresenterSelector = new ClassPresenterSelector(); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }