當前位置: 首頁>>代碼示例>>Java>>正文


Java GridLayoutManager.getSpanSizeLookup方法代碼示例

本文整理匯總了Java中android.support.v7.widget.GridLayoutManager.getSpanSizeLookup方法的典型用法代碼示例。如果您正苦於以下問題:Java GridLayoutManager.getSpanSizeLookup方法的具體用法?Java GridLayoutManager.getSpanSizeLookup怎麽用?Java GridLayoutManager.getSpanSizeLookup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.GridLayoutManager的用法示例。


在下文中一共展示了GridLayoutManager.getSpanSizeLookup方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:WrapperUtils.java

示例2: getLastDividerOffset

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
/**
 * In the case mShowLastDivider = false,
 * Returns offset for how many views we don't have to draw a divider for,
 * for LinearLayoutManager it is as simple as not drawing the last child divider,
 * but for a GridLayoutManager it needs to take the span count for the last items into account
 * until we use the span count configured for the grid.
 *
 * @param parent RecyclerView
 * @return offset for how many views we don't have to draw a divider or 1 if its a
 * LinearLayoutManager
 */
private int getLastDividerOffset(RecyclerView parent) {
    if (parent.getLayoutManager() instanceof GridLayoutManager) {
        GridLayoutManager layoutManager = (GridLayoutManager) parent.getLayoutManager();
        GridLayoutManager.SpanSizeLookup spanSizeLookup = layoutManager.getSpanSizeLookup();
        int spanCount = layoutManager.getSpanCount();
        int itemCount = parent.getAdapter().getItemCount();
        for (int i = itemCount - 1; i >= 0; i--) {
            if (spanSizeLookup.getSpanIndex(i, spanCount) == 0) {
                return itemCount - i;
            }
        }
    }

    return 1;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:FlexibleDividerDecoration.java

示例3: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    mInnerAdapter.onAttachedToRecyclerView(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) {
                int viewType = getItemViewType(position);
                if (viewType == TYPE_REFRESH_HEADER) {
                    return gridLayoutManager.getSpanCount();
                } else if (viewType == TYPE_LOADMORE_FOOTER) {
                    return gridLayoutManager.getSpanCount();
                }
                if (spanSizeLookup != null)
                    return spanSizeLookup.getSpanSize(position);
                return 1;
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
 
開發者ID:BittleDragon,項目名稱:RefreshLoadRecyclerview,代碼行數:27,代碼來源:ExcellentRecyclerview.java

示例4: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:guzhigang001,項目名稱:Bailan,代碼行數:18,代碼來源:WrapperUtils.java

示例5: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    mInnerAdapter.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) {
                int viewType = getItemViewType(position);
                if (mHeaderViews.get(viewType) != null) {
                    return gridLayoutManager.getSpanCount();
                } else if (mFooterViews.get(viewType) != null) {
                    return gridLayoutManager.getSpanCount();
                }
                if (spanSizeLookup != null)
                    return spanSizeLookup.getSpanSize(position);
                return 1;
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
 
開發者ID:BittleDragon,項目名稱:MyRepository,代碼行數:27,代碼來源:MultiFunctionalWrapper.java

示例6: getTotalSpanSizeByPosition

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
/**
 * Gets the total number of spans by the position
 *
 * @param manager  The GridLayoutManager
 * @param position The position of Item
 * @return
 */
private int getTotalSpanSizeByPosition(GridLayoutManager manager, int position) {
    int spanTotalSize = 0;
    GridLayoutManager.SpanSizeLookup lookup = manager.getSpanSizeLookup();
    int spanCount = manager.getSpanCount();
    for (int i = 0; i <= position; i++) {
        int spanLookup = lookup.getSpanSize(i);
        spanTotalSize = spanTotalSize + spanLookup;
        if (spanTotalSize >= spanCount) {
            if (spanTotalSize % spanCount != 0) {
                spanTotalSize = spanLookup;
            } else {
                if (spanTotalSize > spanCount) {
                    if (spanTotalSize % spanCount != 0)
                        spanTotalSize = spanTotalSize % spanCount;
                    else
                        spanTotalSize = spanCount;
                }
            }
        }
    }
    return spanTotalSize;
}
 
開發者ID:dkzwm,項目名稱:ItemDecorations,代碼行數:30,代碼來源:GridItemDecoration.java

示例7: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
public static void onAttachedToRecyclerView(RecyclerView recyclerView, final RecyclerView.Adapter adapter, final int pinnedHeaderType) {
    // 如果是網格布局,這裏處理標簽的布局占滿一行
    final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup oldSizeLookup = gridLayoutManager.getSpanSizeLookup();
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                if (adapter.getItemViewType(position) == pinnedHeaderType) {
                    return gridLayoutManager.getSpanCount();
                }
                if (oldSizeLookup != null) {
                    return oldSizeLookup.getSpanSize(position);
                }
                return 1;
            }
        });
    }
}
 
