• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SpanSizeLookup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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));
            }
        });
    }
}
 
开发者ID:rubengees,项目名称:easy-header-footer-adapter,代码行数:20,代码来源:EasyHeaderFooterAdapter.java


示例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);
    }

}
 
开发者ID:Ztiany,项目名称:WrapperAdapter,代码行数:17,代码来源:KeepFullSpanHelper.java


示例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);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:28,代码来源:ChannelWallActivity.java


示例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;
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:RcvAdapterWrapper.java


示例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);
        }
    }
}
 
开发者ID:Ztiany,项目名称:WrapperAdapter,代码行数:10,代码来源:KeepFullSpanHelper.java


示例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);
    }
}
 
开发者ID:pushbit,项目名称:sprockets-android,代码行数:34,代码来源:InsetDecoration.java


示例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;
}
 
开发者ID:pushbit,项目名称:sprockets-android,代码行数:15,代码来源:LayoutManagers.java


示例8: InnerSpanSizeLookup

import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; //导入依赖的package包/类
InnerSpanSizeLookup(SpanSizeLookup originSpanSizeLookup, GridLayoutManager gridLayoutManager) {
    mOriginSpanSizeLookup = originSpanSizeLookup;
    mGridLayoutManager = gridLayoutManager;
    mSpanCount = mGridLayoutManager.getSpanCount();
}
 
开发者ID:Ztiany,项目名称:WrapperAdapter,代码行数:6,代码来源:KeepFullSpanHelper.java


示例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);
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:47,代码来源:CategoryTab.java



注:本文中的android.support.v7.widget.GridLayoutManager.SpanSizeLookup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WRITE3Request类代码示例发布时间:2022-05-22
下一篇:
Java XYChart类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap