Java Code Examples for android.support.v17.leanback.widget.FullWidthDetailsOverviewRowPresenter#setInitialState()

The following examples show how to use android.support.v17.leanback.widget.FullWidthDetailsOverviewRowPresenter#setInitialState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoDetailsFragment.java    From leanback-assistant with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 2
Source File: VideoDetailsFragment.java    From android-tv-leanback with Apache License 2.0 4 votes vote down vote up
@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>

}
 
Example 3
Source File: VideoDetailsFragment.java    From android-tv-leanback with Apache License 2.0 4 votes vote down vote up
@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>
}
 
Example 4
Source File: VideoDetailsFragment.java    From android-tv-leanback with Apache License 2.0 4 votes vote down vote up
@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>

}
 
Example 5
Source File: VideoDetailsFragment.java    From android-tv-leanback with Apache License 2.0 4 votes vote down vote up
@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>
}