本文整理汇总了Java中android.support.v7.widget.GridLayoutManager.SpanSizeLookup类的典型用法代码示例。如果您正苦于以下问题:Java SpanSizeLookup类的具体用法?Java SpanSizeLookup怎么用?Java SpanSizeLookup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpanSizeLookup类属于android.support.v7.widget.GridLayoutManager包,在下文中一共展示了SpanSizeLookup类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initLayoutManager
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
private void initLayoutManager(final RecyclerView.LayoutManager layoutManager) {
this.layoutManager = layoutManager;
if (layoutManager instanceof GridLayoutManager) {
final GridLayoutManager castedLayoutManager = (GridLayoutManager) layoutManager;
final SpanSizeLookup existingLookup = castedLayoutManager.getSpanSizeLookup();
castedLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (isHeader(position) || isFooter(position)) {
return castedLayoutManager.getSpanCount();
}
return existingLookup.getSpanSize(getRealPosition(position));
}
});
}
}
示例2: setFullSpanForGird
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
void setFullSpanForGird(GridLayoutManager gridLayoutManager) {
SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
if (mOriginSpanSizeLookup == spanSizeLookup) {//first in
if (mInnerSpanSizeLookup == null) {
mInnerSpanSizeLookup = new InnerSpanSizeLookup(mOriginSpanSizeLookup, gridLayoutManager);
}
gridLayoutManager.setSpanSizeLookup(mInnerSpanSizeLookup);
return;
}
if (mInnerSpanSizeLookup != spanSizeLookup) {//spanSizeLookup is new
mOriginSpanSizeLookup = spanSizeLookup;
mInnerSpanSizeLookup = new InnerSpanSizeLookup(mOriginSpanSizeLookup, gridLayoutManager);
gridLayoutManager.setSpanSizeLookup(mInnerSpanSizeLookup);
}
}
示例3: init
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
private void init() {
GridLayoutManager manager = new GridLayoutManager(this, 4);
this.mRecyclerView.setLayoutManager(manager);
ItemTouchHelper helper = new ItemTouchHelper(new ItemDragHelperCallback());
helper.attachToRecyclerView(this.mRecyclerView);
this.mAdapter = new ChannelFragmentAdapter(this, helper, this.mChannelListBean, this.mRecyclerView);
this.mAdapter.setFrom(this.mFromMineCustom);
manager.setSpanSizeLookup(new SpanSizeLookup(this) {
final /* synthetic */ ChannelWallActivity this$0;
{
if (HotFix.PREVENT_VERIFY) {
System.out.println(VerifyLoad.class);
}
this.this$0 = this$0;
}
public int getSpanSize(int position) {
int viewType = this.this$0.mAdapter.getItemViewType(position);
if (viewType == 2 || viewType == 1) {
return 1;
}
return 4;
}
});
this.mRecyclerView.setAdapter(this.mAdapter);
}
示例4: setSpanSizeLookup
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
static void setSpanSizeLookup(final Adapter adapter, final GridLayoutManager layoutManager) {
layoutManager.setSpanSizeLookup(new SpanSizeLookup() {
public int getSpanSize(int position) {
int type = adapter.getItemViewType(position);
if (type == RcvAdapterWrapper.TYPE_HEADER || type == RcvAdapterWrapper.TYPE_FOOTER) {
return layoutManager.getSpanCount();
}
return 1;
}
});
}
示例5: cleanFullSpanIfNeed
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
void cleanFullSpanIfNeed(RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
SpanSizeLookup spanSizeLookup = ((GridLayoutManager) layoutManager).getSpanSizeLookup();
if (spanSizeLookup == mInnerSpanSizeLookup) {
((GridLayoutManager) layoutManager).setSpanSizeLookup(mOriginSpanSizeLookup);
}
}
}
示例6: getItemOffsets
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
@Override
public void getItemOffsets(Rect rect, View view, RecyclerView parent, State state) {
int pos = parent.getChildLayoutPosition(view);
if (pos == NO_POSITION) {
return;
}
int items = state.getItemCount();
int spans = LayoutManagers.getSpanCount(parent);
SpanSizeLookup lookup = LayoutManagers.getSpanSizeLookup(parent);
/* vertical orientation terminology, mentally swap "row" and "col[umn]" for horizontal */
int row = lookup.getSpanGroupIndex(pos, spans);
int col = lookup.getSpanIndex(pos, spans);
int nextCol = col + lookup.getSpanSize(pos);
boolean row1 = row == 0;
boolean rowN = pos == items - 1 || row == lookup.getSpanGroupIndex(items - 1, spans);
boolean col1 = col == 0;
boolean col2 = col == 1;
boolean col2N = nextCol == spans - 1;
boolean colN = nextCol == spans;
rect.top = row1 ? 0 : mHalf;
rect.bottom = rowN ? 0 : mHalf;
if (spans <= 2) {
rect.left = col1 ? 0 : mHalf;
rect.right = colN ? 0 : mHalf;
} else { // inset first and last columns more to keep all items same size
rect.left = col1 ? 0 : col2 ? mThird : colN ? mTwoThirds : mHalf;
rect.right = col1 && !colN ? mTwoThirds : col2N ? mThird : colN ? 0 : mHalf;
}
if (LayoutManagers.getOrientation(parent) == HORIZONTAL) { // rotate
//noinspection SuspiciousNameCombination
rect.set(rect.top, rect.left, rect.bottom, rect.right);
}
}
示例7: getSpanSizeLookup
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
/**
* If the RecyclerView uses a {@link GridLayoutManager}, get its SpanSizeLookup. Otherwise get a
* {@link DefaultSpanSizeLookup DefaultSpanSizeLookup}.
*/
public static SpanSizeLookup getSpanSizeLookup(RecyclerView view) {
LayoutManager layout = view.getLayoutManager();
if (layout instanceof GridLayoutManager) {
return ((GridLayoutManager) layout).getSpanSizeLookup();
}
if (sDefSpanSizeLookup == null) {
sDefSpanSizeLookup = new DefaultSpanSizeLookup();
}
return sDefSpanSizeLookup;
}
示例8: InnerSpanSizeLookup
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
InnerSpanSizeLookup(SpanSizeLookup originSpanSizeLookup, GridLayoutManager gridLayoutManager) {
mOriginSpanSizeLookup = originSpanSizeLookup;
mGridLayoutManager = gridLayoutManager;
mSpanCount = mGridLayoutManager.getSpanCount();
}
示例9: getView
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
public final View getView(int paramInt)
{
if (this.mCategoryView == null)
{
this.mCategoryView = ((ViewGroup)this.mLayoutInflater.inflate(2130968662, null));
this.mRecyclerView = ((PlayRecyclerView)this.mCategoryView.findViewById(2131755329));
this.mRecyclerView.setVisibility(0);
if (!FinskyApp.get().getExperiments().isH20StoreEnabled()) {
break label272;
}
final CategoryAdapterV2 localCategoryAdapterV2 = new CategoryAdapterV2(this.mContext, this.mCategories, this.mNavigationManager, paramInt, this.mToc, this.mBitmapLoader, this.mQuickLinksV2, this.mQuickLinksV2Title, this.mCategoriesTitle, this.mTabMode, this.mParentNode);
this.mCategoryAdapter = localCategoryAdapterV2;
if (this.mRestoredInstanceState.containsKey("CategoryTab.AdapterInstanceState"))
{
ObjectMap localObjectMap = (ObjectMap)this.mRestoredInstanceState.get("CategoryTab.AdapterInstanceState");
if (localObjectMap != null) {
localCategoryAdapterV2.mQuickLinksInstanceState = ((Bundle)localObjectMap.get("CategoryAdapterV2.QuickLinksViewState"));
}
}
GridLayoutManager localGridLayoutManager = new GridLayoutManager(this.mContext);
this.mRecyclerView.setLayoutManager(localGridLayoutManager);
localGridLayoutManager.mSpanSizeLookup = new GridLayoutManager.SpanSizeLookup()
{
public final int getSpanSize(int paramAnonymousInt)
{
if (localCategoryAdapterV2.displayViewInTwoColumns(paramAnonymousInt)) {
return 1;
}
return 2;
}
};
this.mRecyclerView.addItemDecoration(new GridMarginItemDecoration(localCategoryAdapterV2));
this.mRecyclerView.addItemDecoration(new CardLookDecoration(this.mContext));
}
for (;;)
{
this.mRecyclerView.setAdapter(this.mCategoryAdapter);
if (this.mRestoredInstanceState.containsKey("CategoryTab.RecyclerViewState")) {
this.mRecyclerView.restoreInstanceState((Parcelable)this.mRestoredInstanceState.get("CategoryTab.RecyclerViewState"));
}
return this.mCategoryView;
label272:
this.mRecyclerView.setLayoutManager(new LinearLayoutManager());
this.mCategoryAdapter = new CategoryAdapter(this.mContext, this.mCategories, this.mNavigationManager, paramInt, this.mToc, this.mBitmapLoader, this.mQuickLinks, this.mTabTitle, this.mTabMode, this.mParentNode);
}
}