当前位置: 首页>>代码示例>>Java>>正文


Java LRecyclerViewAdapter.setSpanSizeLookup方法代码示例

本文整理汇总了Java中com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter.setSpanSizeLookup方法的典型用法代码示例。如果您正苦于以下问题:Java LRecyclerViewAdapter.setSpanSizeLookup方法的具体用法?Java LRecyclerViewAdapter.setSpanSizeLookup怎么用?Java LRecyclerViewAdapter.setSpanSizeLookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter的用法示例。


在下文中一共展示了LRecyclerViewAdapter.setSpanSizeLookup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sample_ll_activity);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mRecyclerView = (LRecyclerView) findViewById(R.id.list);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this,2));

    mVisitables = getData();
    mMainAdapter = new MainAdapter(new ListTypeFactory(), mVisitables);
    mLRecyclerViewAdapter = new LRecyclerViewAdapter(mMainAdapter);
    mRecyclerView.setAdapter(mLRecyclerViewAdapter);

    mLRecyclerViewAdapter.setSpanSizeLookup(new LRecyclerViewAdapter.SpanSizeLookup() {
        @Override
        public int getSpanSize(GridLayoutManager gridLayoutManager, int position) {
            Object item = mVisitables.get(position);
            return (item instanceof HotList || item instanceof ProductList || item instanceof Category) ? gridLayoutManager.getSpanCount() : 1;
        }
    });

    mLRecyclerViewAdapter.addHeaderView(new SampleHeader(this));

    mRecyclerView.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mRecyclerView.refreshComplete(10);
                }
            },1000);
        }
    });

    mRecyclerView.refresh();
    mRecyclerView.setLoadMoreEnabled(false);
    //是否允许嵌套滑动
    mRecyclerView.setNestedScrollingEnabled(false);

}
 
开发者ID:jdsjlzx,项目名称:LRecyclerView,代码行数:45,代码来源:BilibiliActivity.java

示例2: onCreate

import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sample_ll_activity);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mRecyclerView = (LRecyclerView) findViewById(R.id.list);
    mRecyclerView.setNestedScrollingEnabled(false);

    mShopAdapter = new ShopAdapterBase(this,mGoodsList);

    //setLayoutManager must before setAdapter
    GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
    mRecyclerView.setLayoutManager(layoutManager);

    initData();

    mLRecyclerViewAdapter = new LRecyclerViewAdapter(mShopAdapter);
    mRecyclerView.setAdapter(mLRecyclerViewAdapter);
    mShopAdapter.addAll(mItemModels);

    DividerDecoration divider = new DividerDecoration.Builder(this)
            .setHeight(R.dimen.default_divider_height)
            .setPadding(R.dimen.default_divider_padding)
            .setColorResource(R.color.split)
            .build();

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.addItemDecoration(divider);

    mLRecyclerViewAdapter.setSpanSizeLookup(new LRecyclerViewAdapter.SpanSizeLookup() {
        @Override
        public int getSpanSize(GridLayoutManager gridLayoutManager, int position) {
            MultipleItem item = mShopAdapter.getDataList().get(position);
            if (item.getItemType() == MultipleItem.LIST) {
                return gridLayoutManager.getSpanCount();
            } else {
                return 1;
            }

        }
    });

    mLRecyclerViewAdapter.addHeaderView(new SampleHeader(this));

    mRecyclerView.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mRecyclerView.refreshComplete(10);
                }
            },1000);
        }
    });

    mRecyclerView.refresh();

    //是否允许嵌套滑动
    mRecyclerView.setNestedScrollingEnabled(false);

}
 
开发者ID:jdsjlzx,项目名称:LRecyclerView,代码行数:66,代码来源:Nest2RecyclerViewActivity.java


注:本文中的com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter.setSpanSizeLookup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。