androidx.leanback.widget.VerticalGridPresenter Java Examples
The following examples show how to use
androidx.leanback.widget.VerticalGridPresenter.
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: VideoGridExampleFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private void setupRowAdapter() { VerticalGridPresenter videoGridPresenter = new VerticalGridPresenter(ZOOM_FACTOR); videoGridPresenter.setNumberOfColumns(COLUMNS); // note: The click listeners must be called before setGridPresenter for the event listeners // to be properly registered on the viewholders. setOnItemViewSelectedListener(this); setOnItemViewClickedListener(this); setGridPresenter(videoGridPresenter); PresenterSelector cardPresenterSelector = new CardPresenterSelector(getActivity()); // VideoCardViewPresenter videoCardViewPresenter = new VideoCardViewPresenter(getActivity()); mAdapter = new ArrayObjectAdapter(cardPresenterSelector); setAdapter(mAdapter); prepareEntranceTransition(); new Handler().postDelayed(new Runnable() { @Override public void run() { createRows(); } }, 1000); }
Example #2
Source File: GridExampleFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private void setupRowAdapter() { VerticalGridPresenter gridPresenter = new VerticalGridPresenter(ZOOM_FACTOR); gridPresenter.setNumberOfColumns(COLUMNS); setGridPresenter(gridPresenter); PresenterSelector cardPresenterSelector = new CardPresenterSelector(getActivity()); mAdapter = new ArrayObjectAdapter(cardPresenterSelector); setAdapter(mAdapter); prepareEntranceTransition(); new Handler().postDelayed(new Runnable() { @Override public void run() { createRows(); startEntranceTransition(); } }, 1000); }
Example #3
Source File: PageAndListRowFragment.java From tv-samples with Apache License 2.0 | 6 votes |
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 #4
Source File: VerticalGridFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private void setupFragment() { VerticalGridPresenter gridPresenter = new VerticalGridPresenter(); gridPresenter.setNumberOfColumns(NUM_COLUMNS); setGridPresenter(gridPresenter); getLoaderManager().initLoader(ALL_VIDEOS_LOADER, null, this); // After 500ms, start the animation to transition the cards into view. new Handler().postDelayed(new Runnable() { public void run() { startEntranceTransition(); } }, 500); setOnSearchClickedListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getActivity(), SearchActivity.class); startActivity(intent); } }); setOnItemViewClickedListener(new ItemViewClickedListener()); setOnItemViewSelectedListener(new ItemViewSelectedListener()); }
Example #5
Source File: StdGridFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApplication = TvApp.getApplication(); mFolder = SerializerRepository.INSTANCE.getSerializer().DeserializeFromString(getActivity().getIntent().getStringExtra(Extras.Folder), BaseItemDto.class); mParentId = mFolder.getId(); MainTitle = mFolder.getName(); mDisplayPrefs = TvApp.getApplication().getCachedDisplayPrefs(mFolder.getDisplayPreferencesId()); //These should have already been loaded mPosterSizeSetting = mDisplayPrefs.getCustomPrefs().get("PosterSize"); mImageType = mDisplayPrefs.getCustomPrefs().get("ImageType"); if (mImageType == null) mImageType = ImageType.DEFAULT; if (mPosterSizeSetting == null) mPosterSizeSetting = PosterSize.AUTO; mCardHeight = getCardHeight(mPosterSizeSetting); if (mApplication.getUserPreferences().get(UserPreferences.Companion.getGridDirection()) == GridDirection.HORIZONTAL) setGridPresenter(new HorizontalGridPresenter()); else setGridPresenter(new VerticalGridPresenter()); setGridSizes(); mJumplistPopup = new JumplistPopup(getActivity()); }
Example #6
Source File: VerticalGridFragment.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
private void setupFragment() { VerticalGridPresenter gridPresenter = new VerticalGridPresenter(); gridPresenter.setNumberOfColumns(NUM_COLUMNS); setGridPresenter(gridPresenter); getLoaderManager().initLoader(ALL_VIDEOS_LOADER, null, this); // After 500ms, start the animation to transition the cards into view. new Handler().postDelayed(new Runnable() { public void run() { startEntranceTransition(); } }, 500); setOnSearchClickedListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getActivity(), SearchActivity.class); startActivity(intent); } }); setOnItemViewClickedListener(new ItemViewClickedListener()); setOnItemViewSelectedListener(new ItemViewSelectedListener()); }
Example #7
Source File: GridFragment.java From tv-samples with Apache License 2.0 | 5 votes |
/** * Sets the grid presenter. */ public void setGridPresenter(VerticalGridPresenter gridPresenter) { if (gridPresenter == null) { throw new IllegalArgumentException("Grid presenter may not be null"); } mGridPresenter = gridPresenter; mGridPresenter.setOnItemViewSelectedListener(mViewSelectedListener); if (mOnItemViewClickedListener != null) { mGridPresenter.setOnItemViewClickedListener(mOnItemViewClickedListener); } }
Example #8
Source File: GridFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
/** * Sets the grid presenter. */ public void setGridPresenter(VerticalGridPresenter gridPresenter) { if (gridPresenter == null) { throw new IllegalArgumentException("Grid presenter may not be null"); } gridPresenter.setOnItemViewSelectedListener(mRowSelectedListener); if (mOnItemViewClickedListener != null) { gridPresenter.setOnItemViewClickedListener(mOnItemViewClickedListener); } mGridPresenter = gridPresenter; }
Example #9
Source File: GridFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
/** * Sets an item clicked listener. */ public void setOnItemViewClickedListener(OnItemViewClickedListener listener) { mOnItemViewClickedListener = listener; if (mGridPresenter != null) { if (mGridPresenter instanceof HorizontalGridPresenter) ((HorizontalGridPresenter)mGridPresenter).setOnItemViewClickedListener(mOnItemViewClickedListener); else if (mGridPresenter instanceof VerticalGridPresenter) ((VerticalGridPresenter)mGridPresenter).setOnItemViewClickedListener(mOnItemViewClickedListener); } }
Example #10
Source File: GridFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
protected void createGrid() { mGridViewHolder = mGridPresenter.onCreateViewHolder(mGridDock); if (mGridViewHolder instanceof HorizontalGridPresenter.ViewHolder) mGridView = ((HorizontalGridPresenter.ViewHolder)mGridViewHolder).getGridView(); else if (mGridViewHolder instanceof VerticalGridPresenter.ViewHolder) mGridView = ((VerticalGridPresenter.ViewHolder)mGridViewHolder).getGridView(); mGridView.setFocusable(true); mGridDock.removeAllViews(); mGridView.setGravity(Gravity.CENTER_VERTICAL); mGridDock.addView(mGridViewHolder.view); updateAdapter(); }
Example #11
Source File: StdGridFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
private void setGridSizes() { Presenter gridPresenter = getGridPresenter(); if (gridPresenter instanceof HorizontalGridPresenter) { ((HorizontalGridPresenter) gridPresenter).setNumberOfRows(getGridHeight() / getCardHeight()); } else if (gridPresenter instanceof VerticalGridPresenter) { // Why is this hardcoded you ask? Well did you ever look at getGridHeight()? Yup that one is hardcoded too // This whole fragment is only optimized for 16:9 screens anyway // is this bad? Yup it definitely is, we'll fix it when this screen is rewritten int size; switch (mPosterSizeSetting) { case PosterSize.SMALL: size = 10; break; case PosterSize.MED: default: size = 6; break; case PosterSize.LARGE: size = 5; break; } ((VerticalGridPresenter) gridPresenter).setNumberOfColumns(size); } }
Example #12
Source File: GridFragment.java From tv-samples with Apache License 2.0 | 4 votes |
/** * Returns the grid presenter. */ public VerticalGridPresenter getGridPresenter() { return mGridPresenter; }