Java Code Examples for android.support.v17.leanback.widget.DetailsOverviewRow#setImageBitmap()

The following examples show how to use android.support.v17.leanback.widget.DetailsOverviewRow#setImageBitmap() . 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 android-tv-leanback with Apache License 2.0 6 votes vote down vote up
@Override
protected DetailsOverviewRow doInBackground(Video... videos) {
    DetailsOverviewRow row = new DetailsOverviewRow(videos[0]);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(videos[0].getThumbUrl())
                .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()),
                        dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext()))
                .centerCrop()
                .get();
        row.setImageBitmap(getActivity(), poster);
    } catch (IOException e) {
        Log.e("VideoDetailsFragment", "Cannot load thumbnail for " + videos[0].getId(), e);
    }

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();
    adapter.set(ACTION_PLAY, new Action(ACTION_PLAY, getResources().getString(
            R.string.action_play)));
    adapter.set(ACTION_WATCH_LATER, new Action(ACTION_WATCH_LATER, getResources().getString(R.string.action_watch_later)));
    row.setActionsAdapter(adapter);

    return row;
}
 
Example 2
Source File: VideoDetailsFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
@Override
protected DetailsOverviewRow doInBackground(Video... videos) {
    DetailsOverviewRow row = new DetailsOverviewRow(videos[0]);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(videos[0].getThumbUrl())
                .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()),
                        dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext()))
                .centerCrop()
                .get();
        row.setImageBitmap(getActivity(), poster);
    } catch (IOException e) {
        Log.e("VideoDetailsFragment", "Cannot load thumbnail for " + videos[0].getId(), e);
    }

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();
    adapter.set(ACTION_PLAY, new Action(ACTION_PLAY, getResources().getString(
            R.string.action_play)));
    adapter.set(ACTION_WATCH_LATER, new Action(ACTION_WATCH_LATER, getResources().getString(R.string.action_watch_later)));
    row.setActionsAdapter(adapter);

    return row;
}
 
Example 3
Source File: VideoDetailsFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
@Override
protected DetailsOverviewRow doInBackground(Video... videos) {
    DetailsOverviewRow row = new DetailsOverviewRow(videos[0]);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(videos[0].getThumbUrl())
                .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()),
                        dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext()))
                .centerCrop()
                .get();
        row.setImageBitmap(getActivity(), poster);
    } catch (IOException e) {
        Log.e("VideoDetailsFragment", "Cannot load thumbnail for " + videos[0].getId(), e);
    }

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();
    adapter.set(ACTION_PLAY, new Action(ACTION_PLAY, getResources().getString(
            R.string.action_play)));
    adapter.set(ACTION_WATCH_LATER, new Action(ACTION_WATCH_LATER, getResources().getString(R.string.action_watch_later)));
    row.setActionsAdapter(adapter);

    return row;
}
 
Example 4
Source File: VideoDetailsFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
@Override
protected DetailsOverviewRow doInBackground(Video... videos) {
    DetailsOverviewRow row = new DetailsOverviewRow(videos[0]);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(videos[0].getThumbUrl())
                .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()),
                        dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext()))
                .centerCrop()
                .get();
        row.setImageBitmap(getActivity(), poster);
    } catch (IOException e) {
        Log.e("VideoDetailsFragment", "Cannot load thumbnail for " + videos[0].getId(), e);
    }

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();
    adapter.set(ACTION_PLAY, new Action(ACTION_PLAY, getResources().getString(
            R.string.action_play)));
    adapter.set(ACTION_WATCH_LATER, new Action(ACTION_WATCH_LATER, getResources().getString(R.string.action_watch_later)));
    row.setActionsAdapter(adapter);

    return row;
}
 
Example 5
Source File: TVVideoDetailsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
protected DetailsOverviewRow doInBackground(Movie... movies) {
    selectedMovie = movies[0];

    DetailsOverviewRow row = new DetailsOverviewRow(selectedMovie);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(selectedMovie.getCardImageUrl())
                .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()),
                        dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext()))
                .centerCrop()
                .get();
        row.setImageBitmap(getActivity(), poster);
    } catch (IOException e) {
    }

    row.addAction(new Action(ACTION_WATCH_TRAILER, getResources().getString(
            R.string.watch_trailer_1), getResources().getString(R.string.watch_trailer_2)));
    row.addAction(new Action(ACTION_RENT, getResources().getString(R.string.rent_1),
            getResources().getString(R.string.rent_2)));
    row.addAction(new Action(ACTION_BUY, getResources().getString(R.string.buy_1),
            getResources().getString(R.string.buy_2)));
    return row;
}
 
