android.support.v17.leanback.widget.OnItemViewClickedListener Java Examples

The following examples show how to use android.support.v17.leanback.widget.OnItemViewClickedListener. 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: PageAndListRowFragment.java    From leanback-showcase with Apache License 2.0 7 votes vote down vote up
private void setupAdapter() {
    VerticalGridPresenter presenter = new VerticalGridPresenter(ZOOM_FACTOR);
    presenter.setNumberOfColumns(COLUMNS);
    setGridPresenter(presenter);

    CardPresenterSelector cardPresenter = new CardPresenterSelector(getActivity());
    mAdapter = new ArrayObjectAdapter(cardPresenter);
    setAdapter(mAdapter);

    setOnItemViewClickedListener(new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(
                Presenter.ViewHolder itemViewHolder,
                Object item,
                RowPresenter.ViewHolder rowViewHolder,
                Row row) {
            Card card = (Card)item;
            Toast.makeText(getActivity(),
                    "Clicked on "+card.getTitle(),
                    Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example #2
Source File: TvSearchFragment.java    From leanback-homescreen-channels with Apache License 2.0 6 votes vote down vote up
private OnItemViewClickedListener getDefaultItemClickedListener() {
    return new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                RowPresenter.ViewHolder rowViewHolder, Row row) {
            if (item instanceof Clip) {
                Toast.makeText(getActivity(), "** toggle selected **",
                        Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(getActivity(), "** add as playlist **",
                        Toast.LENGTH_LONG).show();

            }
        }
    };
}
 
Example #3
Source File: CustomRowsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);

	loadVideoData();
	setCustomPadding();
	setOnItemViewClickedListener(new OnItemViewClickedListener() {
		@Override
		public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
			Movie movie = (Movie) item;
			Intent intent = new Intent(getActivity(), MovieDetailsActivity.class);
			intent.putExtra(MovieDetailsActivity.MOVIE, movie);

			Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
					getActivity(),
					((ImageCardView) itemViewHolder.view).getMainImageView(),
					MovieDetailsActivity.SHARED_ELEMENT_NAME).toBundle();
			getActivity().startActivity(intent, bundle);
		}
	});
}
 
Example #4
Source File: PageAndListRowFragment.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
public SampleFragmentB() {
    mRowsAdapter = new ArrayObjectAdapter(new ShadowRowPresenterSelector());

    setAdapter(mRowsAdapter);
    setOnItemViewClickedListener(new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(
                Presenter.ViewHolder itemViewHolder,
                Object item,
                RowPresenter.ViewHolder rowViewHolder,
                Row row) {
            Toast.makeText(getActivity(), "Implement click handler", Toast.LENGTH_SHORT)
                    .show();
        }
    });
}
 
Example #5
Source File: DetailsFragment.java    From iview-android-tv with MIT License 6 votes vote down vote up
private OnItemViewClickedListener getItemClickedListener() {
    return new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            Log.d(TAG, "Clicked item:" + item);
            if (item instanceof EpisodeBaseModel) {
                EpisodeBaseModel ep = (EpisodeBaseModel) item;
                Intent intent = new Intent(getActivity(), getPlayerActivityClass());
                intent.putExtra(ContentManagerBase.CONTENT_ID, ep);
                String[] others = getOtherEpisodeUrls().toArray(new String[getOtherEpisodeUrls().size()]);
                intent.putExtra(ContentManagerBase.OTHER_EPISODES, others);
                startActivity(intent);
            }
        }
    };
}
 
Example #6
Source File: CardExampleFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
private void setupUi() {
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);
    setTitle(getString(R.string.card_examples_title));
    setOnSearchClickedListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getActivity(), getString(R.string.implement_search),
                    Toast.LENGTH_LONG).show();
        }
    });
    setOnItemViewClickedListener(new OnItemViewClickedListener() {

        @Override
        public void onItemClicked(Presenter.ViewHolder viewHolder, Object item, RowPresenter.ViewHolder viewHolder1, Row row) {
            if (!(item instanceof Card)) return;
            if (!(viewHolder.view instanceof ImageCardView)) return;

            ImageView imageView = ((ImageCardView) viewHolder.view).getMainImageView();
            Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                    imageView, DetailViewExampleFragment.TRANSITION_NAME).toBundle();
            Intent intent = new Intent(getActivity().getBaseContext(),
                    DetailViewExampleActivity.class);
            Card card = (Card) item;
            int imageResId = card.getLocalImageResourceId(getContext());
            intent.putExtra(DetailViewExampleFragment.EXTRA_CARD, imageResId);
            startActivity(intent, bundle);
        }

    });

    prepareEntranceTransition();
}
 
