Java 类android.support.v17.leanback.widget.SparseArrayObjectAdapter 实例源码

项目:android_packages_apps_tv    文件:SeriesRecordingDetailsFragment.java   
@Override
protected SparseArrayObjectAdapter onCreateActionsAdapter() {
    mActionsAdapter = new SparseArrayObjectAdapter(new ActionPresenterSelector());
    Resources res = getResources();
    updateWatchAction();
    mActionsAdapter.set(ACTION_SERIES_SCHEDULES, new Action(ACTION_SERIES_SCHEDULES,
            getString(R.string.dvr_detail_view_schedule), null,
            res.getDrawable(R.drawable.ic_schedule_32dp, null)));
    mDeleteAction = new Action(ACTION_DELETE,
            getString(R.string.dvr_detail_series_delete), null,
            res.getDrawable(R.drawable.ic_delete_32dp, null));
    if (!mRecordedPrograms.isEmpty()) {
        mActionsAdapter.set(ACTION_DELETE, mDeleteAction);
    }
    return mActionsAdapter;
}
项目:android_packages_apps_tv    文件:ScheduledRecordingDetailsFragment.java   
@Override
protected SparseArrayObjectAdapter onCreateActionsAdapter() {
    SparseArrayObjectAdapter adapter =
            new SparseArrayObjectAdapter(new ActionPresenterSelector());
    Resources res = getResources();
    if (!mHideViewSchedule) {
        mScheduleAction = new Action(ACTION_VIEW_SCHEDULE,
                res.getString(R.string.dvr_detail_view_schedule), null,
                res.getDrawable(getScheduleIconId()));
        adapter.set(ACTION_VIEW_SCHEDULE, mScheduleAction);
    }
    adapter.set(ACTION_CANCEL, new Action(ACTION_CANCEL,
            res.getString(R.string.epg_dvr_dialog_message_remove_recording_schedule), null,
            res.getDrawable(R.drawable.ic_dvr_cancel_32dp)));
    return adapter;
}
项目:android_packages_apps_tv    文件:RecordedProgramDetailsFragment.java   
@Override
protected SparseArrayObjectAdapter onCreateActionsAdapter() {
    SparseArrayObjectAdapter adapter =
            new SparseArrayObjectAdapter(new ActionPresenterSelector());
    Resources res = getResources();
    if (mDvrWatchedPositionManager.getWatchedStatus(mRecordedProgram)
            == DvrWatchedPositionManager.DVR_WATCHED_STATUS_WATCHING) {
        adapter.set(ACTION_RESUME_PLAYING, new Action(ACTION_RESUME_PLAYING,
                res.getString(R.string.dvr_detail_resume_play), null,
                res.getDrawable(R.drawable.lb_ic_play)));
        adapter.set(ACTION_PLAY_FROM_BEGINNING, new Action(ACTION_PLAY_FROM_BEGINNING,
                res.getString(R.string.dvr_detail_play_from_beginning), null,
                res.getDrawable(R.drawable.lb_ic_replay)));
    } else {
        adapter.set(ACTION_PLAY_FROM_BEGINNING, new Action(ACTION_PLAY_FROM_BEGINNING,
                res.getString(R.string.dvr_detail_watch), null,
                res.getDrawable(R.drawable.lb_ic_play)));
    }
    adapter.set(ACTION_DELETE_RECORDING, new Action(ACTION_DELETE_RECORDING,
            res.getString(R.string.dvr_detail_delete), null,
            res.getDrawable(R.drawable.ic_delete_32dp)));
    return adapter;
}
项目:android-tv-leanback    文件:VideoDetailsFragment.java   
@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;
}
项目:android-tv-leanback    文件:VideoDetailsFragment.java   
@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;
}
项目:android-tv-leanback    文件:VideoDetailsFragment.java   
@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;
}
项目:android-tv-leanback    文件:VideoDetailsFragment.java   
@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;
}
项目:androidtv-sample    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRow() {
    final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedVideo);

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

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();

    adapter.set(ACTION_WATCH_TRAILER, new Action(ACTION_WATCH_TRAILER, getResources()
            .getString(R.string.watch_trailer_1),
            getResources().getString(R.string.watch_trailer_2)));
    adapter.set(ACTION_RENT, new Action(ACTION_RENT, getResources().getString(R.string.rent_1),
            getResources().getString(R.string.rent_2)));
    adapter.set(ACTION_BUY, new Action(ACTION_BUY, getResources().getString(R.string.buy_1),
            getResources().getString(R.string.buy_2)));
    row.setActionsAdapter(adapter);

    mAdapter.add(row);
}
项目:chilly    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRow() {
        final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedVideo);

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

        SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();

        adapter.set(ACTION_PLAY_NOW, new Action(ACTION_PLAY_NOW, getResources()
                .getString(R.string.play_now)));
        adapter.set(ACTION_PLAY_FROM, new Action(ACTION_PLAY_FROM, getResources().getString(R.string.play_from)));