Example 6
Source File: TVVideoDetailsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
protected DetailsOverviewRow doInBackground(Movie... movies) {
    selectedMovie = movies[0];

    DetailsOverviewRow row = new DetailsOverviewRow(selectedMovie);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(selectedMovie.getCardImageUrl())
                .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()),
                        dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext()))
                .centerCrop()
                .get();
        row.setImageBitmap(getActivity(), poster);
    } catch (IOException e) {
    }

    row.addAction(new Action(ACTION_WATCH_TRAILER, getResources().getString(
            R.string.watch_trailer_1), getResources().getString(R.string.watch_trailer_2)));
    row.addAction(new Action(ACTION_RENT, getResources().getString(R.string.rent_1),
            getResources().getString(R.string.rent_2)));
    row.addAction(new Action(ACTION_BUY, getResources().getString(R.string.buy_1),
            getResources().getString(R.string.buy_2)));
    return row;
}
 
Example 7
Source File: TVVideoDetailsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
protected DetailsOverviewRow doInBackground(Movie... movies) {
    selectedMovie = movies[0];

    DetailsOverviewRow row = new DetailsOverviewRow(selectedMovie);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(selectedMovie.getCardImageUrl())
                .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()),
                        dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext()))
                .centerCrop()
                .get();
        row.setImageBitmap(getActivity(), poster);
    } catch (IOException e) {
    }

    row.addAction(new Action(ACTION_WATCH_TRAILER, getResources().getString(
            R.string.watch_trailer_1), getResources().getString(R.string.watch_trailer_2)));
    row.addAction(new Action(ACTION_RENT, getResources().getString(R.string.rent_1),
            getResources().getString(R.string.rent_2)));
    row.addAction(new Action(ACTION_BUY, getResources().getString(R.string.buy_1),
            getResources().getString(R.string.buy_2)));
    return row;
}
 
Example 8
Source File: DetailFragment.java    From TuentiTV with Apache License 2.0 5 votes vote down vote up
private DetailsOverviewRow configureDetailsOverviewRow(CardInfo cardInfo, Bitmap bitmap) {
  final DetailsOverviewRow row = new DetailsOverviewRow(cardInfo);
  row.setImageBitmap(getActivity(), bitmap);
  row.addAction(new Action(VD_CALL_ACTION_ID, getString(R.string.vd_call_action_title)));
  row.addAction(new Action(CALL_ACTION_ID, getString(R.string.call_action_title)));
  row.addAction(new Action(CHAT_ACTION_ID, getString(R.string.chat_action_title)));
  row.addAction(new Action(EDIT_ACTION_ID, getString(R.string.edit_action_title)));
  return row;
}
 
Example 9
Source File: DetailRowBuilderTask.java    From Amphitheatre with Apache License 2.0 5 votes vote down vote up
@Override
protected DetailsOverviewRow doInBackground(Video... videos) {
    mVideo = videos[0];

    DetailsOverviewRow row = new DetailsOverviewRow(mVideo);
    try {
        Bitmap poster = Picasso.with(mActivity)
                .load(mVideo.getCardImageUrl())
                .resize(Utils.dpToPx(DETAIL_THUMB_WIDTH, mActivity.getApplicationContext()),
                        Utils.dpToPx(DETAIL_THUMB_HEIGHT, mActivity.getApplicationContext()))
                .centerCrop()
                .get();
        row.setImageBitmap(mActivity, poster);
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (mShowPlayButton) {
        row.addAction(new Action(ACTION_PLAY, mActivity.getString(R.string.play)));
    }

    if (mVideo.getMovie() != null && !TextUtils.isEmpty(mVideo.getMovie().getTrailer())) {
        row.addAction(
                new Action(ACTION_VIEW_TRAILER, mActivity.getString(R.string.watch_trailer)));
    }

    return row;
}
 
Example 10
Source File: RichAppLinkDetailsFragment.java    From androidtv-sample-inputs with Apache License 2.0 4 votes vote down vote up
@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);
}