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);
}
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;
}
}
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);
}
}
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;
}
}
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);
}
Aggregations