Example #7
Source File: VerticalGridFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item clicked listener.
 */
public void setOnItemViewClickedListener(OnItemViewClickedListener listener) {
    mOnItemViewClickedListener = listener;
    if (mGridPresenter != null) {
        mGridPresenter.setOnItemViewClickedListener(mOnItemViewClickedListener);
    }
}
 
Example #8
Source File: BrowseSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item clicked listener on the fragment.
 * OnItemViewClickedListener will override {@link View.OnClickListener} that
 * item presenter sets during {@link Presenter#onCreateViewHolder(ViewGroup)}.
 * So in general,  developer should choose one of the listeners but not both.
 */
public void setOnItemViewClickedListener(OnItemViewClickedListener listener) {
    mOnItemViewClickedListener = listener;
    if (mRowsSupportFragment != null) {
        mRowsSupportFragment.setOnItemViewClickedListener(listener);
    }
}
 
Example #9
Source File: BrowseFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item clicked listener on the fragment.
 * OnItemViewClickedListener will override {@link View.OnClickListener} that
 * item presenter sets during {@link Presenter#onCreateViewHolder(ViewGroup)}.
 * So in general,  developer should choose one of the listeners but not both.
 */
public void setOnItemViewClickedListener(OnItemViewClickedListener listener) {
    mOnItemViewClickedListener = listener;
    if (mRowsFragment != null) {
        mRowsFragment.setOnItemViewClickedListener(listener);
    }
}
 
Example #10
Source File: RowsFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item clicked listener on the fragment.
 * OnItemViewClickedListener will override {@link View.OnClickListener} that
 * item presenter sets during {@link Presenter#onCreateViewHolder(ViewGroup)}.
 * So in general,  developer should choose one of the listeners but not both.
 */
public void setOnItemViewClickedListener(OnItemViewClickedListener listener) {
    mOnItemViewClickedListener = listener;
    if (mViewsCreated) {
        throw new IllegalStateException(
                "Item clicked listener must be set before views are created");
    }
}
 
Example #11
Source File: DetailsFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item Clicked listener.
 */
public void setOnItemViewClickedListener(OnItemViewClickedListener listener) {
    mOnItemViewClickedListener = listener;
    if (mRowsFragment != null) {
        mRowsFragment.setOnItemViewClickedListener(listener);
    }
}
 
Example #12
Source File: DetailsSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item Clicked listener.
 */
public void setOnItemViewClickedListener(OnItemViewClickedListener listener) {
    mOnItemViewClickedListener = listener;
    if (mRowsSupportFragment != null) {
        mRowsSupportFragment.setOnItemViewClickedListener(listener);
    }
}
 
Example #13
Source File: RowsSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item clicked listener on the fragment.
 * OnItemViewClickedListener will override {@link View.OnClickListener} that
 * item presenter sets during {@link Presenter#onCreateViewHolder(ViewGroup)}.
 * So in general,  developer should choose one of the listeners but not both.
 */
public void setOnItemViewClickedListener(OnItemViewClickedListener listener) {
    mOnItemViewClickedListener = listener;
    if (mViewsCreated) {
        throw new IllegalStateException(
                "Item clicked listener must be set before views are created");
    }
}
 
Example #14
Source File: VerticalGridSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item clicked listener.
 */
public void setOnItemViewClickedListener(OnItemViewClickedListener listener) {
    mOnItemViewClickedListener = listener;
    if (mGridPresenter != null) {
        mGridPresenter.setOnItemViewClickedListener(mOnItemViewClickedListener);
    }
}
 
Example #15
Source File: CategoryFragment.java    From iview-android-tv with MIT License 5 votes vote down vote up
private OnItemViewClickedListener getItemClickedListener() {
    return new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            if (item instanceof EpisodeBaseModel) {
                Intent intent = new Intent(getActivity(), getDetailsActivityClass());
                intent.putExtra(ContentManagerBase.CONTENT_ID, (EpisodeBaseModel) item);
                startActivity(intent);
            }
        }
    };
}
 
Example #16
Source File: SearchFragment.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
protected OnItemViewClickedListener getDefaultItemClickedListener() {
    return new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            if (item instanceof MediaWrapper) {
                TvUtil.openMedia(mActivity, (MediaWrapper) item, row);
            }
        }
    };
}
 
