This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout.

Overview

android-PullRefreshLayout

Android Arsenal

This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout.

Demo

Screenshot

Usage

Add dependency.

dependencies {
    compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
}

Use method like SwipeRefreshLayout's usage.

Use it in your layout xml.

<com.baoyz.widget.PullRefreshLayout
    android:id="@+id/swipeRefreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

	<!-- ListView、ScrollView、RecyclerView、Other -->
	
</com.baoyz.widget.PullRefreshLayout>

Get instance and use it.

PullRefreshLayout layout = (PullRefreshLayout) findViewById(...);

// listen refresh event
layout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
        // start refresh
    }
});

// refresh complete 
layout.setRefreshing(false);

Change the refresh style, there are five styles of use, MATERIALCIRCLESWATER_DROPRING and SMARTISAN.

In java, call setRefreshStyle method.

layout.setRefreshStyle(PullRefreshLayout.STYLE_CIRCLES);

In xml, use attributes.

<com.baoyz.widget.PullRefreshLayout
    android:id="@+id/swipeRefreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
	app:refreshType="water_drop">
	
</com.baoyz.widget.PullRefreshLayout>

Change the color scheme. In java, call setColorSchemeColors method. The int array length must be 4.

layout.setColorSchemeColors(int []);

For Smartisan style, it has only one color, can call 'setColor' method, to set one color.

layout.setColor(int);

In xml, use attributes.

<com.baoyz.widget.PullRefreshLayout
    android:id="@+id/swipeRefreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:refreshColors="@array/scheme_colors"
    app:refreshColor="@color/one_color">
	
</com.baoyz.widget.PullRefreshLayout>

If you do not like these styles, you can customize the refresh style.

class CustomDrawable extends RefreshDrawable{

    @Override
    public void setPercent(float percent) {
        // Percentage of the maximum distance of the drop-down refresh.
    }

    @Override
    public void setColorSchemeColors(int[] colorSchemeColors) {
        
    }

    @Override
    public void offsetTopAndBottom(int offset) {
        // Drop-down offset.
    }

    @Override
    public void start() {
        isRunning = true;
        // Refresh started, start refresh animation.
    }

    @Override
    public void stop() {
        isRunning = false;
        // Refresh completed, stop refresh animation.
    }

    @Override
    public boolean isRunning() {
        return isRunning;
    }

    @Override
    public void draw(Canvas canvas) {
        // Draw custom style.
    }

}

Call setRefreshDrawable() method to use your custom refresh drawable.

layout.setRefreshDrawable(new CustomDrawable());

Thanks

License

The MIT License (MIT)

Copyright (c) 2014 baoyongzhang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Comments
  • Scroll problem when having a ScrollView in the PullRefreshLayout

    Scroll problem when having a ScrollView in the PullRefreshLayout

    Hi, I'm encountering a problem when I have a ScrollView inside your PullRefreshLayout. When I scroll to the end of the ScrollView and I want to scroll back to the top, the scroll is on PullRefreshLayout and not on the ScrollView. So I can't scroll back when I go to the end of the ScrollView !

    I'm not sure if it's very clear :/

    opened by hyukchan 6
  • ColorScheme Showing Me different Colors

    ColorScheme Showing Me different Colors

       int[] colors = {#FFFFFF, #AFAFAF, #838383, #000000}; I use my Color resource not HEXs
       swipeRefreshLayout.setColorSchemeColors(colors);
    

    But whenever I use that, I get a purplish color, but what I want is a white, light grey, dark_grey and a black. Why?

    opened by tonespy 2
  • Improve Material Animation

    Improve Material Animation

    Hi i like and use your libraries but I noticed that in the Material style the animation and the behavior is a little different than Google's one. If you can improve the animation it will be perfect! The differences are:

    1. now when refresh starts the view is created up the listview/scrollview and not above (like a surface)
    2. at the end the circle should scale and fade out instead of translate

    like this http://material-design.storage.googleapis.com/publish/v_2/material_ext_publish/0B8v7jImPsDi-NllyUG1oSUx6XzA/070601_posSwipeYes_xdpi_v08b.webm

    Thanks :smiley:

    opened by fcannizzaro 1
  • setRefreshing programmatically not working properly

    setRefreshing programmatically not working properly

    Hi, I think you should add this couple of lines to your code as if you try to call setRefreshing(true) programmatically the drawable animation won't show.

    public void setRefreshing(boolean refreshing) { if (refreshing) mRefreshDrawable.setPercent(1f); if (mRefreshing != refreshing) { setRefreshing(refreshing, false /* notify */); } }

    Regards and thanks for your contribution. Danny

    opened by tejada 1
  • get Notified when Pull is releasd

    get Notified when Pull is releasd

    how can we get notified when pull is released without delay

    since Onrefresh method in setonrefreshlister has Slight delay or how can we eliminate this delay

    opened by cnelindiahwe 0
  • pointerIndex out of range

    pointerIndex out of range

    Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range at android.view.MotionEvent.nativeGetAxisValue(MotionEvent.java) at android.view.MotionEvent.getY(MotionEvent.java:2431) at android.support.v4.view.MotionEventCompat.getY(MotionEventCompat.java:521) at com.baoyz.widget.PullRefreshLayout.onTouchEvent(PullRefreshLayout.java:324) at android.view.View.dispatchTouchEvent(View.java:10920) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2810) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2512) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.cancelAndClearTouchTargets(ViewGroup.java:2662) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2368) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2842) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2469) at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:623) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1906) at android.app.Activity.dispatchTouchEvent(Activity.java:3247) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68) at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:585) at android.view.View.dispatchPointerEvent(View.java:11149) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5227) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5076) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4580) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4633) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4599) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4736) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4607) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4793) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4580) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4633) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4599) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4607) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4580) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7210) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7142) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7103) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7321) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:323) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:6823) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)

    opened by vytautokas 5
  • Background issue

    Background issue

    Hi, i want to change the color of the area that is behind the loading. But i have to do this without changing background of the list. Because, app has a unique background image which shown all pages and listview on it. How can i change only opened area color? Thanks.

    opened by alcntml 0
