XRecyclerView

a RecyclerView that implements pullrefresh and loadingmore featrues.you can use it like a standard RecyclerView

Subscribe to updates I use XRecyclerView


Statistics on XRecyclerView

Number of watchers on Github 3901
Number of open issues 239
Average time to close an issue about 1 month
Main language Java
Average time to merge a PR about 20 hours
Open pull requests 13+
Closed pull requests 2+
Last commit 6 months ago
Repo Created over 2 years ago
Repo Last Updated 4 months ago
Size 6.35 MB
Organization / Authorxrecyclerview
Contributors2
Page Updated
Do you use XRecyclerView? Leave a review!
View open issues (239)
View XRecyclerView activity
View on github
Latest Open Source Launches
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating XRecyclerView for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

XRecyclerView

a RecyclerView that implements pullrefresh , loadingmore and header featrues.you can use it like a standard RecyclerView. you don't need to implement a special adapter .qq 478803619

Screenshots

demo

on real device it is much more smoother.

Usage

gradle

// 1.5.9 is the main
compile 'com.jcodecraeer:xrecyclerview:1.5.9'

just like a standard RecyclerView

LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setAdapter(mAdapter);

pull to refresh and load more

the pull to refresh and load more featrue is enabled by default. we provide a callback to trigger the refresh and LoadMore event.

 mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
    @Override
    public void onRefresh() {
       //refresh data here
    }

    @Override
    public void onLoadMore() {
       // load more data here
    }
});

new function of 1.5.7 version.

mRecyclerView
    .getDefaultRefreshHeaderView() // get default refresh header view
    .setRefreshTimeVisible(true);  // make refresh time visible,false means hiding

// if you are not sure that you are 100% going to
// have no data load back from server anymore,do not use this
@Deprecated
public void setEmptyView(View emptyView) {
    ...
}

new function of 1.5.6 version,fixed a memory leak problem,use the code below to release XR's memory

// any time,when you finish your activity or fragment,call this below
if(mRecyclerView != null){
    mRecyclerView.destroy(); // this will totally release XR's memory
    mRecyclerView = null;
}

new function of 1.5.3 version,you can use XR in the sticky scroll model now,like the code below,the demo activity is 'LinearStickyScrollActivity'

final View topView = findViewById(R.id.topView);
final View tabView = findViewById(R.id.tabView);
final View content = findViewById(R.id.contentView);

final StickyScrollLinearLayout s = findViewById(R.id.StickyScrollLinearLayout);
s.addOnLayoutChangeListener(
        new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                if(s.getContentView() != null)
                    return;
                //  height  =0
                // add from here just in case they height==0
                s.setInitInterface(
                        new StickyScrollLinearLayout.StickyScrollInitInterface() {
                            @Override
                            public View setTopView() {
                                return topView;
                            }

                            @Override
                            public View setTabView() {
                                return tabView;
                            }

                            @Override
                            public View setContentView() {
                                return content;
                            }
                        }
                );
            }
        }
);

call notifyItemRemoved or notifyItemInserted, remember to use the functions inside XRecyclerView

listData.remove(pos);
mRecyclerView.notifyItemRemoved(listData,pos);

and of course you have to tell our RecyclerView when the refreshing or loading more work is done. you can use

mRecyclerView.loadMoreComplete();

to control when the item number of the screen is list.size-2,we call the onLoadMore

mRecyclerView.setLimitNumberToCallLoadMore(2); // default is 1

to notify that the loading more work is done. and

 mRecyclerView.refreshComplete();

to notify that the refreshing work is done.

here is what we get:

default

call refresh() manually(I change the previous setRefreshing() method to refresh() )

mRecyclerView.refresh();

custom refresh and loading more style

pull refresh and loading more style is highly customizable.

custom loading style

the loading effect we use the AVLoadingIndicatorView . and it is built in(make a little change). we provide all the effect in AVLoadingIndicatorView library besides we add a system style. you can call

mRecyclerView.setRefreshProgressStyle(int style);

and

mRecyclerView.setLaodingMoreProgressStyle(int style);

to set the RefreshProgressStyle and LaodingMoreProgressStyle respectively.

for example

mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);

refreshloadingballspinfade

mRecyclerView.setLaodingMoreProgressStyle(ProgressStyle.SquareSpin);

loadingmoresquarespin

BallPulse effect

BallPulse

all the effect can be get in the ProgressStyle class

public class ProgressStyle {
    public static final int SysProgress=-1;
    public static final int BallPulse=0;
    public static final int BallGridPulse=1;
    public static final int BallClipRotate=2;
    public static final int BallClipRotatePulse=3;
    public static final int SquareSpin=4;
    public static final int BallClipRotateMultiple=5;
    public static final int BallPulseRise=6;
    public static final int BallRotate=7;
    public static final int CubeTransition=8;
    public static final int BallZigZag=9;
    public static final int BallZigZagDeflect=10;
    public static final int BallTrianglePath=11;
    public static final int BallScale=12;
    public static final int LineScale=13;
    public static final int LineScaleParty=14;
    public static final int BallScaleMultiple=15;
    public static final int BallPulseSync=16;
    public static final int BallBeat=17;
    public static final int LineScalePulseOut=18;
    public static final int LineScalePulseOutRapid=19;
    public static final int BallScaleRipple=20;
    public static final int BallScaleRippleMultiple=21;
    public static final int BallSpinFadeLoader=22;
    public static final int LineSpinFadeLoader=23;
    public static final int TriangleSkewSpin=24;
    public static final int Pacman=25;
    public static final int BallGridBeat=26;
    public static final int SemiCircleSpin=27;
}

