Search in sources :

Example 56 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project AdMoney by ErnestoGonAr.

the class Deudas method setRecyclerViewLayoutManager.

public void setRecyclerViewLayoutManager(LayoutManagerType layoutManagerType) {
    int scrollPosition = 0;
    // If a layout manager has already been set, get current scroll position.
    if (mRecyclerView.getLayoutManager() != null) {
        scrollPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
    }
    switch(layoutManagerType) {
        case GRID_LAYOUT_MANAGER:
            mLayoutManager = new GridLayoutManager(getActivity(), SPAN_COUNT);
            mCurrentLayoutManagerType = LayoutManagerType.GRID_LAYOUT_MANAGER;
            break;
        case LINEAR_LAYOUT_MANAGER:
            mLayoutManager = new LinearLayoutManager(getActivity());
            mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
            break;
        default:
            mLayoutManager = new LinearLayoutManager(getActivity());
            mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
    }
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.scrollToPosition(scrollPosition);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 57 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project AdMoney by ErnestoGonAr.

the class Saldo method setRecyclerViewLayoutManager.

public void setRecyclerViewLayoutManager(LayoutManagerType layoutManagerType) {
    int scrollPosition = 0;
    // If a layout manager has already been set, get current scroll position.
    if (mRecyclerView.getLayoutManager() != null) {
        scrollPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
    }
    switch(layoutManagerType) {
        case GRID_LAYOUT_MANAGER:
            mLayoutManager = new GridLayoutManager(getActivity(), SPAN_COUNT);
            mCurrentLayoutManagerType = LayoutManagerType.GRID_LAYOUT_MANAGER;
            break;
        case LINEAR_LAYOUT_MANAGER:
            mLayoutManager = new LinearLayoutManager(getActivity());
            mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
            break;
        default:
            mLayoutManager = new LinearLayoutManager(getActivity());
            mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
    }
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.scrollToPosition(scrollPosition);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 58 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project PhotoNoter by yydcdut.

the class MediaPhotoFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mMainActivity = (MainActivity) getActivity();
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 3);
    mRecyclerView.setLayoutManager(gridLayoutManager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 59 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project CloudReader by youlookwhat.

the class BookCustomFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    showContentView();
    bindingView.srlBook.setColorSchemeColors(CommonUtils.getColor(R.color.colorTheme));
    bindingView.srlBook.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            DebugUtil.error("-----onRefresh");
            //                listTag= Arrays.asList(BookApiUtils.getApiTag(position));
            //                String tag=BookApiUtils.getRandomTAG(listTag);
            //                doubanBookPresenter.searchBookByTag(BookReadingFragment.this,tag,false);
            bindingView.srlBook.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mStart = 0;
                    loadCustomData();
                }
            }, 1000);
        }
    });
    //        mBookAdapter = new BookAdapter(getActivity());
    //        mLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
    mLayoutManager = new GridLayoutManager(getActivity(), 3);
    bindingView.xrvBook.setLayoutManager(mLayoutManager);
    //        bindingView.xrvBook.setAdapter(mBookAdapter);
    scrollRecycleView();
    // 准备就绪
    mIsPrepared = true;
    /**
         * 因为启动时先走loadData()再走onActivityCreated,
         * 所以此处要额外调用load(),不然最初不会加载内容
         */
    loadData();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Example 60 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project wh-app-android by WhiteHouse.

the class FeedItemListFragment method onCreateLayoutManager.

@Override
public RecyclerView.LayoutManager onCreateLayoutManager() {
    Resources res = getResources();
    int feedGridCols = res.getInteger(R.integer.feed_grid_columns);
    int photoGridCols = res.getInteger(R.integer.photo_grid_columns);
    switch(mFeedType) {
        case TYPE_PHOTOS:
            return new StaggeredGridLayoutManager(photoGridCols, VERTICAL);
        case TYPE_VIDEOS:
            return new GridLayoutManager(getActivity(), feedGridCols);
        case TYPE_LIVE:
            return new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
        case TYPE_ARTICLE:
        default:
            return new StaggeredGridLayoutManager(feedGridCols, VERTICAL);
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) Resources(android.content.res.Resources) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)292 RecyclerView (android.support.v7.widget.RecyclerView)135 View (android.view.View)76 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)73 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)44 TextView (android.widget.TextView)39 BindView (butterknife.BindView)19 Toolbar (android.support.v7.widget.Toolbar)16 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)14 MaterialViewPagerHeaderDecorator (com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)14 Nullable (android.support.annotation.Nullable)13 ImageView (android.widget.ImageView)13 ArrayList (java.util.ArrayList)13 Intent (android.content.Intent)12 Handler (android.os.Handler)12 Bundle (android.os.Bundle)11 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)11 SuppressLint (android.annotation.SuppressLint)10 Context (android.content.Context)10 Point (android.graphics.Point)9