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

项目:HelloTV    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:chaosflix-leanback    文件:PlaybackHelper.java   
@Override
public PlaybackControlsRowPresenter createControlsRowAndPresenter() {
    PlaybackControlsRowPresenter presenter = super.createControlsRowAndPresenter();
    adapter = new ArrayObjectAdapter(new ControlButtonPresenterSelector());
    getControlsRow().setSecondaryActionsAdapter(adapter);

    mFastForwardAction = (PlaybackControlsRow.FastForwardAction) getPrimaryActionsAdapter()
            .lookup(ACTION_FAST_FORWARD);

    mRewindAction = (PlaybackControlsRow.RewindAction) getPrimaryActionsAdapter()
            .lookup(ACTION_REWIND);

    presenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            dispatchAction(action);
        }
    });
    return presenter;
}
项目:tubik    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:androidtv-sample    文件:PlaybackControlHelper.java   
@TargetApi(VERSION_CODES.N)
public void dispatchAction(Action action) {
    if (action instanceof PlaybackControlsRow.MultiAction) {
        PlaybackControlsRow.MultiAction multiAction = (PlaybackControlsRow.MultiAction) action;
        multiAction.nextIndex();
        notifyActionChanged(multiAction);
    }

    if (action == mFastForwardAction) {
        mTransportControls.fastForward();
    } else if (action == mRewindAction) {
        mTransportControls.rewind();
    } else if (action.getId() == mPipAction.getId()) {
        ((Activity) getContext()).enterPictureInPictureMode();
    } else {
        super.onActionClicked(action);
    }
}
项目:chaosflix    文件:EventsDetailsFragment.java   
private ArrayObjectAdapter getRecordingActionsAdapter(List<Recording> recordings) {
    ArrayObjectAdapter actionsAdapter = new ArrayObjectAdapter();
    if(mWatchlistItem != null){
        actionsAdapter.add(new Action(REMOVE_WATCHLIST_ACTION,getString(R.string.remove_from_watchlist)));
    } else {
        actionsAdapter.add(new Action(ADD_WATCHLIST_ACTION,getString(R.string.add_to_watchlist)));
    }
    if (recordings != null) {
        for (int i = 0; i < recordings.size(); i++) {
            Recording recording = recordings.get(i);
            if (recording.getMimeType().startsWith("video/") || true) {
                String quality = recording.isHighQuality() ? "HD" : "SD";
                String title = quality + " (" + recording.getLanguage() + ")";
                actionsAdapter.add(new Action(recording.getApiID(), title, recording.getMimeType().substring(6)));
            }
        }
    } else {
        actionsAdapter.add(new Action(DUMMY_ID, "Dummy", "HLS"));
    }
    return actionsAdapter;
}
项目:chaosflix    文件:PlaybackHelper.java   
@Override
public PlaybackControlsRowPresenter createControlsRowAndPresenter() {
    PlaybackControlsRowPresenter presenter = super.createControlsRowAndPresenter();
    adapter = new ArrayObjectAdapter(new ControlButtonPresenterSelector());
    getControlsRow().setSecondaryActionsAdapter(adapter);

    mFastForwardAction = (PlaybackControlsRow.FastForwardAction) getPrimaryActionsAdapter()
            .lookup(ACTION_FAST_FORWARD);

    mRewindAction = (PlaybackControlsRow.RewindAction) getPrimaryActionsAdapter()
            .lookup(ACTION_REWIND);

    presenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            dispatchAction(action);
        }
    });
    return presenter;
}
项目:aos-Video    文件:VideoActionAdapter.java   
public void updateToNonIndexed(Context context) {
    clear(ACTION_RESUME);
    clear(ACTION_LOCAL_RESUME);
    set(ACTION_PLAY_FROM_BEGIN, new Action(ACTION_PLAY_FROM_BEGIN, context.getString(R.string.play_selection)));
    clear(ACTION_NEXT_EPISODE);
    clear(ACTION_MARK_AS_WATCHED);
    clear(ACTION_MARK_AS_NOT_WATCHED);
    clear(ACTION_UNINDEX);
    clear(ACTION_SCRAP);
    clear(ACTION_UNSCRAP);
    clear(ACTION_HIDE);
    clear(ACTION_UNHIDE);
    clear(ACTION_ADD_TO_LIST);

    set(ACTION_INDEX, new Action(ACTION_INDEX, context.getString(R.string.video_browser_index_file)));
}
项目:chilly    文件:PlaybackControlHelper.java   
@TargetApi(VERSION_CODES.N)
public void dispatchAction(Action action) {
    if (action instanceof PlaybackControlsRow.MultiAction) {
        PlaybackControlsRow.MultiAction multiAction = (PlaybackControlsRow.MultiAction) action;
        multiAction.nextIndex();
        notifyActionChanged(multiAction);
    }

    if (action == mFastForwardAction) {
        mTransportControls.fastForward();
    } else if (action == mRewindAction) {
        mTransportControls.rewind();
    } else if (action.getId() == mPipAction.getId()) {
        ((Activity) getContext()).enterPictureInPictureMode();
    } else {
        super.onActionClicked(action);
    }
}
项目:cleaninsights-android-sdk    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:eanalytics-android    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:android_packages_apps_tv    文件:SeriesRecordingDetailsFragment.java   
private void updateWatchAction() {
    List<RecordedProgram> programs = mDvrDataManager.getRecordedPrograms(mSeries.getId());
    Collections.sort(programs, RecordedProgram.EPISODE_COMPARATOR);
    mRecommendRecordedProgram = getRecommendProgram(programs);
    if (mRecommendRecordedProgram == null) {
        mActionsAdapter.clear(ACTION_WATCH);
    } else {
        String episodeStatus;
        if(mDvrWatchedPositionManager.getWatchedStatus(mRecommendRecordedProgram)
                == DvrWatchedPositionManager.DVR_WATCHED_STATUS_WATCHING) {
            episodeStatus = mResumeLabel;
            mInitialPlaybackPositionMs = mDvrWatchedPositionManager
                    .getWatchedPosition(mRecommendRecordedProgram.getId());
        } else {
            episodeStatus = mWatchLabel;
            mInitialPlaybackPositionMs = TvInputManager.TIME_SHIFT_INVALID_TIME;
        }
        String episodeDisplayNumber = mRecommendRecordedProgram.getEpisodeDisplayNumber(
                getContext());
        mActionsAdapter.set(ACTION_WATCH, new Action(ACTION_WATCH,
                episodeStatus, episodeDisplayNumber, mWatchDrawable));
    }
}
项目: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_packages_apps_tv    文件:RecordedProgramDetailsFragment.java   
@Override
protected OnActionClickedListener onCreateOnActionClickedListener() {
    return new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_PLAY_FROM_BEGINNING) {
                startPlayback(mRecordedProgram, TvInputManager.TIME_SHIFT_INVALID_TIME);
            } else if (action.getId() == ACTION_RESUME_PLAYING) {
                startPlayback(mRecordedProgram, mDvrWatchedPositionManager
                        .getWatchedPosition(mRecordedProgram.getId()));
            } else if (action.getId() == ACTION_DELETE_RECORDING) {
                DvrManager dvrManager = TvApplication
                        .getSingletons(getActivity()).getDvrManager();
                dvrManager.removeRecordedProgram(mRecordedProgram);
                getActivity().finish();
            }
        }
    };
}
项目:Android-High-Performance-Programming    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:Android-High-Performance-Programming    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:Android-High-Performance-Programming    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:Android-High-Performance-Programming    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:popcorn-android    文件:PTVPlaybackOverlayFragment.java   
@Override
public void onActionClicked(@NonNull Action action) {
    if (action.getId() == mPlayPauseAction.getId()) {
        invokeTogglePlaybackAction(mPlayPauseAction.getIndex() == PlayPauseAction.PLAY);
    }
    else if (action.getId() == mScaleVideoAction.getId()) {
        invokeScaleVideoAction();
    }
    else if (action.getId() == mClosedCaptioningAction.getId()) {
        invokeOpenSubtitleSettingsAction();
    }
    if (mSkipPreviousAction != null && action.getId() == mSkipPreviousAction.getId()) {
        playSelectedEpisode(mPreviousEpisode);
    }
    if (mSkipNextAction != null && action.getId() == mSkipNextAction.getId()) {
        playSelectedEpisode(mNextEpisode);
    }

    if (action instanceof PlaybackControlsRow.MultiAction) {
        notifyPlaybackControlActionChanged(action);
    }
}
项目:Mediathek    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:leanback-showcase    文件:DetailViewExampleWithVideoBackgroundFragment.java   
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                          RowPresenter.ViewHolder rowViewHolder, Row row) {
    if (!(item instanceof Action)) return;
    Action action = (Action) item;
    long id = action.getId();

    if (id == ACTION_RENT) {
        startWizardActivityForPayment();
    } else if (action.getId() == ACTION_PLAY) {
        playMainVideoOnBackground();
    } else if (action.getId() == ACTION_RELATED) {
        setSelectedPosition(1);
    } else {
        Toast.makeText(getActivity(), getString(R.string.action_cicked), Toast.LENGTH_LONG)
                .show();
    }
}
项目:danish-media-license    文件:PlaybackFragment.java   
private void initUi() {
  PlaybackControlsRowPresenter presenter = mediaControllerHelper.createControlsRowAndPresenter();
  rows = new ArrayObjectAdapter(presenter);
  rows.add(mediaControllerHelper.getControlsRow());
  setAdapter(rows);
  setOnItemViewClickedListener(new OnItemViewClickedListener() {

    @Override
    public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                              RowPresenter.ViewHolder rowViewHolder, Row row) {
      if (item instanceof Action) {
        mediaControllerHelper.onActionClicked((Action) item);
      }
    }
  });
}
项目:tldrlegal    文件:VideoDetailsFragment.java   
@Override
protected DetailsOverviewRow doInBackground(Movie... movies) {
    mSelectedMovie = movies[0];

    DetailsOverviewRow row = new DetailsOverviewRow(mSelectedMovie);
    try {
        Bitmap poster = Picasso.with(getActivity())
                               .load(mSelectedMovie.getCardImageUrl())
                               .resize(Utils.convertDpToPixel(getActivity().getApplicationContext(),
                                               DETAIL_THUMB_WIDTH),
                                       Utils.convertDpToPixel(getActivity().getApplicationContext(),
                                               DETAIL_THUMB_HEIGHT))
                               .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;
}
项目: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;
}
项目:Mizuu-Android-TV    文件:VideoDetailsFragment.java   
@Override
protected DetailsOverviewRow doInBackground(Movie... movies) {
    mSelectedMovie = movies[0];

    DetailsOverviewRow row = new DetailsOverviewRow(mSelectedMovie);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(mSelectedMovie.getCardImageUrl())
                .resize(Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_WIDTH),
                        Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_HEIGHT))
                .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;
}
项目:spotify-tv    文件:NowPlayingFragment.java   
@Override
protected boolean onActionClicked(Action action) {
    if (super.onActionClicked(action)) {
        return true;
    }
    if (action.getId() == ACTION_VIEW_ARTIST) {
        ArtistSimple artist = null;

        TrackSimple track = (TrackSimple) getObject();
        if (track.artists.size() > 0) {
            artist = track.artists.get(0);
        }

        if (artist != null) {
            ArtistsAlbumsActivity.launch(getActivity(), artist.id, artist.name);
        }
        return true;
    }

    return false;
}
项目:spotify-tv    文件:AlbumDetailsFragment.java   
@Override
protected boolean onActionClicked(Action action) {
    if (super.onActionClicked(action)) {
        return true;
    }
    if (action.getId() == ACTION_VIEW_ARTIST) {
        ArtistSimple artist = null;

        if (mAlbum.artists.size() > 0) {
            artist = mAlbum.artists.get(0);
        }

        if (artist != null) {
            ArtistsAlbumsActivity.launch(getActivity(), artist.id, artist.name);
        }
        return true;
    }
    return false;
}
项目:birudo    文件:VideoDetailsFragment.java   
@Override
protected DetailsOverviewRow doInBackground(Movie... movies) {
    mSelectedMovie = movies[0];

    DetailsOverviewRow row = new DetailsOverviewRow(mSelectedMovie);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(mSelectedMovie.getCardImageUrl())
                .resize(Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_WIDTH),
                        Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_HEIGHT))
                .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;
}
项目:androidtv-Leanback    文件:VideoPlayerGlue.java   
private void dispatchAction(Action action) {
    // Primary actions are handled manually.
    if (action == mRewindAction) {
        rewind();
    } else if (action == mFastForwardAction) {
        fastForward();
    } else if (action instanceof PlaybackControlsRow.MultiAction) {
        PlaybackControlsRow.MultiAction multiAction = (PlaybackControlsRow.MultiAction) action;
        multiAction.nextIndex();
        // Notify adapter of action changes to handle secondary actions, such as, thumbs up/down
        // and repeat.
        notifyActionChanged(
                multiAction,
                (ArrayObjectAdapter) getControlsRow().getSecondaryActionsAdapter());
    }
}
项目:TickTank_old    文件:AboutDetailsFragment.java   
private ArrayObjectAdapter buildAboutAdapter() {
    DetailsOverviewRowPresenter rowPresenter = new DetailsOverviewRowPresenter(new AboutDetailsDescriptionPresenter());
    rowPresenter.setBackgroundColor(getResources().getColor(R.color.about_background));
    rowPresenter.setOnActionClickedListener(new OnActionClickedListener() {

        @Override
        public void onActionClicked(Action action) {}
    });

    ClassPresenterSelector selector = new ClassPresenterSelector();
    selector.addClassPresenter(DetailsOverviewRow.class, rowPresenter);
    selector.addClassPresenter(ListRow.class, new ListRowPresenter());

    ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(selector);

    rowsAdapter.add(generateAboutMeRow());
    rowsAdapter.add(generateAboutGDGRow());

    return rowsAdapter;
}
项目:adaptive-arp-android    文件:VideoDetailsFragment.java   
@Override
protected DetailsOverviewRow doInBackground(Movie... movies) {
    mSelectedMovie = movies[0];

    DetailsOverviewRow row = new DetailsOverviewRow(mSelectedMovie);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(mSelectedMovie.getCardImageUrl())
                .resize(Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_WIDTH),
                        Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_HEIGHT))
                .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;
}
项目:BuildingForAndroidTV    文件:TVVideoDetailsFragment.java   
@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;
}
项目:BuildingForAndroidTV    文件:TVVideoDetailsFragment.java   
@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;
}
项目:BuildingForAndroidTV    文件:TVVideoDetailsFragment.java   
@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;
}
项目:BuildingForAndroidTV    文件:MovieDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            MovieDetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackActivity.class);
                intent.putExtra(MovieDetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:HelloTV    文件:PlaybackOverlayFragment.java   
private void notifyChanged(Action action) {
    ArrayObjectAdapter adapter = mPrimaryActionsAdapter;
    if (adapter.indexOf(action) >= 0) {
        adapter.notifyArrayItemRangeChanged(adapter.indexOf(action), 1);
        return;
    }
    adapter = mSecondaryActionsAdapter;
    if (adapter.indexOf(action) >= 0) {
        adapter.notifyArrayItemRangeChanged(adapter.indexOf(action), 1);
        return;
    }
}