refresh arrow icon

we provide a default arrow icon:

ic_pulltorefresh_arrow

but if you don't like it,you can replace it with any other icon you want. just call

mRecyclerView.setArrowImageView(R.drawable.iconfont_downgrey);

customarrow

disable refresh and load more featrue

if you don't want the refresh and load more featrue(in that case,you probably dont'n need the lib neither),you can call

mRecyclerView.setPullRefreshEnabled(false);

and

mRecyclerView.setPullRefreshEnabled(true);

in which false means disabled ,true means enabled.

Header

you can add header to XRecyclerViewjust call addHeaderView().

View header =   LayoutInflater.from(this).inflate(R.layout.recyclerview_header, (ViewGroup)findViewById(android.R.id.content),false);
mRecyclerView.addHeaderView(header);

if you like ,you can add two header

View header =   LayoutInflater.from(this).inflate(R.layout.recyclerview_header, (ViewGroup)findViewById(android.R.id.content),false);
View header1 =   LayoutInflater.from(this).inflate(R.layout.recyclerview_header1, (ViewGroup)findViewById(android.R.id.content),false);
mRecyclerView.addHeaderView(header);
mRecyclerView.addHeaderView(header1);

License

Copyright 2015 jianghejie

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
XRecyclerView open issues Ask a question     (View All Issues)
  • over 1 year 为什么compile导入的包和github下载的包的代码不一样?没更新吗?
  • over 1 year the interface getLayoutPosition of ViewHolder doesn't return the right value
  • over 1 year 请问可否去掉下拉刷新的弹性下拉效果
  • over 1 year XRecyclerView 使用 notifyItemChanged 会闪的原因,以及解决方法
  • over 1 year XRecyclerView getItemViewType position 从-1 开始,简直无情,附带解决方法
  • over 1 year 适配器的getItemViewType()中的position出现负值
  • over 1 year 发现XRecyclerView没有下传setSpanSizeLookup
  • over 1 year 上次更新时间无法显示
  • over 1 year 这个库还在维护的吗?无意中看到有人使用发现的bug
  • almost 2 years 这个支持其他view的下拉刷新吗?
  • almost 2 years 底部留白
  • almost 2 years 集成到Eclipse中的时候,v7和v4包冲突,怎么解决啊?
  • almost 2 years 能添加items的添加删除滑动动画就很好了,就不必再添加其他的库了
  • almost 2 years 我想知道 我想改变下字体颜色 改怎么改 为什么许多方法 都是私有的 还不对外提供扩展
  • almost 2 years 能不能支持下自定义动画头部的类似于美团的那种刷新动画
  • almost 2 years setRefreshProgressStyle有内存泄露
  • almost 2 years 关于setRefreshing(true)
  • almost 2 years 不重写getAdapter() 出现的ClassCastException
  • almost 2 years item 重复点击
  • almost 2 years 连续上拉加载时,程序会crash
  • almost 2 years 自动刷新,setRefreshing(true) 不起作用
  • almost 2 years 添加了Header之后position返回的值不是从0开始,设置点击事件数组越界
  • almost 2 years Toolbar配合的CoordinatorLayout的layout_behavior,Toolbar无法滑动下来
  • almost 2 years 下拉刷新时间不显示?上拉加载无提示?
  • almost 2 years 不使用加载更多时仍然会空出一个item
  • almost 2 years 怎么去掉下拉刷新的文字显示?看了下代码好像没有接口
  • almost 2 years 高度未超过一屏,上拉不回调onLoadMore
  • almost 2 years 为RecyclerView 添加分割线 第一条分割线在顶部
  • almost 2 years 上拉加载过快,动画没有销毁引起的bug
  • almost 2 years 为何设置刷新和加载更多的style没有效果。
XRecyclerView open pull requests (View All Pulls)
  • Update XRecyclerView.java
  • 添加支持 : 上次更新时间
  • 添加了支持横向刷新和加载
  • 自定义下拉刷新头部样式
  • 解决issue#164 Android Studio 预览错误 Couldn't resolve resource @id/listvie…
  • add alpha change listener
  • 修复GridLayoutManager布局下setSpanSizeLookup失效问题
  • 解决内存泄漏:动画依赖context导致的泄漏以及footView的泄漏
  • Allow custom header texts
  • 仿微信通讯录
  • Update README.md
  • // 增加自定义加载完成页面的功能,并在sample中实现
  • 修复事件的不连续导致的自动滚动
XRecyclerView list of languages used
Other projects in Java