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

The following examples show how to use android.support.v17.leanback.widget.DetailsOverviewRow#setImageDrawable() . 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: MovieDetailsFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private void setupDetailsOverviewRow() {
    Log.d(TAG, "doInBackground: " + mSelectedMovie.toString());
    final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedMovie);
    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(mSelectedMovie.getCardImageUrl())
            .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());
                }
            });

    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)));

    mAdapter.add(row);
}
 
Example 2
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);
}
 
Example 3
Source File: VideoDetailsFragment.java    From CumulusTV with MIT License 4 votes vote down vote up
private void setupDetailsOverviewRow() {
    final DetailsOverviewRow row = new DetailsOverviewRow(jsonChannel);
    row.setImageDrawable(getResources().getDrawable(R.drawable.c_background5));
    int width = Utils.convertDpToPixel(getActivity()
            .getApplicationContext(), DETAIL_THUMB_WIDTH);
    int height = Utils.convertDpToPixel(getActivity()
            .getApplicationContext(), DETAIL_THUMB_HEIGHT);
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                final Bitmap bitmap = Glide.with(getActivity())
                        .load(ChannelDatabase.getNonNullChannelLogo(jsonChannel))
                        .asBitmap()
                        .fitCenter()
                        .error(R.drawable.c_background5)
                        .into(DETAIL_THUMB_WIDTH, DETAIL_THUMB_HEIGHT)
                        .get();
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        row.setImageBitmap(getActivity(), bitmap);
                        mAdapter.notifyArrayItemRangeChanged(0, mAdapter.size());
                    }
                });
            } catch (InterruptedException | ExecutionException e) {
                e.printStackTrace();
            }
        }
    }).start();

    ArrayObjectAdapter actions = new ArrayObjectAdapter();
    // Add another action IF it isn't a channel you already have:
    ChannelDatabase cdn = ChannelDatabase.getInstance(getActivity());
    if(cdn.findChannelByMediaUrl(jsonChannel.getMediaUrl()) == null) {
        actions.add(new Action(ACTION_ADD, getString(R.string.add_channel_txt)));
    } else {
        actions.add(new Action(ACTION_EDIT, getString(R.string.edit_channel)));
    }
    actions.add(new Action(ACTION_WATCH, getString(R.string.play)));
    row.setActionsAdapter(actions);
    mAdapter.add(row);
}