A pull to refresh layout for android, the RecyclerRefreshLayout is based on the SwipeRefreshLayout. support all the views, highly customizable, code simplicity, etc. really a practical RefreshLayout!

Overview

RecyclerRefreshLayout

Android Arsenal

English | 中文版

RecyclerRefreshLayout based on the {@link android.support.v4.widget.SwipeRefreshLayout} The RecyclerRefreshLayout should be used whenever the user can refresh the contents of a view via a vertical swipe gesture. The activity that instantiates this view should add an OnRefreshListener to be notified whenever the swipe to refresh gesture is completed. The RecyclerRefreshLayout will notify the listener each and every time the gesture is completed again; the listener is responsible for correctly determining when to actually initiate a refresh of its content. If the listener determines there should not be a refresh, it must call setRefreshing(false) to cancel any visual indication of a refresh. If an activity wishes to show just the progress animation, it should call setRefreshing(true). To disable the gesture and progress animation, call setEnabled(false) on the view.

Note: The RecyclerRefreshLayout supports all of the views: ListView, GridView, ScrollView, FrameLayout, or Even a single TextView



Installation

Add the following dependency to your build.gradle file:

    dependencies {
        compile 'com.dinuscxj:recyclerrefreshlayout:2.0.5'
    }

Usage

Config in xml

<?xml version="1.0" encoding="utf-8"?>
<com.dinuscxj.refresh.RecyclerRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/refresh_layout"
 android:layout_width="match_parent"
 android:layout_height="match_parent">
 <android.support.v7.widget.RecyclerView
     android:id="@+id/recycler_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent" />
</app.dinus.com.refresh.RecyclerRefreshLayout>

Configure the attributes(* must)

Set the listener to be notified when a refresh is triggered via the swipe gesture.

RecyclerRefreshLayout.setOnRefreshListener(OnRefreshListener);

Notify the widget that refresh state has changed. Do not call this when refresh is triggered by a swipe gesture.

RecyclerRefreshLayout.setRefreshing(boolean);

Configure the attributes(optional)

Set the interpolator used by the animation that move the refresh view the release point to the refreshing point.

RecyclerRefreshLayout.setAnimateToRefreshInterpolator(Interpolator);

Set the interpolator used by the animation that move the refresh view from the refreshing point or (the release point) to the start point.

RecyclerRefreshLayout.setAnimateToStartInterpolator(Interpolator);

Set the duration used by the animation that move the refresh view the release point to the refreshing point.

RecyclerRefreshLayout.setAnimateToRefreshDuration(int);

Set the duration used by the animation that move the refresh view from the refreshing point or (the release point) to the start point.

RecyclerRefreshLayout.setAnimateToStartDuration(int);

Set the top position of the RefreshView relative to its parent.

RecyclerRefreshLayoutsetRefreshInitialOffset(float)

Set The minimum distance that trigger refresh

RecyclerRefreshLayout.setRefreshTargetOffset(float)

Set the style of the RefreshView

RecyclerRefreshLayout.setRefreshStyle(@NonNull RefreshStyle) 

Customize

Customize a refresh view (need to implements IRefreshStatus) for RecyclerRefreshLayout.

public interface IRefreshStatus {
/**
* When the content view has reached top and refresh has been completed, view will be reset.
*/
void reset();
/**
* Refresh View is refreshing
*/
void refreshing();
/**
* Refresh View is dropped down to the refresh point
*/
void pullToRefresh();
/**
* Refresh View is released into the refresh point
*/
void releaseToRefresh();
/**
* @param pullDistance The drop-down distance of the refresh View
* @param pullProgress The drop-down progress of the refresh View and the pullProgress may be more than 1.0f
*                     pullProgress = pullDistance / refreshTargetOffset
*/
void pullProgress(float pullDistance, float pullProgress);
}
RecyclerRefreshLayout.setRefreshView(View, LayoutParams);

Eg. RefreshView or RefreshViewEg

Customize a drag distance converter (need to implements IDragDistanceConverter) for RecyclerRefreshLayout.

public interface IDragDistanceConverter {
 /**
  * @param scrollDistance the distance between the ACTION_DOWN point and the ACTION_MOVE point
  * @param refreshDistance the distance between the refresh point and the start point
  * @return the real distance of the refresh view moved
  */
 float convert(float scrollDistance, float refreshDistance);
}
RecyclerRefreshLayout.setDragDistanceConverter(@NonNull IDragDistanceConverter) 

Eg. MaterialDragDistanceConverter or DragDistanceConverterEg

Misc

QQ Group: 342748245

License

