android.support.v17.leanback.widget.SparseArrayObjectAdapter Java Examples

The following examples show how to use android.support.v17.leanback.widget.SparseArrayObjectAdapter. 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: VideoDetailsFragment.java    From leanback-assistant with Apache License 2.0 5 votes vote down vote up
private void setupDetailsOverviewRow() {
    final DetailsOverviewRow row = new DetailsOverviewRow(mMovie);

    Glide.with(this)
            .load(mMovie.getCardImage())
            .asBitmap()
            .dontAnimate()
            .error(R.drawable.assistant_tv_banner)
            .into(
                    new SimpleTarget<Bitmap>() {
                        @Override
                        public void onResourceReady(
                                final Bitmap resource, GlideAnimation glideAnimation) {
                            row.setImageBitmap(getActivity(), resource);
                        }
                    });

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();

    adapter.set(
            ACTION_WATCH, new Action(ACTION_WATCH, getResources().getString(R.string.watch)));
    adapter.set(
            ACTION_RENT,
            new Action(
                    ACTION_RENT,
                    getResources().getString(R.string.rent),
                    mMovie.getRentalPrice()));
    adapter.set(
            ACTION_BUY,
            new Action(
                    ACTION_BUY,
                    getResources().getString(R.string.buy),
                    mMovie.getPurchasePrice()));
    row.setActionsAdapter(adapter);

    mAdapter.add(row);
}
 
Example #6
Source File: AppDetailsFragment.java    From TvAppRepo with Apache License 2.0 4 votes vote down vote up
private void setupDetailsOverviewRow() {
    Log.d(TAG, "doInBackground: " + mSelectedApk.toString());
    final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedApk);
    row.setImageDrawable(getResources().getDrawable(R.drawable.default_background));
    int width = Utils.convertDpToPixel(getActivity()
            .getApplicationContext(), DETAIL_THUMB_WIDTH);
    int height = Utils.convertDpToPixel(getActivity()
            .getApplicationContext(), DETAIL_THUMB_HEIGHT);
    Glide.with(getActivity())
            .load(mSelectedApk.getIcon())
            .centerCrop()
            .error(R.drawable.default_background)
            .into(new SimpleTarget<GlideDrawable>(width, height) {
                @Override
                public void onResourceReady(GlideDrawable resource,
                                            GlideAnimation<? super GlideDrawable>
                                                    glideAnimation) {
                    Log.d(TAG, "details overview card image url ready: " + resource);
                    row.setImageDrawable(resource);
                    mAdapter.notifyArrayItemRangeChanged(0, mAdapter.size());
                }
            });

    // See if this is already installed. If so, check if it can be updated.
    // Offer an uninstall option.
    // Add an install button.
    SparseArrayObjectAdapter possibleActions = new SparseArrayObjectAdapter();
    PackageManager packageManager = getActivity().getPackageManager();
    try {
        PackageInfo info = packageManager.getPackageInfo(mSelectedApk.getPackageName(), 0);
        if (info.versionCode < mSelectedApk.getVersionCode()) {
            possibleActions.set(ACTION_UPDATE,
                    new Action(ACTION_UPDATE, getString(R.string.update)));
        }
        possibleActions.set(ACTION_UNINSTALL,
                new Action(ACTION_UNINSTALL, getString(R.string.uninstall)));
    } catch (PackageManager.NameNotFoundException e) {
        // App is not installed
        possibleActions.set(ACTION_INSTALL,
                new Action(ACTION_INSTALL, getString(R.string.install)));
    }
    row.setActionsAdapter(possibleActions);

    mAdapter.add(row);
}