Search in sources :

Example 91 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project bilibili-android-client by HotBitmapGG.

the class UserHomePageFragment method setCoins.

private void setCoins() {
    int count = mUserCoinsInfo.getData().getCount();
    if (count == 0) {
        coinsLayout.setVisibility(View.GONE);
    }
    List<UserCoinsInfo.DataBean.ListBean> list = mUserCoinsInfo.getData().getList();
    mCoinsRecycler.setHasFixedSize(false);
    mCoinsRecycler.setNestedScrollingEnabled(false);
    mCoinsRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    mCoinsRecycler.setAdapter(new UserHomePagerCoinsAdapter(mCoinsRecycler, list));
    mCoinsCount.setText(String.valueOf(count));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) UserCoinsInfo(com.hotbitmapgg.bilibili.entity.user.UserCoinsInfo) UserHomePagerCoinsAdapter(com.hotbitmapgg.bilibili.adapter.UserHomePagerCoinsAdapter) SuppressLint(android.annotation.SuppressLint)

Example 92 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project bilibili-android-client by HotBitmapGG.

the class UserHomePageFragment method setChaseBangumi.

private void setChaseBangumi() {
    int count = mUserChaseBangumiInfo.getData().getCount();
    if (count == 0) {
        chaseBangumiLayout.setVisibility(View.GONE);
    }
    List<UserChaseBangumiInfo.DataBean.ResultBean> result = mUserChaseBangumiInfo.getData().getResult();
    mChaseBangumiRecycler.setHasFixedSize(false);
    mChaseBangumiRecycler.setNestedScrollingEnabled(false);
    mChaseBangumiRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 3));
    mChaseBangumiRecycler.setAdapter(new UserHomePagerChaseBangumiAdapter(mChaseBangumiRecycler, result));
    mChaseBangumiCount.setText(String.valueOf(count));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) UserChaseBangumiInfo(com.hotbitmapgg.bilibili.entity.user.UserChaseBangumiInfo) UserHomePagerChaseBangumiAdapter(com.hotbitmapgg.bilibili.adapter.UserHomePagerChaseBangumiAdapter) SuppressLint(android.annotation.SuppressLint)

Example 93 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project PullZoomView by Frank-Zhu.

the class PullToZoomRecyclerViewEx method isFirstItemVisible.

private boolean isFirstItemVisible() {
    if (mRootView != null) {
        final RecyclerView.Adapter adapter = mRootView.getAdapter();
        final GridLayoutManager mLayoutmanager = (GridLayoutManager) mRootView.getLayoutManager();
        if (null == adapter || adapter.getItemCount() == 0) {
            return true;
        } else {
            /**
                 * This check should really just be:
                 * mRootView.getFirstVisiblePosition() == 0, but PtRListView
                 * internally use a HeaderView which messes the positions up. For
                 * now we'll just add one to account for it and rely on the inner
                 * condition which checks getTop().
                 */
            int[] into = { 0, 0 };
            if (mLayoutmanager != null)
                into[0] = mLayoutmanager.findFirstVisibleItemPosition();
            if (into.length > 0 && into.length > 0 && into[0] <= 1) {
                final View firstVisibleChild = mRootView.getChildAt(0);
                if (firstVisibleChild != null) {
                    return firstVisibleChild.getTop() >= mRootView.getTop();
                }
            }
        }
    }
    return false;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 94 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project PullZoomView by Frank-Zhu.

the class PullToZoomRecyclerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pull_to_zoom_recycler_view);
    listView = (PullToZoomRecyclerViewEx) findViewById(R.id.recyclerview);
    final RecyclerViewHeaderAdapter mAdapter = new RecyclerAdapterCustom(this);
    final GridLayoutManager manager = new GridLayoutManager(this, 2);
    manager.setOrientation(GridLayoutManager.VERTICAL);
    manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            return mAdapter.getItemViewType(position) == RecyclerViewHeaderAdapter.INT_TYPE_HEADER ? 2 : 1;
        }
    });
    listView.setAdapterAndLayoutManager(mAdapter, manager);
    DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
    int mScreenHeight = localDisplayMetrics.heightPixels;
    int mScreenWidth = localDisplayMetrics.widthPixels;
    AbsListView.LayoutParams localObject = new AbsListView.LayoutParams(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
    listView.setHeaderLayoutParams(localObject);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) AbsListView(android.widget.AbsListView) DisplayMetrics(android.util.DisplayMetrics)

Example 95 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project bilibili-android-client by HotBitmapGG.

the class HomeRecommendedFragment method initRecyclerView.

@Override
protected void initRecyclerView() {
    mSectionedAdapter = new SectionedRecyclerViewAdapter();
    GridLayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 2);
    mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            switch(mSectionedAdapter.getSectionItemViewType(position)) {
                case SectionedRecyclerViewAdapter.VIEW_TYPE_HEADER:
                    return 2;
                case SectionedRecyclerViewAdapter.VIEW_TYPE_FOOTER:
                    return 2;
                default:
                    return 1;
            }
        }
    });
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(mSectionedAdapter);
    setRecycleNoScroll();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) SectionedRecyclerViewAdapter(com.hotbitmapgg.bilibili.widget.sectioned.SectionedRecyclerViewAdapter)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)264 RecyclerView (android.support.v7.widget.RecyclerView)118 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)68 View (android.view.View)60 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)38 TextView (android.widget.TextView)32 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)15 MaterialViewPagerHeaderDecorator (com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)14 BindView (butterknife.BindView)13 ArrayList (java.util.ArrayList)13 Handler (android.os.Handler)12 Toolbar (android.support.v7.widget.Toolbar)12 ImageView (android.widget.ImageView)12 Context (android.content.Context)11 Intent (android.content.Intent)11 Point (android.graphics.Point)9 Nullable (android.support.annotation.Nullable)9 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)9 SuppressLint (android.annotation.SuppressLint)8 AdapterView (android.widget.AdapterView)8