• Stars
    star
    377
  • Rank 113,535 (Top 3 %)
  • Language
    Java
  • Created about 9 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A RecyclerView library for Android which support pull-to-refresh ,auto-load-more and add header.

Android-PullToRefreshRecyclerView

This is a project based on RecyclerView with pull-to-refresh feature.

It support addding Header, auto-loading more data when scrolling to bottom.

It can help you to implement ListView effect in RecyclerView, and not affect exsiting RecyclerView and Adapter logic.

Screenshot

Latest version:v1.3.1

How to make custom LoadMoreView, see 'DemoLoadMoreView.class' in demo project.

Feature

  • Encapsulation based on native RecyclerView
  • Pull-to-refresh
  • Auto load when scrolling to the bottom
  • Most API of like ListView's
  • Add Header easily (Not supported by native RecyclerView)
  • Support EmptyView settings
  • Current LayoutManager supported:
    • LinearLayoutManager
    • GridLayoutManager

Project site: https://github.com/HomHomLin/Android-PullToRefreshRecyclerView.

Sample

There has a Sample in project:Sample

##Using library in your application

Gradle dependency:

compile 'homhomlin.lib:ptrrv-library:1.3.1'

or

Maven dependency:

<dependency>
	<groupId>homhomlin.lib</groupId>
	<artifactId>ptrrv-library</artifactId>
	<version>1.3.1</version>
</dependency>

If you want your application work on Android 2.x, you should add this in your gradle :

compile 'com.nineoldandroids:library:2.4.0'

##Usage

PullToRefreshRecyclerView is easy to use just like ListView and RecyclerView. It is derived from native SwipeRefreshLayout, so all property of SwipeRefreshLayout can be used here.

See Sample for detail.

First: Config in xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.lhh.ptrrv.library.PullToRefreshRecyclerView
        android:id="@+id/ptrrv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

Second: Find it in your Activity

PullToRefreshRecyclerView mPtrrv = (PullToRefreshRecyclerView) this.findViewById(R.id.ptrrv);

Third: Config it in java code

// custom own load-more-view and add it into ptrrv
DemoLoadMoreView loadMoreView = new DemoLoadMoreView(this, mPtrrv.getRecyclerView());
loadMoreView.setLoadmoreString(getString(R.string.demo_loadmore));
loadMoreView.setLoadMorePadding(100);

mPtrrv.setLoadMoreFooter(loadMoreView);

//remove header
mPtrrv.removeHeader();

// set true to open swipe(pull to refresh, default is true)
mPtrrv.setSwipeEnable(true);

// set the layoutManager which to use
mPtrrv.setLayoutManager(new LinearLayoutManager(this));

// set PagingableListener
mPtrrv.setPagingableListener(new PullToRefreshRecyclerView.PagingableListener() {
    @Override
    public void onLoadMoreItems() {
        //do loadmore here
    }
});

// set OnRefreshListener
mPtrrv.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
        // do refresh here
    }
});

// add item divider to recyclerView
mPtrrv.getRecyclerView().addItemDecoration(new DividerItemDecoration(this,
        DividerItemDecoration.VERTICAL_LIST));

// add headerView
mPtrrv.addHeaderView(View.inflate(this, R.layout.header, null));

//set EmptyVIEW
mPtrrv.setEmptyView(View.inflat(this,R.layout.empty_view, null));

// set loadmore String
mPtrrv.setLoadmoreString("loading");

// set loadmore enable, onFinishLoading(can load more? , select before item)
mPtrrv.onFinishLoading(true, false);

Finally: Set the adapter which extends RecyclerView.Adpater

PtrrvAdapter mAdapter = new PtrrvAdapter(this);
mPtrrv.setAdapter(mAdapter);

##License Copyright 2015 LinHongHong

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.

More Repositories

1

SlidingLayout

实现类似微信WebView的上拉下拉弹跳效果和iOS的ListView的果冻效果。
Java
627
star
2

AdvancedPagerSlidingTabStrip

Android AdvancedPagerSlidingTabStrip是一种Android平台的导航控件,完美兼容Android自带库和兼容库的ViewPager组件。
Java
413
star
3

Android-DivergeView

仿美拍直播的点赞动画。
Java
289
star
4

FrescoImageView

FrescoImageView是一种Android平台的图像控件,可以异步加载网络图片、项目资源和本地图片,并且支持双指缩放、图片的基本处理以及Fresco的所有特性。
Java
167
star
5

Android-ParallaxSupportView

Android-ParallaxSupportView是一种Android平台的动态视觉差控件,支持N个任意View的视觉差效果。
Java
69
star
6

Dilutions

美柚公司出品的跨模块协议框架,经过亿万用户的测试
Java
27
star
7

Android-TaobaoAnimtor

淘宝购物车动画。
Java
12
star
8

Anna

Java
9
star
9

DexWalila-Java

瓦莉拉是一个能处理Dex的插件,他能控制主DEX的内容,完美解决主DEX 65535的问题。
Java
6
star
10

Android-EmojiBoard

Java
5
star
11

MeiwuFramework

This is an Android application's develop framework which develop by myself, it could help you create an Android application which contain HTTP connect helper, view helper, log and os-helper easily.
Java
5
star
12

LgameDemo

Lgame游戏引擎和OpenGL制作的斗鱼礼物动画demo。
Java
5
star
13

Assassin

Java
4
star
14

GradlePublishing

3
star
15

Gradle-Publish

2
star
16

GetKeyboardHeight

获得键盘高度的测试demo。
Java
2
star
17

MultiPacketShell

Mac和Linux下的多渠道打包shell
Shell
1
star
18

UniversalTextView

Java
1
star
19

EmojiView

Java
1
star
20

MacShellLearn

1
star
21

Android-TouchMenu

Java
1
star
22

Android-RefreshLayout

Java
1
star
23

AndroidEmanteAnimtor

[DEPRECATED]
Java
1
star
24

Blackhand

Groovy
1
star
25

Winter

Android performance monitoring tool
Java
1
star