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

The following examples show how to use android.support.v17.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 leanback-showcase with Apache License 2.0 7 votes vote down vote up
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: 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 #3
Source File: MainFragment.java    From leanback-assistant with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ArrayObjectAdapter mRowAdapter =
            new ArrayObjectAdapter(new VideoCardViewPresenter(getContext()));
    setAdapter(mRowAdapter);

    setTitle(getString(R.string.assistant_playback_videos));
    setBadgeDrawable(
            getActivity().getResources().getDrawable(R.drawable.assistant_tv_banner, null));

    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);

    for (Movie movie : MockDatabase.getAllMovies()) {
        mRowAdapter.add(movie);
    }

    setOnItemViewClickedListener(new ItemViewClickedListener());
}
 
Example #4
Source File: GridExampleFragment.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: GridFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #6
Source File: GridFragment.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = getActivity();
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);
    mAdapter = new ArrayObjectAdapter(new CardPresenter(mContext));
    mAdapter.clear();
    setAdapter(mAdapter);
}
 
Example #7
Source File: VerticalGridSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * 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(mRowSelectedListener);
    if (mOnItemViewClickedListener != null) {
        mGridPresenter.setOnItemViewClickedListener(mOnItemViewClickedListener);
    }
    if (mOnItemClickedListener != null) {
        mGridPresenter.setOnItemClickedListener(mOnItemClickedListener);
    }
}
 
Example #8
Source File: VerticalGridFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * 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(mRowSelectedListener);
    if (mOnItemViewClickedListener != null) {
        mGridPresenter.setOnItemViewClickedListener(mOnItemViewClickedListener);
    }
    if (mOnItemClickedListener != null) {
        mGridPresenter.setOnItemClickedListener(mOnItemClickedListener);
    }
}
 
Example #9
Source File: TVGridFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	VerticalGridPresenter presenter = new VerticalGridPresenter();
	presenter.setNumberOfColumns(3);
	setGridPresenter(presenter);

	loadRows();
}
 
Example #10
Source File: TVGridFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	VerticalGridPresenter presenter = new VerticalGridPresenter();
	presenter.setNumberOfColumns(3);
	setGridPresenter(presenter);

	loadRows();
}
 
Example #11
Source File: TVGridFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	VerticalGridPresenter presenter = new VerticalGridPresenter();
	presenter.setNumberOfColumns(3);
	setGridPresenter(presenter);

	loadRows();
}
 
Example #12
Source File: VerticalGridFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private void setupFragment() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);

    mAdapter = new ArrayObjectAdapter(new CardPresenter());

    long seed = System.nanoTime();

    HashMap<String, List<Movie>> movies = VideoProvider.getMovieList();

    for (Map.Entry<String, List<Movie>> entry : movies.entrySet()) {
        List<Movie> list = entry.getValue();
        Collections.shuffle(list, new Random(seed));
        for (Movie movie : list) {
            mAdapter.add(movie);
        }
    }

    setAdapter(mAdapter);

    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 #13
Source File: GridFragment.java    From leanback-showcase with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the grid presenter.
 */
public VerticalGridPresenter getGridPresenter() {
    return mGridPresenter;
}
 
Example #14
Source File: VerticalGridSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the grid presenter.
 */
public VerticalGridPresenter getGridPresenter() {
    return mGridPresenter;
}
 
Example #15
Source File: VerticalGridFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the grid presenter.
 */
public VerticalGridPresenter getGridPresenter() {
    return mGridPresenter;
}