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

项目: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);
}
项目: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;
}
项目: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    文件: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);
}
项目: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    文件:LiveDataDetailFragmentUiModule.java   
@Provides
@PerFragment
public FullWidthDetailsOverviewSharedElementHelper provideHelper(Activity activity,
        PresenterSelector mPs, DetailsOverviewRow row, OnActionClickedListener listener) {
    FullWidthDetailsOverviewSharedElementHelper mHelper =
            new FullWidthDetailsOverviewSharedElementHelper();
    mHelper.setSharedElementEnterTransition(activity,
            LiveDataDetailActivity.SHARED_ELEMENT_NAME);

    ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row))
            .setListener(mHelper);
    ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row))
            .setParticipatingEntranceTransition(false);
    ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row))
            .setOnActionClickedListener(listener);
    return mHelper;

}
项目: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;
}
项目: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);
}
项目:garras    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRowPresenter() {
    // Set detail background.
    FullWidthDetailsOverviewRowPresenter detailsPresenter =
            new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(
            ContextCompat.getColor(getActivity(), R.color.selected_background));

    // Hook up transition element.
    FullWidthDetailsOverviewSharedElementHelper sharedElementHelper =
            new FullWidthDetailsOverviewSharedElementHelper();
    sharedElementHelper.setSharedElementEnterTransition(
            getActivity(), DetailsActivity.SHARED_ELEMENT_NAME);
    detailsPresenter.setListener(sharedElementHelper);
    detailsPresenter.setParticipatingEntranceTransition(true);

    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(DetailsActivity.MOVIE, mSelectedMovie);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:androidtv-sample    文件:PlaybackControlHelper.java   
@Override
public PlaybackControlsRowPresenter createControlsRowAndPresenter() {
    PlaybackControlsRowPresenter presenter = super.createControlsRowAndPresenter();

    ArrayObjectAdapter adapter = new ArrayObjectAdapter(new ControlButtonPresenterSelector());
    getControlsRow().setSecondaryActionsAdapter(adapter);

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

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

    // odebrani zbytecnych tlacitek
    /*
    adapter.add(mThumbsDownAction);
    adapter.add(mRepeatAction);
    adapter.add(mThumbsUpAction);
    */
    if (PlaybackOverlayActivity.supportsPictureInPicture(getContext())) {
        adapter.add(mPipAction);
    }

    presenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            dispatchAction(action);
        }
    });

    return presenter;
}
项目:androidtv-sample    文件:VideoDetailsFragment.java   
private void setupAdapter() {
    // Set detail background and style.
    FullWidthDetailsOverviewRowPresenter detailsPresenter =
            new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(),
                    new MovieDetailsOverviewLogoPresenter());

    detailsPresenter.setBackgroundColor(
            ContextCompat.getColor(getActivity(), R.color.selected_background));
    detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF);

    // Hook up transition element.
    mHelper = new FullWidthDetailsOverviewSharedElementHelper();
    mHelper.setSharedElementEnterTransition(getActivity(),
            VideoDetailsActivity.SHARED_ELEMENT_NAME);
    detailsPresenter.setListener(mHelper);
    detailsPresenter.setParticipatingEntranceTransition(false);
    prepareEntranceTransition();

    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(VideoDetailsActivity.VIDEO, mSelectedVideo);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    mPresenterSelector = new ClassPresenterSelector();
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
    mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
    mAdapter = new ArrayObjectAdapter(mPresenterSelector);
    setAdapter(mAdapter);
}
项目:chilly    文件:PlaybackControlHelper.java   
@Override
public PlaybackControlsRowPresenter createControlsRowAndPresenter() {
    PlaybackControlsRowPresenter presenter = super.createControlsRowAndPresenter();

    ArrayObjectAdapter adapter = new ArrayObjectAdapter(new ControlButtonPresenterSelector());
    getControlsRow().setSecondaryActionsAdapter(adapter);

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

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

    adapter.add(mThumbsDownAction);
    adapter.add(mRepeatAction);
    adapter.add(mThumbsUpAction);
    if (PlaybackOverlayActivity.supportsPictureInPicture(getContext())) {
        adapter.add(mPipAction);
    }

    presenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            dispatchAction(action);
        }
    });

    return presenter;
}
项目:leanback-assistant    文件:VideoDetailsFragment.java   
private void setupAdapter() {
    FullWidthDetailsOverviewRowPresenter detailsPresenter =
            new FullWidthDetailsOverviewRowPresenter(
                    new DetailsDescriptionPresenter(), new MovieDetailsOverviewLogoPresenter());

    detailsPresenter.setBackgroundColor(
            ContextCompat.getColor(getContext(), R.color.background_dark));
    detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF);

    detailsPresenter.setOnActionClickedListener(
            new OnActionClickedListener() {
                @Override
                public void onActionClicked(Action action) {
                    if (action.getId() == ACTION_WATCH) {
                        Intent intent =
                                PlaybackActivity.createIntent(getContext(), mMovie.getId());
                        startActivity(intent);
                    } else {
                        Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT)
                                .show();
                    }
                }
            });

    ClassPresenterSelector mPresenterSelector = new ClassPresenterSelector();
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
    mAdapter = new ArrayObjectAdapter(mPresenterSelector);
    setAdapter(mAdapter);
}
项目:android_packages_apps_tv    文件:SeriesRecordingDetailsFragment.java   
@Override
protected OnActionClickedListener onCreateOnActionClickedListener() {
    return new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH) {
                startPlayback(mRecommendRecordedProgram, mInitialPlaybackPositionMs);
            } else if (action.getId() == ACTION_SERIES_SCHEDULES) {
                DvrUiHelper.startSchedulesActivityForSeries(getContext(), mSeries);
            } else if (action.getId() == ACTION_DELETE) {
                DvrUiHelper.startSeriesDeletionActivity(getContext(), mSeries.getId());
            }
        }
    };
}
项目:android_packages_apps_tv    文件:ScheduledRecordingDetailsFragment.java   
@Override
protected OnActionClickedListener onCreateOnActionClickedListener() {
    return new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            long actionId = action.getId();
            if (actionId == ACTION_VIEW_SCHEDULE) {
                DvrUiHelper.startSchedulesActivity(getContext(), getRecording());
            } else if (actionId == ACTION_CANCEL) {
                mDvrManager.removeScheduledRecording(getRecording());
                getActivity().finish();
            }
        }
    };
}
项目:android_packages_apps_tv    文件:CurrentRecordingDetailsFragment.java   
@Override
protected OnActionClickedListener onCreateOnActionClickedListener() {
    return new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_STOP_RECORDING) {
                DvrManager dvrManager = TvApplication.getSingletons(getActivity())
                        .getDvrManager();
                dvrManager.stopRecording(getRecording());
            }
            getActivity().finish();
        }
    };
}
项目:Mizuu-Android-TV    文件:VideoDetailsFragment.java   
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();
    // set detail background and style
    mDorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background));
    mDorPresenter.setStyleLarge(true);
    mDorPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {

            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    ps.addClassPresenter(DetailsOverviewRow.class, mDorPresenter);
    ps.addClassPresenter(ListRow.class,
            new ListRowPresenter());

    ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
    adapter.add(detailRow);

    String subcategories[] = {
            getString(R.string.related_movies)
    };
    List<Movie> list = MovieList.list;
    Collections.shuffle(list);
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
    for (int j = 0; j < NUM_COLS; j++) {
        listRowAdapter.add(list.get(j % 5));
    }

    HeaderItem header = new HeaderItem(0, subcategories[0]);
    adapter.add(new ListRow(header, listRowAdapter));

    setAdapter(adapter);
}
项目:spotify-tv    文件:TracksDetailsFragment.java   
private void setupFragment() {
    mDetailsPresenter = new DetailsOverviewRowPresenter(getDetailsPresenter());
    mDetailsPresenter.setStyleLarge(false);

    ClassPresenterSelector ps = new ClassPresenterSelector();
    ps.addClassPresenter(DetailsOverviewRow.class, mDetailsPresenter);
    ps.addClassPresenter(TracksHeaderRow.class, new TracksHeaderRowPresenter());

    OnItemViewClickedListener onTrackRowItemClicked = new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            if (item instanceof TrackSimple) {
                playFromTrack(((TrackSimple) item));
            }
        }
    };

    ps.addClassPresenter(TrackRow.class, getTrackRowPresenter(onTrackRowItemClicked));

    mRowsAdapter = new ArrayObjectAdapter(ps);

    setAdapter(mRowsAdapter);

    setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            TracksDetailsFragment.this.onActionClicked(action);
        }
    });
}
项目:AndroidDemoProjects    文件:VideoDetailsFragment.java   
@Override
protected void onPostExecute( DetailsOverviewRow detailRow ) {
    if( detailRow == null )
        return;

    ClassPresenterSelector ps = new ClassPresenterSelector();
    DetailsOverviewRowPresenter dorPresenter =
            new DetailsOverviewRowPresenter( new DetailsDescriptionPresenter() );
    // set detail background and style
    dorPresenter.setBackgroundColor( getResources().getColor( R.color.detail_background ) );
    dorPresenter.setStyleLarge( true );
    dorPresenter.setOnActionClickedListener( new OnActionClickedListener() {
        @Override
        public void onActionClicked( Action action ) {
            if (action.getId() == ACTION_WATCH ) {
                Intent intent = new Intent( getActivity(), PlayerActivity.class );
                intent.putExtra( EXTRA_MOVIE, mSelectedMovie );
                intent.putExtra( EXTRA_SHOULD_AUTO_START, true );
                startActivity( intent );
            }
        }
    });

    ps.addClassPresenter( DetailsOverviewRow.class, dorPresenter );
    ps.addClassPresenter( ListRow.class,
            new ListRowPresenter() );


    ArrayObjectAdapter adapter = new ArrayObjectAdapter( ps );
    adapter.add( detailRow );
    loadRelatedMedia( adapter );
    setAdapter( adapter );
}
项目:androidtv-Leanback    文件:VideoDetailsFragment.java   
private void setupAdapter() {
    // Set detail background and style.
    FullWidthDetailsOverviewRowPresenter detailsPresenter =
            new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(),
                    new MovieDetailsOverviewLogoPresenter());

    detailsPresenter.setBackgroundColor(
            ContextCompat.getColor(getActivity(), R.color.selected_background));
    detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF);

    // Hook up transition element.
    mHelper = new FullWidthDetailsOverviewSharedElementHelper();
    mHelper.setSharedElementEnterTransition(getActivity(),
            VideoDetailsActivity.SHARED_ELEMENT_NAME);
    detailsPresenter.setListener(mHelper);
    detailsPresenter.setParticipatingEntranceTransition(false);
    prepareEntranceTransition();

    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(VideoDetailsActivity.VIDEO, mSelectedVideo);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    mPresenterSelector = new ClassPresenterSelector();
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
    mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
    mAdapter = new ArrayObjectAdapter(mPresenterSelector);
    setAdapter(mAdapter);
}
项目:Amphitheatre    文件:DetailRowBuilderTask.java   
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();
    DetailsOverviewRowPresenter dorPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter(mActivity));

    dorPresenter.setBackgroundColor(mActivity.getResources().getColor(R.color.fastlane_background));
    dorPresenter.setStyleLarge(true);
    dorPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_PLAY) {
                VideoUtils.playVideo(new WeakReference<Activity>(mActivity), mVideo);
            }
            else if (action.getId() == ACTION_VIEW_TRAILER) {
                Uri trailerUri = Uri.parse(mVideo.getMovie().getTrailer());
                mActivity.startActivity(new Intent(Intent.ACTION_VIEW, trailerUri));
            }
            else {
                Toast.makeText(mActivity, action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    ps.addClassPresenter(DetailsOverviewRow.class, dorPresenter);
    ps.addClassPresenter(ListRow.class, new ListRowPresenter());

    ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
    adapter.add(detailRow);

    addGroups(adapter);

    if (mRowBuilderTaskListener != null) {
        mRowBuilderTaskListener.taskCompleted(adapter);
    }
}
项目:androidtv-sample    文件:RichAppLinkDetailsFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final String displayNumber = getActivity().getIntent().getStringExtra(
            RichFeedUtil.EXTRA_DISPLAY_NUMBER);

    DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter(
            new DetailsDescriptionPresenter());
    dorPresenter.setSharedElementEnterTransition(getActivity(), "RichAppLinkDetailsFragment");

    DetailsOverviewRow row = new DetailsOverviewRow(displayNumber);
    Resources res = getResources();
    Bitmap bitmap = BitmapFactory.decodeResource(res, R.drawable.nejnettv);
    int length = Math.min(bitmap.getWidth(), bitmap.getHeight());
    Bitmap croppedBitmap = Bitmap.createBitmap(bitmap,
            (bitmap.getWidth() - length) / 2,
            (bitmap.getHeight() - length) / 2,
            length, length);
    row.setImageBitmap(getActivity(), croppedBitmap);

    Action action1 = new Action(0, res.getString(R.string.details_fragment_action_1));
    Action action2 = new Action(1, res.getString(R.string.details_fragment_action_2));
    row.addAction(action1);
    row.addAction(action2);

    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    dorPresenter.setBackgroundColor(res.getColor(R.color.detail_background));
    dorPresenter.setStyleLarge(true);

    dorPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            getActivity().finish();
        }
    });

    presenterSelector.addClassPresenter(DetailsOverviewRow.class, dorPresenter);
    presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
    ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector);
    adapter.add(row);

    setAdapter(adapter);
}
项目:androidtv-sample    文件:RichSetupFragment.java   
private void initUIs(Bitmap bitmap) {
    DetailsOverviewRowPresenter dorPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    dorPresenter.setSharedElementEnterTransition(getActivity(), "SetUpFragment");

    mAddChannelAction = new Action(ACTION_ADD_CHANNELS,
            getResources().getString(R.string.rich_setup_add_channel));
    Action cancelAction = new Action(ACTION_CANCEL,
            getResources().getString(R.string.rich_setup_cancel));
    mInProgressAction = new Action(ACTION_IN_PROGRESS,
            getResources().getString(R.string.rich_setup_in_progress));

    DetailsOverviewRow row = new DetailsOverviewRow(mTvListing);
    if (bitmap != null) {
        int length = Math.min(bitmap.getWidth(), bitmap.getHeight());
        Bitmap croppedBitmap = Bitmap.createBitmap(bitmap,
                (bitmap.getWidth() - length) / 2,
                (bitmap.getHeight() - length) / 2,
                length, length);
        row.setImageBitmap(getActivity(), croppedBitmap);
    }
    row.addAction(mAddChannelAction);
    row.addAction(cancelAction);

    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    // set detail background and style
    dorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background));
    dorPresenter.setStyleLarge(true);

    dorPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_ADD_CHANNELS) {
                setupChannels(mInputId);
            } else if (action.getId() == ACTION_CANCEL) {
                getActivity().finish();
            }
        }
    });

    presenterSelector.addClassPresenter(DetailsOverviewRow.class, dorPresenter);
    presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
    mAdapter = new ArrayObjectAdapter(presenterSelector);
    mAdapter.add(row);

    setAdapter(mAdapter);

    BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity());
    backgroundManager.attach(getActivity().getWindow());
    if (bitmap != null) {
        backgroundManager.setBitmap(bitmap);
    } else {
        backgroundManager.setDrawable(
                getActivity().getDrawable(R.drawable.default_background));
    }
}
项目:leanback-showcase    文件:LiveDataDetailFragmentSubComponent.java   
@BindsInstance
Builder actionClickedListener(OnActionClickedListener listener);
项目:tldrlegal    文件:VideoDetailsFragment.java   
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();
    // set detail background and style
    mDorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background));
    mDorPresenter.setStyleLarge(true);
    mDorPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(getResources().getString(R.string.movie), mSelectedMovie);
                intent.putExtra(getResources().getString(R.string.should_start), true);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    ps.addClassPresenter(DetailsOverviewRow.class, mDorPresenter);
    ps.addClassPresenter(ListRow.class,
            new ListRowPresenter());

    ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
    adapter.add(detailRow);

    String subcategories[] = {
            getString(R.string.related_movies)
    };
    List<Movie> list = MovieList.list;
    Collections.shuffle(list);
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
    for (int j = 0; j < NUM_COLS; j++) {
        listRowAdapter.add(list.get(j % 5));
    }

    HeaderItem header = new HeaderItem(0, subcategories[0]);
    adapter.add(new ListRow(header, listRowAdapter));

    setAdapter(adapter);
}
项目:android-tv-leanback    文件:VideoDetailsFragment.java   
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();

    FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext()));
    detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary));
    detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_PLAY) {
                Intent intent = new Intent(getActivity(), PlayerActivity.class);
                intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
    ps.addClassPresenter(ListRow.class, new ListRowPresenter());

    /** bonus code for adding related items to details fragment **/
    // <START>
    ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
    adapter.add(detailRow);

    String subcategories[] = {
            "You may also like"
    };

    CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter()));
    VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter);
    manager.startDataLoading();
    HeaderItem header = new HeaderItem(0, subcategories[0]);
    adapter.add(new ListRow(header, rowAdapter));
    setAdapter(adapter);
    // <END>

}
项目:android-tv-leanback    文件:VideoDetailsFragment.java   
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();

    FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext()));
    detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary));
    detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_PLAY) {
                Intent intent = new Intent(getActivity(), PlayerActivity.class);
                intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
    ps.addClassPresenter(ListRow.class, new ListRowPresenter());

    /** bonus code for adding related items to details fragment **/
    // <START>
    ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
    adapter.add(detailRow);

    String subcategories[] = {
            "You may also like"
    };

    CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter()));
    VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter);
    manager.startDataLoading();
    HeaderItem header = new HeaderItem(0, subcategories[0]);
    adapter.add(new ListRow(header, rowAdapter));
    setAdapter(adapter);
    // <END>
}
项目:android-tv-leanback    文件:VideoDetailsFragment.java   
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();

    FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext()));
    detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary));
    detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_PLAY) {
                Intent intent = new Intent(getActivity(), PlayerActivity.class);
                intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
    ps.addClassPresenter(ListRow.class,
            new ListRowPresenter());

    /** bonus code for adding related items to details fragment **/
    // <START>
    ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
    adapter.add(detailRow);

    String subcategories[] = {
            "You may also like"
    };

    CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter()));
    VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter);
    manager.startDataLoading();
    HeaderItem header = new HeaderItem(0, subcategories[0]);
    adapter.add(new ListRow(header, rowAdapter));
    setAdapter(adapter);
    // <END>

}
项目:android-tv-leanback    文件:VideoDetailsFragment.java   
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();

    FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext()));
    detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary));
    detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL);

    detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_PLAY) {
                Intent intent = new Intent(getActivity(), PlayerActivity.class);
                intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
    ps.addClassPresenter(ListRow.class,
            new ListRowPresenter());

    /** bonus code for adding related items to details fragment **/
    // <START>
    ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
    adapter.add(detailRow);

    String subcategories[] = {
            "You may also like"
    };

    CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter()));
    VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter);
    manager.startDataLoading();
    HeaderItem header = new HeaderItem(0, subcategories[0]);
    adapter.add(new ListRow(header, rowAdapter));
    setAdapter(adapter);
    // <END>
}
项目:spotify-tv    文件:TracksDetailsFragment.java   
protected void setOnActionClickedListener(OnActionClickedListener listener) {
    mDetailsPresenter.setOnActionClickedListener(listener);
}
项目:MediaBrowser.AndroidTv    文件:BaseItemDetailsFragment.java   
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();
    // set detail background and style
    mDorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background));
    mDorPresenter.setStyleLarge(true);
    mDorPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            Long id = action.getId();
            switch (id.intValue()) {
                case ACTION_PLAY:
                    play(mBaseItem, 0, false);
                    break;
                case ACTION_RESUME:
                    Long pos = mBaseItem.getUserData().getPlaybackPositionTicks() / 10000;
                    play(mBaseItem, pos.intValue(), false);
                    break;
                case ACTION_SHUFFLE:
                    play(mBaseItem, 0, true);
                    break;
                case ACTION_RECORD:
                    recordProgram(mProgramInfo);
                    break;
                case ACTION_CANCEL_RECORD:
                    cancelRecording(mProgramInfo);
                    break;
                case ACTION_DETAILS:
                    Intent intent = new Intent(mActivity, FullDetailsActivity.class);
                    intent.putExtra("BaseItem", TvApp.getApplication().getSerializer().SerializeToString(mBaseItem));
                    mActivity.startActivity(intent);
                    break;
                default:
                    Toast.makeText(getActivity(), action.toString() + " not implemented", Toast.LENGTH_SHORT).show();
                    break;
            }
        }
    });

    ps.addClassPresenter(DetailsOverviewRow.class, mDorPresenter);
    ps.addClassPresenter(ListRow.class,
            new ListRowPresenter());

    final ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
    adapter.add(detailRow);

    setAdapter(adapter);

    addAdditionalRows(adapter);
}
项目:CumulusTV    文件: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_EDIT) {
                ActivityUtils.editChannel(getActivity(), jsonChannel.getMediaUrl());
            } else if(action.getId() == ACTION_WATCH) {
                Log.d(TAG, ChannelDatabase.getInstance(getActivity()).getHashMap().toString());
                if (ChannelDatabase.getInstance(getActivity()).getHashMap()
                        .containsKey(jsonChannel.getMediaUrl())) {
                    // Open in Live Channels
                    Uri liveChannelsUri =
                            TvContract.buildChannelUri(
                                    ChannelDatabase.getInstance(
                                            getActivity()).getHashMap()
                                            .get(jsonChannel.getMediaUrl()));
                    getActivity().startActivity(
                            new Intent(Intent.ACTION_VIEW, liveChannelsUri));
                } else {
                    ActivityUtils.openStream(getActivity(), jsonChannel.getMediaUrl());
                }
            } else if(action.getId() == ACTION_ADD) {
                Log.d(TAG, "Adding " + jsonChannel.toString());
                ActivityUtils
                        .addChannel(getActivity(), gapi, jsonChannel);
                getActivity().setResult(LeanbackActivity.RESULT_CODE_REFRESH_UI);
                getActivity().finish();
            }
        }
    });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
项目:birudo    文件:VideoDetailsFragment.java   
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();
    // set detail background and style
    mDorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background));
    mDorPresenter.setStyleLarge(true);
    mDorPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
                intent.putExtra(getResources().getString(R.string.movie), mSelectedMovie);
                intent.putExtra(getResources().getString(R.string.should_start), true);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    ps.addClassPresenter(DetailsOverviewRow.class, mDorPresenter);
    ps.addClassPresenter(ListRow.class,
            new ListRowPresenter());

    ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
    adapter.add(detailRow);

    String subcategories[] = {
            getString(R.string.related_movies)
    };
    List<Movie> list = MovieList.list;
    Collections.shuffle(list);
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
    for (int j = 0; j < NUM_COLS; j++) {
        listRowAdapter.add(list.get(j % 5));
    }

    HeaderItem header = new HeaderItem(0, subcategories[0], null);
    adapter.add(new ListRow(header, listRowAdapter));

    setAdapter(adapter);
}