Java Code Examples for android.support.v17.leanback.widget.DetailsOverviewRowPresenter#setSharedElementEnterTransition()

The following examples show how to use android.support.v17.leanback.widget.DetailsOverviewRowPresenter#setSharedElementEnterTransition() . 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: MovieDetailsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
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);
}
 
Example 2
Source File: AppDetailsFragment.java    From TvAppRepo with Apache License 2.0 5 votes vote down vote up
private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getActivity()));
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(getActivity(),
            DetailsActivity.SHARED_ELEMENT_NAME);
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
}
 
Example 3
Source File: VideoDetailsFragment.java    From CumulusTV with MIT License 4 votes vote down vote up
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);
}
 
Example 4
Source File: RichAppLinkDetailsFragment.java    From androidtv-sample-inputs with Apache License 2.0 4 votes vote down vote up
@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.your_company);
    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(ContextCompat.getColor(getActivity(),
            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);
}