//        adapter.set(ACTION_PLAY_TRAILER, new Action(ACTION_PLAY_TRAILER, getResources().getString(R.string.play_trailer)));
        if(Chilly.getInstance(getActivity().getApplicationContext()).userLoggedIn()){
            adapter.set(ACTION_TRAKT, new Action(ACTION_TRAKT, "TRAKT"));
        }

        row.setActionsAdapter(adapter);

        mAdapter.add(row);
    }
项目:leanback-assistant    文件:VideoDetailsFragment.java   
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);
}
项目:android_packages_apps_tv    文件:CurrentRecordingDetailsFragment.java   
@Override
protected SparseArrayObjectAdapter onCreateActionsAdapter() {
    SparseArrayObjectAdapter adapter =
            new SparseArrayObjectAdapter(new ActionPresenterSelector());
    Resources res = getResources();
    adapter.set(ACTION_STOP_RECORDING, new Action(ACTION_STOP_RECORDING,
            res.getString(R.string.epg_dvr_dialog_message_stop_recording), null,
            res.getDrawable(R.drawable.lb_ic_stop)));
    return adapter;
}
项目:itplayer    文件:ExoPlayerGlue.java   
@Override
protected void onCreatePrimaryActions(SparseArrayObjectAdapter primaryActionsAdapter) {
    this.primaryActionsAdapter = primaryActionsAdapter;

    closedCaptionAction = new PlaybackControlsRow.ClosedCaptioningAction(getContext());
    closedCaptionAction.setIndex(PlaybackControlsRow.ClosedCaptioningAction.ON);

    primaryActionsAdapter.notifyArrayItemRangeChanged(primaryActionsAdapter.indexOf(closedCaptionAction), 1);

    primaryActionsAdapter.set(ACTION_CUSTOM_RIGHT_FIRST, closedCaptionAction);
}
项目:androidtv-Leanback    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRow() {
    final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedVideo);

    RequestOptions options = new RequestOptions()
            .error(R.drawable.default_background)
            .dontAnimate();

    Glide.with(this)
            .asBitmap()
            .load(mSelectedVideo.cardImageUrl)
            .apply(options)
            .into(new SimpleTarget<Bitmap>() {
                @Override
                public void onResourceReady(
                        Bitmap resource,
                        Transition<? super Bitmap> transition) {
                    row.setImageBitmap(getActivity(), resource);
                    startEntranceTransition();
                }
            });

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();

    adapter.set(ACTION_WATCH_TRAILER, new Action(ACTION_WATCH_TRAILER, getResources()
            .getString(R.string.watch_trailer_1),
            getResources().getString(R.string.watch_trailer_2)));
    adapter.set(ACTION_RENT, new Action(ACTION_RENT, getResources().getString(R.string.rent_1),
            getResources().getString(R.string.rent_2)));
    adapter.set(ACTION_BUY, new Action(ACTION_BUY, getResources().getString(R.string.buy_1),
            getResources().getString(R.string.buy_2)));
    row.setActionsAdapter(adapter);

    mAdapter.add(row);
}
项目:chaosflix-leanback    文件:PlaybackHelper.java   
private SparseArrayObjectAdapter getPrimaryActionsAdapter() {
    return (SparseArrayObjectAdapter) getControlsRow().getPrimaryActionsAdapter();
}
项目:androidtv-sample    文件:PlaybackControlHelper.java   
private SparseArrayObjectAdapter getPrimaryActionsAdapter() {
    return (SparseArrayObjectAdapter) getControlsRow().getPrimaryActionsAdapter();
}
项目:chaosflix    文件:PlaybackHelper.java   
private SparseArrayObjectAdapter getPrimaryActionsAdapter() {
    return (SparseArrayObjectAdapter) getControlsRow().getPrimaryActionsAdapter();
}
项目:chilly    文件:PlaybackControlHelper.java   
private SparseArrayObjectAdapter getPrimaryActionsAdapter() {
    return (SparseArrayObjectAdapter) getControlsRow().getPrimaryActionsAdapter();
}
项目:TvAppRepo    文件:AppDetailsFragment.java   
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);
}
项目:danish-media-license    文件:DetailsFragment.java   
private void createActions(DetailsOverviewRow detailsRow) {
  SparseArrayObjectAdapter actionsAdapter = new SparseArrayObjectAdapter();
  actionsAdapter.set(ACTION_PLAY,
      new Action(ACTION_PLAY, getString(R.string.ondemand_details_action_play)));
  detailsRow.setActionsAdapter(actionsAdapter);
}
项目:android_packages_apps_tv    文件:DvrDetailsFragment.java   
/**
 * Creates actions users can interact with and their adaptor for this fragment.
 */
abstract SparseArrayObjectAdapter onCreateActionsAdapter();