Search in sources :

Example 21 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project actor-platform by actorapp.

the class StickersView method buildAdapter.

private void buildAdapter(Context context) {
    GridLayoutManager layoutManager = new GridLayoutManager(context, Screen.getWidth() / Screen.dp(70));
    setLayoutManager(layoutManager);
    stickersAdapter = new StickersAdapter(keyboard, this);
    setAdapter(stickersAdapter);
    RecyclerView packSwitch = new RecyclerView(context);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, HORIZONTAL, false);
    packSwitch.setLayoutManager(linearLayoutManager);
    packSwitch.setItemAnimator(null);
    packSwitch.setHasFixedSize(true);
    PacksAdapter packsAdapter = new PacksAdapter(context, stickersAdapter, keyboard.getStickerIndicatorContainer());
    packSwitch.setAdapter(packsAdapter);
    stickersAdapter.setPacksAdapter(packsAdapter);
    keyboard.getStickerIndicatorContainer().removeAllViews();
    keyboard.getStickerIndicatorContainer().addView(packSwitch, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 22 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project epoxy by airbnb.

the class VerticalGridCardSpacingDecoration method getItemOffsets.

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, State state) {
    if (outerPadding == -1 || innerPadding == -1) {
        DisplayMetrics m = view.getResources().getDisplayMetrics();
        outerPadding = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, OUTER_PADDING_DP, m);
        innerPadding = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, INNER_PADDING_DP, m);
    }
    int position = parent.getChildAdapterPosition(view);
    final GridLayoutManager layoutManager = (GridLayoutManager) parent.getLayoutManager();
    final SpanSizeLookup spanSizeLookup = layoutManager.getSpanSizeLookup();
    // Zero everything out for the common case
    outRect.setEmpty();
    int spanSize = spanSizeLookup.getSpanSize(position);
    int spanCount = layoutManager.getSpanCount();
    int spanIndex = spanSizeLookup.getSpanIndex(position, spanCount);
    if (spanSize == spanCount) {
        // Only item in row
        outRect.left = outerPadding;
        outRect.right = outerPadding;
    } else if (spanIndex == 0) {
        // First item in row
        outRect.left = outerPadding;
        outRect.right = innerPadding;
    } else if (spanIndex == spanCount - 1) {
        // Last item in row
        outRect.left = innerPadding;
        outRect.right = outerPadding;
    } else {
        // Inner item (not relevant for less than three columns)
        outRect.left = innerPadding;
        outRect.right = innerPadding;
    }
}
Also used : SpanSizeLookup(android.support.v7.widget.GridLayoutManager.SpanSizeLookup) GridLayoutManager(android.support.v7.widget.GridLayoutManager) DisplayMetrics(android.util.DisplayMetrics)

Example 23 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project GestureViews by alexvasilkov.

the class DefaultEndlessRecyclerAdapter method onAttachedToRecyclerView.

@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
    if (recyclerView.getLayoutManager() instanceof GridLayoutManager) {
        GridLayoutManager gridManager = (GridLayoutManager) recyclerView.getLayoutManager();
        spanCount = gridManager.getSpanCount();
        originalSpanLookup = gridManager.getSpanSizeLookup();
        gridManager.setSpanSizeLookup(spanSizes);
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Example 24 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project GestureViews by alexvasilkov.

the class DefaultEndlessRecyclerAdapter method onDetachedFromRecyclerView.

@Override
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
    super.onDetachedFromRecyclerView(recyclerView);
    if (recyclerView.getLayoutManager() instanceof GridLayoutManager) {
        GridLayoutManager gridManager = (GridLayoutManager) recyclerView.getLayoutManager();
        gridManager.setSpanSizeLookup(originalSpanLookup);
        originalSpanLookup = null;
        spanCount = 1;
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Example 25 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project FastDev4Android by jiangqqlmj.

the class RecyclerViewTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.recyclerview_test_layout);
    top_bar_linear_back = (LinearLayout) this.findViewById(R.id.top_bar_linear_back);
    btn_add = (Button) this.findViewById(R.id.btn_add);
    btn_delete = (Button) this.findViewById(R.id.btn_delete);
    top_bar_linear_back.setOnClickListener(new CustomOnClickListener());
    btn_add.setOnClickListener(new CustomOnClickListener());
    btn_delete.setOnClickListener(new CustomOnClickListener());
    top_bar_title = (TextView) this.findViewById(R.id.top_bar_title);
    top_bar_title.setText("RecyclerView使用实例");
    //开始设置RecyclerView
    recyclerView_one = (RecyclerView) this.findViewById(R.id.recyclerView_one);
    recyclerView_one.setHasFixedSize(true);
    //1.LinearLayoutManager 线性布局类型
    mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(OrientationHelper.VERTICAL);
    recyclerView_one.setLayoutManager(mLayoutManager);
    //2.GridLayoutManager 表格布局类型
    //        GridLayoutManager girdLayoutManager=new GridLayoutManager(this,4);
    //        recyclerView_one.setLayoutManager(girdLayoutManager);
    //3.采用StaggeredGridLayoutManager  流式布局类型
    //        StaggeredGridLayoutManager staggeredGridLayoutManager=new StaggeredGridLayoutManager(2,OrientationHelper.VERTICAL);
    //        recyclerView_one.setLayoutManager(staggeredGridLayoutManager);
    //添加默认的动画效果
    recyclerView_one.setItemAnimator(new DefaultItemAnimator());
    //添加分隔线
    recyclerView_one.addItemDecoration(new AdvanceDecoration(this, OrientationHelper.VERTICAL));
    mAdapter = new TestRecyclerAdapter(this, new TestRecyclerAdapter.OnRecyclerItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            Toast.makeText(RecyclerViewTestActivity.this, "点击了第" + position + "项", Toast.LENGTH_SHORT).show();
        }
    });
    recyclerView_one.setAdapter(mAdapter);
}
Also used : AdvanceDecoration(com.chinaztt.fda.widget.AdvanceDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) TestRecyclerAdapter(com.chinaztt.fda.adapter.TestRecyclerAdapter)

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