Git Product home page Git Product logo

hvendlessrecyclerview's Introduction

HVEndlessRecyclerView

该项目是学习如何封装 loadmore 功能时候的实验作品,未投入生产环境测试,如有需要,请移步至 PullRecycler

Easy way implements loadmore

Thanks Cube-Sdk,秋哥的 loadmore 模块真的写得很好!

1.Click 事件支持

    // 支持 Click 事件
    mSampleAdapter.setOnItemClickListener(new OnRcvItemClickListener() {
      @Override public void onItemClick(View v, int position) {
        Toast.makeText(MainActivity.this, "点击事件支持,item position -->>" + position,
            Toast.LENGTH_SHORT).show();
      }
    });
    // 支持 LongClick 事件
    mSampleAdapter.setOnItemLongClickListener(new OnRcvItemLongClickListener() {
      @Override public boolean onItemLongClick(View view, int position) {
        Toast.makeText(MainActivity.this, "长按点击事件支持,item position -->>" + position,
            Toast.LENGTH_SHORT).show();
        return true;
      }
    });

2. 使用默认的 footer

    mRecyclerView.setAdapter(mSampleAdapter);
    mRecyclerView.useDefaultFooter(); // 请在 setAdapter 之后设置默认的 footer

3.加载更多数据

    mRecyclerView.setLoadMoreHandler(new ILoadMoreHandler() {
          @Override public void onLoadMore() {
            simulateLoadMoreData();
        }
      });

4. 加载完成之后,设置状态

  • 内容是否为空

  • 是否有更多数据

/**
   * 
   * @param isEmpty fetch 的数据列表是否为空
   * @param hasMore 是否还有更多数据
   */
  @Override public void onLoadMoreCompleted(boolean isEmpty, boolean hasMore) {
  
  }

5.加载失败

/**
   * 
   * @param errorCode 错误码
   * @param errorMsg 错误信息
   */
  @Override public void onLoadMoreFailed(int errorCode, String errorMsg) {
  
  }

嫌弃我写的 Footer 不好看,你可以自定义 Footer !

/**
 *
 * 对 LoadMoreView 的抽象
 */
public interface ILoadMoreUIHandler {

  // 加载中
  void onLoading();
  // 加载完毕
  void onLoadFinish(boolean isEmpty, boolean hasMore);
  // 加载出错
  void onLoadError(int errorCode, String errorMsg);
  // 等待被点击加载更多
  void onWaitToLoadMore();
}

Tips

具体可以参考 DefaultLoadMoreFooterView 这个栗子

最后,来自笔者的善意,nice footer and header

1.当 LayoutManager 为 LinearLayoutManager

2.当 LayoutManager 为 GridLayoutManager

3.当 LayoutManager 为 StaggeredGridLayoutManager

// 请自行想象...

hvendlessrecyclerview's People

Contributors

hellovass avatar

Stargazers

白言午 avatar  avatar  avatar 谢敏 avatar shraddha avatar  avatar Bakha avatar thomas.ning avatar Bys avatar 王小义 avatar eity0323 avatar Nisarg avatar  avatar  avatar hanmichael avatar  avatar Timmmm avatar yulongsun avatar  avatar Martin avatar  avatar louisgeek avatar Jake Woki avatar yincheng avatar Jungle avatar good luck & have fun! avatar Alex_zheng avatar Hardik Amal avatar  avatar Pranav Lathigara avatar  avatar  avatar  avatar WangPeiyuan avatar yihuxz avatar Yanbo avatar ChenFuduo avatar wen avatar Jing Lu avatar ywzheng avatar 米纳斯少校. avatar Ailurus avatar 李小义 avatar 负雪明烛 avatar Ren  Yu avatar Drakeet avatar zouyingjie avatar  avatar

Watchers

James Cloos avatar Ren  Yu avatar  avatar hanmichael avatar

hvendlessrecyclerview's Issues

problem with glide and picasso

hello,
i use
Glide.with(CONtext).load(ExtraMthd.UPLOADURL + "news/" + prd.id + "/hdr_" + prd.id + ".jpg").asBitmap().placeholder(R.mipmap.no_wifi).into(banner);
in convert but when scroll down and up, image load with a long time to show image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.