Copyright 2015-2019 dinus

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.
Comments
  • 为什么在我写的demo里。会出现这种情况

    为什么在我写的demo里。会出现这种情况

    设置自动刷新setRefreshing(true),不回调onRefresh方法,还有就是RefreshView不设置pinned紧贴底部,设置pinned紧贴顶部,然而在你给出的demo里,没有我说的这种情况,我也仔细看了你给出的demo。发现也没有什么不同之处,唯一不同就是adapter我用了这个库https://github.com/CymChad/BaseRecyclerViewAdapterHelper, 麻烦在百忙之中,看看能否帮我只个招。提前谢谢了。

    opened by YangShaoXiong 5
  • 加载成功网络数据后刷新UI的处理不友好

    加载成功网络数据后刷新UI的处理不友好

    感谢大神贡献如此强大易用的库。之所以说刷新UI处理的不友好,是因为当网络请求回调不是在ItemInteractionListener类中的时候无法正确地刷新UI。

    demo中当网络请求成功返回时,是通过ItemInteractionListener.super.requestRefresh();来刷新UI的,但是如果当网络请求不是在ItemInteractionListener这个类中实现的时候刷新的操作就无法正常执行。 即便声明了一个全局变量,

    private ItemInteractionListener itemInteractionListener = new ItemInteractionListener();
    

    也不行。

    相信很多人都不是把网络请求写在ItemInteractionListener这个类中的,@dinuscxj 能否给些修改的提示呢?

    opened by loganguo 2
  • 不能像SwipeRefreshLayout一样主动把刷新效果post出来吗

    不能像SwipeRefreshLayout一样主动把刷新效果post出来吗

    像这样 mRecyclerRefreshLayout.post(new Runnable() {
                    @Override
                    public void run() {
                        mRecyclerRefreshLayout.setRefreshing(true);
                    }
                });
    
    opened by junchenChow 2
  • Please help

    Please help

    Hi, your apk cleapup was preinstalled on my mx9 pro TV box. I have now upgraded to mecool km9 pro. Android certified box and wanted to use your apk on that box since it doesn't have any app to kill all running apps. I was able to extract the apk com.charon.rocketfly.apk but it doesn't get installed. Can you help please. The box has official android PIE version.

    opened by imurreflection 1
  • NPE in RecyclerRefreshLayout$1.applyTransformation

    NPE in RecyclerRefreshLayout$1.applyTransformation

    java.lang.NullPointerException at com.dinuscxj.refresh.RecyclerRefreshLayout$1.applyTransformation(RecyclerRefreshLayout.java:122) at android.view.animation.Animation.initializeInvalidateRegion(Animation.java:1047) at android.view.View.drawAnimation(View.java:14210) at android.view.View.draw(View.java:14359)

    opened by alexander-nikolaev 1
  • removeFooterView和addFooterView方法不能改变footer样式

    removeFooterView和addFooterView方法不能改变footer样式

    调用DefaultTipsHelper中的getHeaderAdapter().removeFooterView方法时出现问题。 DefaultTipsHelper中的showHasMore方法用来显示加载中的样式,我想新增一种样式用来显示“没有更多数据了”比如叫showNoMore,参考DefaultTipsHelper中的实现,showNoMore中的具体实现是:

    • mFragment.getHeaderAdapter().removeFooterView(mLoadingView);
    • mFragment.getHeaderAdapter().addFooterView(mNoMoreView); 但是页面仍然显示的是mLoadingView,为什么mNoMoreView显示不出来呢?

    另外,调用removeAllFooterView也无效。

    错误日志是

    cn.com.something.ui.adapter.RecyclerListAdapter$ViewHolderFactory.onCreateViewHolder(android.view.ViewGroup)' on a null object reference
    W/System.err( 2855): 	at cn.com.something.ui.adapter.RecyclerListAdapter.onCreateViewHolder(RecyclerListAdapter.java:30)
    W/System.err( 2855): 	at cn.com.something.ui.adapter.RecyclerListAdapter.onCreateViewHolder(RecyclerListAdapter.java:10)
    W/System.err( 2855): 	at cn.com.something.ui.adapter.HeaderViewRecyclerAdapter.onCreateViewHolder(HeaderViewRecyclerAdapter.java:63)
    W/System.err( 2855): 	at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6073)
    W/System.err( 2855): 	at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5243)
    W/System.err( 2855): 	at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5153)
    W/System.err( 2855): 	at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2061)
    W/System.err( 2855): 	at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1445)
    W/System.err( 2855): 	at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1408)
    W/System.err( 2855): 	at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:580)
    W/System.err( 2855): 	at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3374)
    W/System.err( 2855): 	at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3183)
    W/System.err( 2855): 	at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3627)
    
    opened by loganguo 1
  • The design of tips is too complex  to understand

    The design of tips is too complex to understand

    the show and hide of the tipview is so complicated, every action of tip take serversal inovke.I think it should be simplified. Maybe remove the tipview will reduce the use the of system's resource when it should be hidden,but the the cost of let it visible or invisible is as same as add view or remove view frequently,I think.

    opened by yummyChina 1
  • Fragment SimpleItemRecyclerFragment{6fb84bc} not attached to Activity

    Fragment SimpleItemRecyclerFragment{6fb84bc} not attached to Activity

    Process: app.dinus.com.recyclerrefreshlayout, PID: 31521 java.lang.IllegalStateException: Fragment SimpleItemRecyclerFragment{6fb84bc} not attached to Activity at android.support.v4.app.Fragment.getResources(Fragment.java:636) at android.support.v4.app.Fragment.getString(Fragment.java:658) at app.dinus.com.example.simplerefresh.SimpleItemRecyclerFragment.responseItemList(SimpleItemRecyclerFragment.java:96) at app.dinus.com.example.simplerefresh.SimpleItemRecyclerFragment.access$100(SimpleItemRecyclerFragment.java:19) at app.dinus.com.example.simplerefresh.SimpleItemRecyclerFragment$2$2.run(SimpleItemRecyclerFragment.java:79) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5438) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)

    opened by selfimprW 1
  • pmd:ImmutableField - Immutable Field

    pmd:ImmutableField - Immutable Field

    This pull request is focused on resolving occurrences of Sonar rule pmd:ImmutableField - Immutable Field

    You can find more information about the issue here: https://dev.eclipse.org/sonar/coding_rules#q=pmd:ImmutableField

    Please let me know if you have any questions.

    M-Ezzat

    opened by m-ezzat 0
  • Multiple quality improvements

    Multiple quality improvements

    This pull request is focused on resolving occurrences of Sonar rules squid:SwitchLastCaseIsDefaultCheck - "switch" statements should end with a "default" clause squid:S1319 - Declarations should use Java collection interfaces such as "List" rather than specific implementation classes such as "LinkedList" squid:S1213 - The members of an interface declaration or class should appear in a pre-defined order

    You can find more information about the issues here: https://dev.eclipse.org/sonar/coding_rules#q=squid:SwitchLastCaseIsDefaultCheck https://dev.eclipse.org/sonar/coding_rules#q=squid:S1319 https://dev.eclipse.org/sonar/coding_rules#q=squid:S1213

    Please let me know if you have any questions.

    M-Ezzat

    opened by m-ezzat 0
  • Migrate RecyclerRefreshLayout and sample app to AndroidX

    Migrate RecyclerRefreshLayout and sample app to AndroidX

    This PR does a conservative migration from Support Library v25 to AndroidX.

    The last version of the Android Support Library was v28. It has been deprecated for some time now, and superseded by AndroidX since it became stable in September 2018. Most open source projects have long migrated to AndroidX, but not RecyclerRefreshLayout. This PR changes that.

    Migrating to AndroidX also removes the need for RecyclerRefreshLayout to be 'jetified', which is the compile-time migration of support-library-dependent libraries to equivalent AndroidX packages.

    The migration is 'conservative' in the sense that it attempts to only migrate the dependencies and imports to AndroidX, without introducing any other project/code changes. I.e. the Android gradle build tools and gradle wrapper versions remain unchanged. However, some changes are unavoidable. The main one being:

    • Support Library v26 raised the minSdkVersion for most libraries tot API 14. That's still the minimum supported Android version required for the AndroidX artifacts RecyclerRefreshLayout depends on.
    opened by mhelder 0
  • loading view flickering

    loading view flickering

    If loading is triggered by swipe gesture its working fine BUT when i am triggering it just by adding refreshLayout.setRefreshing(true); it start flickering

    opened by tabish075 0
  • 加载完一页以后,主动调用refresh会造成RefreshView显示为全白色

    加载完一页以后,主动调用refresh会造成RefreshView显示为全白色

    如上图所示,如果加载一页以后,手动调用refresh,会造成RefreshView显示为全白色,现在定位到原因是 这种情况下,MaterialRefreshView的mSwipeDegrees一直为0,暂时还不知道怎么解决,正在查找

    private void drawArc(Canvas canvas) {
            canvas.drawArc(mArcBounds, mStartDegrees, mSwipeDegrees, false, mPaint);
        }
    
    opened by ZhaoKaiQiang 0
