Java 类android.support.v17.leanback.widget.VerticalGridPresenter 实例源码

项目:androidtv-sample    文件:VerticalGridFragment.java   
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());
}
项目:aos-Video    文件:MyVerticalGridFragment.java   
/**
 * 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);
    }

    // ARCHOS ADDED: update the number of columns in case the GridView is already created
    if (mGridViewHolder!=null) {
        mGridViewHolder.getGridView().setNumColumns(gridPresenter.getNumberOfColumns());
    }
}
项目:webradio-tv-app    文件:RadioFragment.java   
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);
}
项目:leanback-assistant    文件:MainFragment.java   
@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());
}
项目:TvSample    文件:VerticalGridFragment1.java   
private void setupFragment() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter(FocusHighlight.ZOOM_FACTOR_SMALL);
    gridPresenter.setNumberOfColumns(numColumns);
    //gridPresenter.setShadowEnabled(false);
    setGridPresenter(gridPresenter);

    mAdapter = new ArrayObjectAdapter(new CardPresenter());

    List<Contact> contacts = ContactProvider.getContactList();
    mAdapter.addAll(0, contacts);

    setAdapter(mAdapter);

    setOnItemViewClickedListener(new ItemViewClickedListener());
    setOnItemViewSelectedListener(new ItemViewSelectedListener());
}
项目:TvSample    文件:VerticalGridFragment.java   
private void setupFragment() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter(FocusHighlight.ZOOM_FACTOR_NONE);
    gridPresenter.setNumberOfColumns(numColumns);
    //gridPresenter.setShadowEnabled(false);
    setGridPresenter(gridPresenter);

    mAdapter = new ArrayObjectAdapter(new ContactPresenter());

    List<Contact> contacts = ContactProvider.getContactList();
    mAdapter.addAll(0, contacts);

    setAdapter(mAdapter);

    setOnItemViewClickedListener(new ItemViewClickedListener());
    setOnItemViewSelectedListener(new ItemViewSelectedListener());
}
项目:itplayer    文件:BrowserFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter(FocusHighlight.ZOOM_FACTOR_MEDIUM);
    gridPresenter.setNumberOfColumns(4);
    setGridPresenter(gridPresenter);

    setOnItemViewClickedListener(this);
    setOnItemViewSelectedListener(this);

    backgroundManager = ((MainActivity) getActivity()).getBackgroundManager();
    metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);

    mainHandler = new Handler(getContext().getMainLooper());
}
项目:leanback-showcase    文件:VideoGridExampleFragment.java   
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);
}
项目:leanback-showcase    文件:GridExampleFragment.java   
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);
}
项目:leanback-showcase    文件:PageAndListRowFragment.java   
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();
        }
    });
}
项目:youtubetv    文件:YoutubeTvFragment.java   
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);
}
项目:iview-android-tv    文件:CategoryFragment.java   
private void setupFragment() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(isFilm ? FILM_COLUMNS : SHOW_COLUMNS);
    setGridPresenter(gridPresenter);
    setTitle(Utils.stripCategory(category));

    List<EpisodeBaseModel> all = getContentManger().getAllShowsByCategory(category);
    ArrayObjectAdapter adapter;
    if (isFilm) {
       adapter = new ArrayObjectAdapter(new FilmPresenter(true));
    } else {
        adapter = new ArrayObjectAdapter(new EpisodePresenter());
    }
    adapter.addAll(0, all);

    setAdapter(adapter);
}
项目:Vineyard    文件:PostGridFragment.java   
private void setupFragment() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);

    mHandler = new Handler();

    setOnSearchClickedListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(SearchActivity.getStartIntent(getActivity()));
        }
    });

    setOnItemViewClickedListener(mOnItemViewClickedListener);
    setOnItemViewSelectedListener(mOnItemViewSelectedListener);
}
项目:androidtv-Leanback    文件:VerticalGridFragment.java   
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());
}
项目:chaosflix-leanback    文件:ConferencesGridFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((LeanbackBaseActivity) getActivity()).getApiServiceObservable()
            .subscribe(mediaApiService -> {
                mediaApiService.getConferences()
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(conferences -> {
                            List<Conference> conferenceList = conferences.getConferences();
                            Collections.sort(conferenceList);
                            Collections.reverse(conferenceList);
                            mConferenceAdapter.addAll(0, conferenceList);
                            setAdapter(mConferenceAdapter);
                        });
            });
    setTitle("Chaosflix");

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

    // After 500ms, start the animation to transition the cards into view.
    new Handler().postDelayed(new Runnable() {
        public void run() {
            startEntranceTransition();
        }
    }, 500);

    setOnItemViewClickedListener(new ItemViewClickedListener(this));
}
项目:chaosflix    文件:ConferencesGridFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((LeanbackBaseActivity) getActivity()).getApiServiceObservable()
            .subscribe(mediaApiService -> {
                mediaApiService.getConferences()
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(conferences -> {
                            List<Conference> conferenceList = conferences.getConferences();
                            Collections.sort(conferenceList);
                            Collections.reverse(conferenceList);
                            mConferenceAdapter.addAll(0, conferenceList);
                            setAdapter(mConferenceAdapter);
                        });
            });
    setTitle("Chaosflix");

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

    // After 500ms, start the animation to transition the cards into view.
    new Handler().postDelayed(new Runnable() {
        public void run() {
            startEntranceTransition();
        }
    }, 500);

    setOnItemViewClickedListener(new ItemViewClickedListener(this));
}
项目:aos-Video    文件:ListingFragment.java   
private VerticalGridPresenter buildGridPresenter() {
    final int zoom;
    final boolean focusDimmer;
    final int numberOfColumns;
    final boolean shadowEnabled;

    switch (mDisplayMode) {
        case GRID:
            zoom = FocusHighlight.ZOOM_FACTOR_LARGE;
            focusDimmer = false;
            numberOfColumns = 6;
            shadowEnabled = true;
            break;
        case LIST:
            zoom = FocusHighlight.ZOOM_FACTOR_SMALL;
            focusDimmer = false;
            numberOfColumns = 1;
            shadowEnabled = true;
            break;
        default:
            throw new IllegalArgumentException("Invalid Display Mode! "+mDisplayMode);
    }

    VerticalGridPresenter vgp = new VerticalGridPresenter(zoom, focusDimmer);
    vgp.setNumberOfColumns(numberOfColumns);
    vgp.setShadowEnabled(shadowEnabled);
    return vgp;
}
项目:popcorn-android    文件:PTVMediaGridFragment.java   
private void setupFragment() {
    //setup background updater
    mBackgroundUpdater = new BackgroundUpdater();
    mBackgroundUpdater.initialise(getActivity(), R.color.black);

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

    mAdapter = new ArrayObjectAdapter(new MediaCardPresenter(getActivity()));
    setAdapter(mAdapter);

    setOnItemViewClickedListener(this);
    setOnItemViewSelectedListener(this);
}
项目:leanback-showcase    文件:GridFragment.java   
/**
 * 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);
    }
}
项目:MrinalMusicPlayer    文件:TvVerticalGridFragment.java   
private void setupFragment() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);

    mAdapter = new ArrayObjectAdapter(new CardPresenter());
    setAdapter(mAdapter);
    setOnItemViewClickedListener(new ItemViewClickedListener());
}
项目:android-UniversalMusicPlayer    文件:TvVerticalGridFragment.java   
private void setupFragment() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);

    mAdapter = new ArrayObjectAdapter(new CardPresenter(getActivity()));
    setAdapter(mAdapter);
    setOnItemViewClickedListener(new ItemViewClickedListener());
}
项目:VCL-Android    文件:GridFragment.java   
@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);
}
项目:spotify-tv    文件:CategoryFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    BusProvider.getInstance().register(this);
}
项目:vlc-android    文件:GridFragment.java   
@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);
}
项目:UniversalAndroidMusicPlayer    文件:TvVerticalGridFragment.java   
private void setupFragment() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);

    mAdapter = new ArrayObjectAdapter(new CardPresenter());
    setAdapter(mAdapter);
    setOnItemViewClickedListener(new ItemViewClickedListener());
}
项目:adt-leanback-support    文件:VerticalGridSupportFragment.java   
/**
 * 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);
    }
}
项目:adt-leanback-support    文件:VerticalGridFragment.java   
/**
 * 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);
    }
}
项目:BuildingForAndroidTV    文件:TVGridFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    loadRows();
}
项目:BuildingForAndroidTV    文件:TVGridFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    loadRows();
}
项目:BuildingForAndroidTV    文件:TVGridFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    loadRows();
}
项目:BuildingForAndroidTV    文件:VerticalGridFragment.java   
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());
}
项目:aos-Video    文件:MyVerticalGridFragment.java   
/**
 * Returns the grid presenter.
 */