Example #17
Source File: ListenerFactory.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Inject
public ListenerFactory(Map<Class, OnItemViewClickedListener> onItemViewClickedListenerMap,
        Map<Class, OnItemViewSelectedListener> onItemViewSelectedListenerMap,
        Map<Class, View.OnClickListener> viewOnClickListenerMap) {
    mOnItemViewClickedListenerMap = onItemViewClickedListenerMap;
    mOnItemViewSelectedListenerMap = onItemViewSelectedListenerMap;
    mViewOnClickListenerMap = viewOnClickListenerMap;

}
 
Example #18
Source File: GridFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item clicked listener.
 */
public void setOnItemViewClickedListener(OnItemViewClickedListener listener) {
    mOnItemViewClickedListener = listener;
    if (mGridPresenter != null) {
        mGridPresenter.setOnItemViewClickedListener(mOnItemViewClickedListener);
    }
}
 
Example #19
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
protected OnItemViewClickedListener getDefaultItemViewClickedListener() {
    return new OnItemViewClickedListener() {

        @Override
        public void onItemClicked(Presenter.ViewHolder viewHolder, Object o, RowPresenter.ViewHolder viewHolder2, Row row) {

            Intent intent = new Intent(getActivity(), VideoDetailsActivity.class);
            intent.putExtra(Video.INTENT_EXTRA_VIDEO, (Serializable) o);
            startActivity(intent);

        }
    };
}
 
Example #20
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
protected OnItemViewClickedListener getDefaultItemViewClickedListener() {
    return new OnItemViewClickedListener() {

        @Override
        public void onItemClicked(Presenter.ViewHolder viewHolder, Object o, RowPresenter.ViewHolder viewHolder2, Row row) {

            Intent intent = new Intent(getActivity(), VideoDetailsActivity.class);
            intent.putExtra(Video.INTENT_EXTRA_VIDEO, (Serializable) o);
            startActivity(intent);

        }
    };
}
 
Example #21
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
protected OnItemViewClickedListener getDefaultItemViewClickedListener() {
    return new OnItemViewClickedListener() {

        @Override
        public void onItemClicked(Presenter.ViewHolder viewHolder, Object o, RowPresenter.ViewHolder viewHolder2, Row row) {

            Intent intent = new Intent(getActivity(), VideoDetailsActivity.class);
            intent.putExtra(Video.INTENT_EXTRA_VIDEO, (Serializable) o);
            startActivity(intent);

        }
    };
}
 
Example #22
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
protected OnItemViewClickedListener getDefaultItemViewClickedListener() {
    return new OnItemViewClickedListener() {

        @Override
        public void onItemClicked(Presenter.ViewHolder viewHolder, Object o, RowPresenter.ViewHolder viewHolder2, Row row) {

            Intent intent = new Intent(getActivity(), VideoDetailsActivity.class);
            intent.putExtra(Video.INTENT_EXTRA_VIDEO, (Serializable) o);
            startActivity(intent);

        }
    };
}
 
Example #23
Source File: SearchFragment.java    From iview-android-tv with MIT License 5 votes vote down vote up
private OnItemViewClickedListener getItemClickedListener() {
    return new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            if (item instanceof EpisodeBaseModel) {
                Intent intent = new Intent(getActivity(), getDetailsActivityClass());
                intent.putExtra(ContentManagerBase.CONTENT_ID, (EpisodeBaseModel) item);
                startActivity(intent);
            }
        }
    };
}
 
Example #24
Source File: RowsSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the item clicked listener.
 */
public OnItemViewClickedListener getOnItemViewClickedListener() {
    return mOnItemViewClickedListener;
}
 
Example #25
Source File: DetailsSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the item Clicked listener.
 */
public OnItemViewClickedListener getOnItemViewClickedListener() {
    return mOnItemViewClickedListener;
}
 
Example #26
Source File: VerticalGridSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the item clicked listener.
 */
public OnItemViewClickedListener getOnItemViewClickedListener() {
    return mOnItemViewClickedListener;
}
 
Example #27
Source File: DetailsFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the item Clicked listener.
 */
public OnItemViewClickedListener getOnItemViewClickedListener() {
    return mOnItemViewClickedListener;
}
 
Example #28
Source File: GridFragment.java    From leanback-showcase with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the item clicked listener.
 */
public OnItemViewClickedListener getOnItemViewClickedListener() {
    return mOnItemViewClickedListener;
}
 
Example #29
Source File: RowsFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the item clicked listener.
 */
public OnItemViewClickedListener getOnItemViewClickedListener() {
    return mOnItemViewClickedListener;
}
 
Example #30
Source File: BrowseFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the item Clicked listener.
 */
public OnItemViewClickedListener getOnItemViewClickedListener() {
    return mOnItemViewClickedListener;
}