Owner
星一
Read the fucking code
星一
A custom SwipeRefreshLayout to support the pull-to-refresh featrue.RecyclerView,ListView,GridView,NestedScrollView,ScrollView are supported.

SuperSwipeRefreshLayout A custom SwipeRefreshLayout to support the pull-to-refresh featrue.You can custom your header view and footer view. RecyclerVi

Zheng Haibo(莫川) 1.3k Dec 13, 2022
A beautiful leanback port for Smartphones and Tablets

MaterialLeanBack A beautiful leanback port for Smartphones and Tablets Sample Usage In your layout <com.github.florent37.materialleanback.MaterialLean

Florent CHAMPIGNY 739 Aug 2, 2022
null 2.4k Dec 30, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Jan 5, 2023
Android component which presents a dismissible view from the bottom of the screen

BottomSheet BottomSheet is an Android component which presents a dismissible view from the bottom of the screen. BottomSheet can be a useful replaceme

Flipboard 4.5k Dec 28, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube New graphic component.

Please switch to DragView, for the best support, thank you DraggablePanel Download allprojects { repositories { ... maven { url 'https://jitp

Hoàng Anh Tuấn 103 Oct 12, 2022
ConstraintLayout is an Android layout component which allows you to position and size widgets in a flexible way

ConstraintLayout is a layout manager for Android which allows you to position and size widgets in a flexible way. It's available for both the Android view system and Jetpack Compose.

Android Jetpack 970 Jan 6, 2023
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
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
TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.

This project isn't maintained anymore. It is now recommended to use https://github.com/peterLaurence/MapView. MapView is maintained by Peter, one of o

Mike Dunn 1.5k Nov 21, 2022
A layout that creates a loading-like progress around it's child ( circle ) on touch, inspired from Destiny's ( PS4 ) accept mechanism

HoldToLoadLayout HoldToLoadLayout is a view group that can contain a single child. It draws your child to middle of layout, and performs loading wheel

Melih Aksoy 79 Feb 8, 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
AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard switch component.

AwesomeSwitch AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard swi

Anoop S S 29 Jun 2, 2022
🔎 An HTTP inspector for Android & OkHTTP (like Charles but on device) - More Chucker than Chuck

Chucker A fork of Chuck Getting Started Features Multi-Window Configure Redact-Header️ Decode-Body Migrating Snapshots FAQ Contributing Building Ackno

Chucker Team 2.9k Dec 30, 2022
MaterialLoadingProgressBar provide a styled ProgressBar which looks like SwipeRefreshLayout's loading indicator(support-v4 v21+)

MaterialLoadingProgressBar MaterialLoadingProgressBar provide a styled ProgressBar which looks like SwipeRefreshLayout's loading indicator(support-v4

lsjwzh 1.1k Nov 19, 2022
📦📦Video downloader for Android - Download videos from Youtube, Facebook, Twitter, Instagram, Dailymotion, Vimeo and more than 1000 other sites

youtube-dl-android ?? An Android client for youtube-dl: https://github.com/rg3/youtube-dl Major technologies Language: Kotlin Architecture: MVVM Andro

Cuong Pham 445 Jan 8, 2023
Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies.

android-formidable-validation Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Pr

Linden 147 Nov 20, 2022
📦📦Video downloader for Android - Download videos from Youtube, Facebook, Twitter, Instagram, Dailymotion, Vimeo and more than 1000 other sites

youtube-dl-android ?? An Android client for youtube-dl: https://github.com/rg3/youtube-dl Major technologies Language: Kotlin Architecture: MVVM Andro

Cuong Pham 443 Dec 30, 2022
Android Shared preference wrapper than encrypts the values of Shared Preferences. It's not bullet proof security but rather a quick win for incrementally making your android app more secure.

Secure-preferences - Deprecated Please use EncryptedSharedPreferences from androidx.security in preferenced to secure-preference. (There are no active

Scott Alexander-Bown 1.5k Dec 24, 2022
Share MPS code snippets. More than just screenshots.

skadi gist Share MPS code snippets. More than just screenshots. Repository Content ide-plugin: MPS Plugin that creates a gist from the IDE written in

Skadi 6 Jan 8, 2023