public VerticalGridPresenter getGridPresenter() {
    return mGridPresenter;
}
项目:chilly    文件:VerticalGridFragment.java   
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mSpinnerFragment = new SpinnerFragment();
//        getFragmentManager().beginTransaction().add(R.id.vertical_grid_fragment, mSpinnerFragment).commit();

//        mVideoCursorAdapter.setMapper(new VideoCursorMapper());

//        setAdapter(mVideoCursorAdapter);

        mSelectedShow = (Video) getActivity().getIntent()
                .getParcelableExtra("show");

        mSelectedSeason = (Video) getActivity().getIntent()
                .getParcelableExtra("season");

        CardPresenter cp = new CardPresenter(getActivity());

        VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
        gridPresenter.setNumberOfColumns(5);

        elem = (ListElem) getActivity().getIntent().getParcelableExtra("listElem");
        if(mSelectedShow != null && mSelectedSeason != null) {
            cp.isEpisode = true;
            gridPresenter.setNumberOfColumns(4);
            setTitle(mSelectedShow.title + ": " + mSelectedSeason.title);
            elem = new ListElem();
            elem.tvshow = mSelectedShow;
            elem.season = mSelectedSeason;
        } else {
            setTitle(elem.videoType.toUpperCase() + "S: " + elem.title);
        }


        mVideoAdapter = new ArrayObjectAdapter(cp);
        setAdapter(mVideoAdapter);
        setGridPresenter(gridPresenter);

        if (savedInstanceState == null) {
            prepareEntranceTransition();
        }




        setupFragment();
    }
项目:leanback-showcase    文件:GridFragment.java   
/**
 * Returns the grid presenter.
 */
public VerticalGridPresenter getGridPresenter() {
    return mGridPresenter;
}
项目:adt-leanback-support    文件:VerticalGridSupportFragment.java   
/**
 * Returns the grid presenter.
 */
public VerticalGridPresenter getGridPresenter() {
    return mGridPresenter;
}
项目:adt-leanback-support    文件:VerticalGridFragment.java   
/**
 * Returns the grid presenter.
 */
public VerticalGridPresenter getGridPresenter() {
    return mGridPresenter;
}