Owner
dinus_developer
blank
dinus_developer
Ultra Pull to Refresh for Android. Support all the views.

Welcome to follow me on GitHub or Twitter GitHub: https://github.com/liaohuqiu Twitter: https://twitter.com/liaohuqiu 中文版文档 Wanna auto-load-more? This

Huqiu Liao 9.6k Jan 5, 2023
This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout.

android-PullRefreshLayout This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout. Demo Usage Add dependency. dependencie

星一 2.1k Dec 3, 2022
a custom pull-to-refresh layout which contains a interesting animation

This is a project with custom pull-to-refresh layout which contains a interesting animation. And the animation is inspired by https://dribbble.com/sho

ZhangLei 1.8k Dec 27, 2022
A pull-down-to-refresh layout inspired by Lollipop overscrolled effects

JellyRefreshLayout A pull-down-to-refresh layout inspired by Lollipop overscrolled effects Preview Download Gradle: repositories { maven {

Y.Chen 628 Oct 26, 2022
null 2.4k Dec 30, 2022
Phoenix Pull-to-Refresh

Phoenix Pull-to-Refresh This project aims to provide a simple and customizable pull to refresh implementation. Made in [Yalantis] (https://yalantis.co

Yalantis 4k Dec 30, 2022
A little more fun for the pull-to-refresh interaction.

Pull-to-Refresh.Tours This project aims to provide a simple and customizable pull to refresh implementation. Check this [project on Behance] (https://

Yalantis 1.7k Dec 24, 2022
GoolgePlusLayout is a custom layout that plays animation on the children views while scrolling as the layout in the Google Plus (android) main page

Google Plus Layout Google Plus Layout is a custom layout that support playing animation on child view(s) in a serialize manner like the the main

Ahmed Nammari 224 Nov 25, 2022
Material Design Search View Layout, now implemented in Google Maps, Dialer, etc

THIS PROJECT IS DEPRECATED Component is not maintained anymore. Implementation of Lollipop+ Dialer and Google Maps. DEMO Add in View Add to your layou

Sahil Dave 1.1k Dec 22, 2022
[UNMAINTAINED]: AndroidMosaicLayout is android layout to display group of views as grid consists of different asymmetric patterns (90 different patterns).

AndroidMosaicLayout AndroidMosaicLayout is android layout to display group of views in more that 90 different patterns. What is AndroidMosaicLayout? I

Adham Enaya 474 Nov 12, 2022
An android layout to re-arrange child views via dragging

Android Rearrangeable Layout An android layout to re-arrange child views via dragging Screencast Demo Layout Usage All the child views are draggable o

Raja Sharan Mamidala 273 Nov 25, 2022
A layout to transition between two views using a Floating Action Button as shown in many Material Design concepts

⚠ This library is no longer maintained ⚠️ FABRevealLayout A layout to transition between two views using a Floating Action Button as shown in many Mat

Tomás Ruiz-López 901 Dec 9, 2022
Responsive Layout Gird Configuration using Compose. An adaptive layout

ResponsiveGrid Responsive Grid is most followed layout system by the designer as it adapts to screen size and orientation, ensuring consistency across

null 4 Apr 12, 2022
Added support to modify text size and indicator width based on the original TabLayout.

XTabLayout——可修改选中项字体大小和指示器长度的TabLayout XTabLayout是基于design包中的TabLayout进行了功能的扩展,在保留原有功能的基础上,增加了修改选中项字体大小、修改指示器长度以及限制屏幕显示范围内显示的Tab个数。 集成步骤: 1.添加XTabLayo

Kennor 660 Dec 20, 2022
Android Library that lights items for tutorials or walk-throughs etc...

Spotlight Gradle dependencies { implementation 'com.github.takusemba:spotlight:x.x.x' } Usage val spotlight = Spotlight.Builder(this) .setTarg

TakuSemba 3.4k Dec 23, 2022
ViewStateLayout - Easy way to manage common state templates like loading, empty, error etc.!

ViewStateLayout Easy way to manage common state templates like loading, empty, error etc.! How to Step 1. Add the JitPack repository to your build fil

Kamrul Hasan 7 Dec 15, 2022
VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions.

Vorolay VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions. [Voronoi diagram] (https://en.wikip

Daniil Jurjev 918 Dec 4, 2022
An Android Layout which has a same function like https://github.com/romaonthego/RESideMenu

ResideLayout An Android Layout which has a same function like https://github.com/romaonthego/RESideMenu. Can be used on Android 1.6(I haven't try it.)

Yang Hui 392 Oct 12, 2022