Search in sources :

Example 86 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project AndroidDevelop by 7449.

the class ContentsActivity method initCreate.

@Override
protected void initCreate(Bundle savedInstanceState) {
    Bundle extras = getIntent().getExtras();
    toolbar.setTitle(extras.getString(TITLE));
    setSupportActionBar(toolbar);
    swipeRefreshLayout.setEnabled(false);
    xRecyclerViewAdapter = new XRecyclerViewAdapter<>();
    recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    list = new ArrayList<>();
    recyclerView.setAdapter(xRecyclerViewAdapter.initXData(list).addRecyclerView(recyclerView).setLayoutId(R.layout.item_contents).onXBind(this).setOnItemClickListener(this));
    new ContentsPresenterImpl(this).startContents(extras.getString(URL));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) Bundle(android.os.Bundle) ContentsPresenterImpl(com.fiction.y.contents.p.ContentsPresenterImpl)

Example 87 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project AndroidDevelop by 7449.

the class CheckFragment method initData.

@Override
protected void initData() {
    mPresenter = new CheckPresenterImpl(this);
    mSaveApp.setOnClickListener(this);
    mSaveAppAll.setOnClickListener(this);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 4));
    mAdapter = new CheckAdapter(new ArrayList<>());
    mAdapter.setOnItemClickListener(this);
    mAdapter.setOnLongClickListener(this);
    mRecyclerView.setAdapter(mAdapter);
    onRefresh();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) CheckPresenterImpl(com.lock.checkapp.presenter.CheckPresenterImpl) ArrayList(java.util.ArrayList)

Example 88 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project AndroidDevelop by 7449.

the class SuperAdapter method onAttachedToRecyclerView.

@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
    RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
    if (manager instanceof GridLayoutManager) {
        final GridLayoutManager gridManager = ((GridLayoutManager) manager);
        gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                if (!(getItemViewType(position) == TYPE_ITEM)) {
                    return gridManager.getSpanCount();
                } else {
                    return 1;
                }
            }
        });
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView)

Example 89 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project SwipeToLoadLayout by Aspsine.

the class TwitterRecyclerFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    swipeToLoadLayout = (SwipeToLoadLayout) view.findViewById(R.id.swipeToLoadLayout);
    recyclerView = (RecyclerView) view.findViewById(R.id.swipe_target);
    RecyclerView.LayoutManager layoutManager = null;
    if (mType == TYPE_LINEAR) {
        layoutManager = new LinearLayoutManager(getContext());
    } else if (mType == TYPE_GRID) {
        layoutManager = new GridLayoutManager(getContext(), 2);
    } else if (mType == TYPE_STAGGERED_GRID) {
        layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    }
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(mAdapter);
    swipeToLoadLayout.setOnRefreshListener(this);
    swipeToLoadLayout.setOnLoadMoreListener(this);
    recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                if (!ViewCompat.canScrollVertically(recyclerView, 1)) {
                    swipeToLoadLayout.setLoadingMore(true);
                }
            }
        }
    });
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 90 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project SwipeToLoadLayout by Aspsine.

the class RecyclerCharactersAdapter method onAttachedToRecyclerView.

@Override
public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                RecyclerView.Adapter adapter = recyclerView.getAdapter();
                if (isFullSpanType(adapter.getItemViewType(position))) {
                    return gridLayoutManager.getSpanCount();
                }
                return 1;
            }
        });
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView)

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