Search in sources :

Example 26 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project PhotoView by chrisbanes.

the class ActivityTransitionActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transition);
    RecyclerView list = (RecyclerView) findViewById(R.id.list);
    list.setLayoutManager(new GridLayoutManager(this, 2));
    ImageAdapter imageAdapter = new ImageAdapter(new ImageAdapter.Listener() {

        @Override
        public void onImageClicked(View view) {
            transition(view);
        }
    });
    list.setAdapter(imageAdapter);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 27 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project philm by chrisbanes.

the class MovieDetailFragment method populateUi.

private void populateUi() {
    if (mMovie == null) {
        return;
    }
    if (mBackdropImageView != null) {
        if (mMovie.hasBackdropUrl()) {
            mBackdropImageView.loadBackdrop(mMovie);
        }
    }
    if (mCollapsingToolbarLayout != null) {
        mCollapsingToolbarLayout.setTitle(mMovie.getTitle());
    }
    mAdapter = new GroupAdapter();
    mAdapter.add(new TitleItem());
    mAdapter.add(new ButtonsItem());
    if (!TextUtils.isEmpty(mMovie.getOverview())) {
        mAdapter.add(new SummaryItem());
    }
    mAdapter.add(new RatingItem());
    mAdapter.add(new DetailsGroup());
    //
    //        if (!PhilmCollections.isEmpty(mMovie.getTrailers())) {
    //            mItems.add(DetailItemType.TRAILERS);
    //        }
    //
    //        if (!PhilmCollections.isEmpty(mMovie.getCast())) {
    //            mItems.add(DetailItemType.CAST);
    //        }
    //
    //        if (!PhilmCollections.isEmpty(mMovie.getCrew())) {
    //            mItems.add(DetailItemType.CREW);
    //        }
    //
    //        if (!PhilmCollections.isEmpty(mMovie.getRelated())) {
    //            mItems.add(DetailItemType.RELATED);
    //        }
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), mAdapter.getSpanCount());
    layoutManager.setSpanSizeLookup(mAdapter.getSpanSizeLookup());
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setAdapter(mAdapter);
}
Also used : GroupAdapter(com.genius.groupie.GroupAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Example 28 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project AndroidAutoLayout by hongyangAndroid.

the class RecyclerViewGridFragment method initView.

private void initView() {
    mContext = getActivity();
    mRecyclerView = (RecyclerView) mView.findViewById(R.id.id_recyclerview);
    mList = new ArrayList<String>();
    for (int i = 0; i < 50; i++) {
        mList.add(i + "");
    }
    mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2, GridLayoutManager.HORIZONTAL, false));
    mRecyclerView.setAdapter(new MyAdapter());
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Example 29 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project baseAdapter by hongyangAndroid.

the class RecyclerViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recyclerview);
    initDatas();
    mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview);
    //        mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    //        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
    mAdapter = new CommonAdapter<String>(this, R.layout.item_list, mDatas) {

        @Override
        protected void convert(ViewHolder holder, String s, int position) {
            holder.setText(R.id.id_item_list_title, s + " : " + holder.getAdapterPosition() + " , " + holder.getLayoutPosition());
        }
    };
    initHeaderAndFooter();
    //        initEmptyView();
    mLoadMoreWrapper = new LoadMoreWrapper(mHeaderAndFooterWrapper);
    mLoadMoreWrapper.setLoadMoreView(R.layout.default_loading);
    mLoadMoreWrapper.setOnLoadMoreListener(new LoadMoreWrapper.OnLoadMoreListener() {

        @Override
        public void onLoadMoreRequested() {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    for (int i = 0; i < 10; i++) {
                        mDatas.add("Add:" + i);
                    }
                    mLoadMoreWrapper.notifyDataSetChanged();
                }
            }, 3000);
        }
    });
    mRecyclerView.setAdapter(mLoadMoreWrapper);
    mAdapter.setOnItemClickListener(new CommonAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
            Toast.makeText(RecyclerViewActivity.this, "pos = " + position, Toast.LENGTH_SHORT).show();
            mAdapter.notifyItemRemoved(position);
        }

        @Override
        public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) {
            return false;
        }
    });
}
Also used : LoadMoreWrapper(com.zhy.adapter.recyclerview.wrapper.LoadMoreWrapper) Handler(android.os.Handler) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CommonAdapter(com.zhy.adapter.recyclerview.CommonAdapter) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ViewHolder(com.zhy.adapter.recyclerview.base.ViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 30 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project baseAdapter by hongyangAndroid.

the class WrapperUtils method onAttachedToRecyclerView.

public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback) {
    innerAdapter.onAttachedToRecyclerView(recyclerView);
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
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