androidx.recyclerview.widget.GridLayoutManager.getSpanSizeLookup()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中androidx.recyclerview.widget.GridLayoutManager.getSpanSizeLookup()方法的一些代码示例,展示了GridLayoutManager.getSpanSizeLookup()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridLayoutManager.getSpanSizeLookup()方法的具体详情如下:
包路径:androidx.recyclerview.widget.GridLayoutManager
类名称:GridLayoutManager
方法名:getSpanSizeLookup

GridLayoutManager.getSpanSizeLookup介绍

暂无

代码示例

代码示例来源:origin: alexvasilkov/GestureViews

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

代码示例来源:origin: airbnb/epoxy

/**
 * If a grid layout manager is set we sync the span count between the layout and the epoxy
 * adapter automatically.
 */
private void syncSpanCount() {
 LayoutManager layout = getLayoutManager();
 if (layout instanceof GridLayoutManager && epoxyController != null) {
  GridLayoutManager grid = (GridLayoutManager) layout;
  if (epoxyController.getSpanCount() != grid.getSpanCount()
    || grid.getSpanSizeLookup() != epoxyController.getSpanSizeLookup()) {
   epoxyController.setSpanCount(grid.getSpanCount());
   grid.setSpanSizeLookup(epoxyController.getSpanSizeLookup());
  }
 }
}

代码示例来源:origin: airbnb/epoxy

private void calculatePositionDetails(RecyclerView parent, int position, LayoutManager layout) {
 int itemCount = parent.getAdapter().getItemCount();
 firstItem = position == 0;
 lastItem = position == itemCount - 1;
 horizontallyScrolling = layout.canScrollHorizontally();
 verticallyScrolling = layout.canScrollVertically();
 grid = layout instanceof GridLayoutManager;
 if (grid) {
  GridLayoutManager grid = (GridLayoutManager) layout;
  final SpanSizeLookup spanSizeLookup = grid.getSpanSizeLookup();
  int spanSize = spanSizeLookup.getSpanSize(position);
  int spanCount = grid.getSpanCount();
  int spanIndex = spanSizeLookup.getSpanIndex(position, spanCount);
  isFirstItemInRow = spanIndex == 0;
  fillsLastSpan = spanIndex + spanSize == spanCount;
  isInFirstRow = isInFirstRow(position, spanSizeLookup, spanCount);
  isInLastRow =
    !isInFirstRow && isInLastRow(position, itemCount, spanSizeLookup, spanCount);
 }
}

相关文章