本文整理匯總了Java中android.support.v17.leanback.widget.Action類的典型用法代碼示例。如果您正苦於以下問題:Java Action類的具體用法?Java Action怎麽用?Java Action使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Action類屬於android.support.v17.leanback.widget包,在下文中一共展示了Action類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupDetailsOverviewRowPresenter
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
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);
}
示例2: createControlsRowAndPresenter
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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;
}
示例3: dispatchAction
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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);
}
}
示例4: getRecordingActionsAdapter
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
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;
}
示例5: updateToNonIndexed
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
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)));
}
示例6: updateWatchAction
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
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));
}
}
示例7: onCreateActionsAdapter
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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;
}
示例8: onCreateActionsAdapter
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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;
}
示例9: onCreateActionsAdapter
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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;
}
示例10: onCreateOnActionClickedListener
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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();
}
}
};
}
示例11: onActionClicked
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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);
}
}
示例12: onItemClicked
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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();
}
}
開發者ID:googlesamples,項目名稱:leanback-showcase,代碼行數:19,代碼來源:DetailViewExampleWithVideoBackgroundFragment.java
示例13: initUi
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
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);
}
}
});
}
示例14: doInBackground
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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;
}
示例15: doInBackground
import android.support.v17.leanback.widget.Action; //導入依賴的package包/類
@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;
}