開發者ID:yedashen,項目名稱:UltimateRecyclerView,代碼行數:21,代碼來源:FullSpanUtil.java

示例8: inspectLayoutManager

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
private void inspectLayoutManager(LayoutManager layoutManager) {
    if (layoutManager instanceof GridLayoutManager) {
        GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
        FixedViewSpanSizeLookup fixedViewSpanSizeLookup = null;
        if (spanSizeLookup == null || spanSizeLookup instanceof GridLayoutManager.DefaultSpanSizeLookup) {
            fixedViewSpanSizeLookup = new FixedViewSpanSizeLookup();
            gridLayoutManager.setSpanSizeLookup(fixedViewSpanSizeLookup);
        } else if (spanSizeLookup instanceof FixedViewSpanSizeLookup) {
            fixedViewSpanSizeLookup = (FixedViewSpanSizeLookup) spanSizeLookup;
        }
        if (fixedViewSpanSizeLookup != null) {
            fixedViewSpanSizeLookup.attach(gridLayoutManager, proxyAdapter);
        }
    }
}
 
開發者ID:TakWolf,項目名稱:Android-HeaderAndFooterRecyclerView,代碼行數:17,代碼來源:HeaderAndFooterRecyclerView.java

示例9: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:zuoni1018,項目名稱:CoordinatorLayoutExample-master,代碼行數:20,代碼來源:WrapperUtils.java

示例10: getGroupIndex

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
/**
 * Returns a group index for GridLayoutManager.
 * for LinearLayoutManager, always returns position.
 *
 * @param position current view position to draw divider
 * @param parent   RecyclerView
 * @return group index of items
 */
private int getGroupIndex(int position, RecyclerView parent) {
    if (parent.getLayoutManager() instanceof GridLayoutManager) {
        GridLayoutManager layoutManager = (GridLayoutManager) parent.getLayoutManager();
        GridLayoutManager.SpanSizeLookup spanSizeLookup = layoutManager.getSpanSizeLookup();
        int spanCount = layoutManager.getSpanCount();
        return spanSizeLookup.getSpanGroupIndex(position, spanCount);
    }

    return position;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:FlexibleDividerDecoration.java

示例11: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    mInnerAdapter.onAttachedToRecyclerView(recyclerView);
    //為了兼容GridLayout
    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) {
                int viewType = getItemViewType(position);
                if (mHeaderViews.get(viewType) != null) {
                    return gridLayoutManager.getSpanCount();
                } else if (mFooterViews.get(viewType) != null) {
                    return gridLayoutManager.getSpanCount();
                }
                if (spanSizeLookup != null)
                    return spanSizeLookup.getSpanSize(position);
                return 1;
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }

}
 
開發者ID:GuoZhaoHui628,項目名稱:SliderStatusBar,代碼行數:28,代碼來源:HeaderAndFooterWrapperAdapter.java

示例12: wasDividerAlreadyDrawn

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
/**
 * Determines whether divider was already drawn for the row the item is in,
 * effectively only makes sense for a grid
 *
 * @param position current view position to draw divider
 * @param parent   RecyclerView
 * @return true if the divider can be skipped as it is in the same row as the previous one.
 */
private boolean wasDividerAlreadyDrawn(int position, RecyclerView parent) {
    if (parent.getLayoutManager() instanceof GridLayoutManager) {
        GridLayoutManager layoutManager = (GridLayoutManager) parent.getLayoutManager();
        GridLayoutManager.SpanSizeLookup spanSizeLookup = layoutManager.getSpanSizeLookup();
        int spanCount = layoutManager.getSpanCount();
        return spanSizeLookup.getSpanIndex(position, spanCount) > 0;
    }

    return false;
}
 
開發者ID:Loofer,項目名稱:Watermark,代碼行數:19,代碼來源:FlexibleDividerDecoration.java

示例13: recoverLayoutManager

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
private void recoverLayoutManager(LayoutManager layoutManager) {
    if (layoutManager instanceof GridLayoutManager) {
        GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
        if (spanSizeLookup instanceof FixedViewSpanSizeLookup) {
            gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.DefaultSpanSizeLookup());
            ((FixedViewSpanSizeLookup) spanSizeLookup).detach();
        }
    }
}
 
開發者ID:TakWolf,項目名稱:Android-HeaderAndFooterRecyclerView,代碼行數:11,代碼來源:HeaderAndFooterRecyclerView.java


注:本文中的android.support.v7.widget.GridLayoutManager.getSpanSizeLookup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。