SSPullToRefresh makes PullRefresh easy to use, you can provide your own custom animations or set simple gifs on refresh view. The best feature is Lottie animations in refresh view, it uses lottie animations to render high quality animations on pull refresh. 🎉💥

Overview

SSPullToRefresh

Pull to Refresh with custom animations

Build Status Kotlin Version Platform API

SSPullToRefresh makes PullRefresh easy to use, you can provide your own custom animations or set simple gifs on refresh view. The best feature is Lottie animations in refresh view, it uses lottie animations to render high quality animations on pull refresh.

Features

  • Simple and easy to use ( no complex animations to deal with )
  • Customize the animation view by providing your own custom RefreshView (need to subclass SSAnimationView)
  • Set Gif animations in refresh view
  • Import lottie jason in assets folder and apply animation ( as simple as that )
  • Customize repeateMode, repeateCount and Interpolators on different points of animations

🎬 Preview

Default refreshView Lottie animation 1 Lottie animation 2
Wave animation (Custom class) Gif animation

How it works:

  1. Gradle Dependency
  • Add the JitPack repository to your project's build.gradle file
    allprojects {
        repositories {
            ...
    	    maven { url 'https://jitpack.io' }
        }
    }
  • Add the dependency in your app's build.gradle file
    dependencies {
        implementation 'com.github.SimformSolutionsPvtLtd:SSPullToRefresh:1.2'
    }
  1. Wrap your refreshing view ( RecyclerView, listView etc..) with SSPullToRefreshLayout
">
    <com.simform.refresh.SSPullToRefreshLayout
        android:id="@+id/ssPullRefresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    com.simform.refresh.SSPullToRefreshLayout>
  1. Set OnRefreshListener on SSPullToRefreshLayout and you are good to go 👍
    ssPullRefresh.setOnRefreshListener(object : SSPullToRefreshLayout.OnRefreshListener {
        override fun onRefresh() {
            // This is demo code to perform
            GlobalScope.launch {
                delay(3000)
                ssPullRefresh.setRefreshing(false) // This line stops layout refreshing
                MainScope().launch {
                    Toast.makeText(this@MainActivity,"Refresh Complete",Toast.LENGTH_SHORT).show()
                }
            }
        }
    })

To customize SSPullToRefreshLayout:

  • To customize SSPullToRefreshLayout, you can set a different lottie animation of your choice
  • you need to have .json file of you lottie animations in assets forlder of you app module
    ssPullRefresh.setLottieAnimation("lottie_isometric-plane.json")
  • To customize repeadtMode and repeatCount of animation.
    ssPullRefresh.setRepeatMode(SSPullToRefreshLayout.RepeatMode.REPEAT)
    ssPullRefresh.setRepeatCount(SSPullToRefreshLayout.RepeatCount.INFINITE)
  • To change refresh style.
    ssPullRefresh.setRefreshStyle(SSPullToRefreshLayout.RefreshStyle.NORMAL)
  • To customize the whole refresh view you need to inherit SSAnimationView for your custom class and override the methods needed
    class WaveAnimation(context: Context): SSAnimationView(context) {
        private var amplitude = 22f.toDp() // scale
        private var speed = 0f
        private val path = Path()
        private var paint = Paint(Paint.ANTI_ALIAS_FLAG)
        private var animator: ValueAnimator? = null

        override fun onDraw(c: Canvas) = c.drawPath(path, paint)

        private fun createAnimator(): ValueAnimator {
            return ValueAnimator.ofFloat(0f, Float.MAX_VALUE).apply {
                repeatCount = ValueAnimator.INFINITE
                addUpdateListener {
                    speed -= WAVE_SPEED
                    createPath()
                    invalidate()
                }
            }
        }

        private fun createPath() {
            path.reset()
            paint.color = Color.parseColor("#203354")
            path.moveTo(0f, height.toFloat())
            path.lineTo(0f, amplitude)
            path.lineTo(0f, amplitude - 10)
            var i = 0
            while (i < width + 10) {
                val wx = i.toFloat()
                val wy = amplitude * 2 + amplitude * sin((i + 10) * Math.PI / WAVE_AMOUNT_ON_SCREEN + speed).toFloat()
                path.lineTo(wx, wy)
                i += 10
            }
            path.lineTo(width.toFloat(), height.toFloat())
            path.close()
        }

        override fun onDetachedFromWindow() {
            animator?.cancel()
            super.onDetachedFromWindow()
        }

        companion object {
            const val WAVE_SPEED = 0.25f
            const val WAVE_AMOUNT_ON_SCREEN = 350
        }

        private fun Float.toDp() = this * context.resources.displayMetrics.density

        override fun reset() {
        }

        override fun refreshing() {
        }

        override fun refreshComplete() {
            animator?.cancel()
        }

        override fun pullToRefresh() {
            animator = createAnimator().apply {
                start()
            }
        }

        override fun releaseToRefresh() {
        }

        override fun pullProgress(pullDistance: Float, pullProgress: Float) {
        }
}
  • Provide your CustomView by setRefreshView() method
        ssPullRefresh.setRefreshView(WaveAnimation(this))
  • Provide layoutParams if you need to channge RefreshView height/width
         ssPullRefresh.setRefreshViewParams(ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,300))
  • Set Gif animation just by using setGifAnimation method ( This can only be done on SSAnimationView )
         ssPullRefresh.setGifAnimation(R.raw.bird)

Other Library used:

Credits:

Find this library useful? ❤️

Support it by joining stargazers for this repository.

🤝 How to Contribute

Whether you're helping us fix bugs, improve the docs, or a feature request, we'd love to have you! 💪 Check out our Contributing Guide for ideas on contributing.

iOS Library:

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues.

License

Copyright 2021 Simform Solutions

 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.
You might also like...
 android custom listview,with interaction pattern load more and pull to refresh to load data  dinamically
android custom listview,with interaction pattern load more and pull to refresh to load data dinamically

The first thing that i have to say is render thanks to johannilsson because all the part of pull to refresh listview is based in the code of his repos

A custom SwipeRefreshLayout to support the pull-to-refresh featrue.RecyclerView,ListView,GridView,NestedScrollView,ScrollView are supported.
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

Noice is an android app that allows you to create your own set of background sounds by mixing clips from environmental sources.
Noice is an android app that allows you to create your own set of background sounds by mixing clips from environmental sources.

A native Android app to relax, improve focus and boost productivity with minimal background noise.

This is a specified proportion to the size of the Layout or View support library, with which you can easily set a fixed ratio of the size of the Layout or View, internal adaptive size calculation, completely abandon the code to calculate the size! If you have any questions in the course or suggestions, please send an e-mail to the following e-mail, thank you!
FragmentTransactionExtended is a library which provide us a set of custom animations between fragments.

FragmentTransactionExtended FragmentTransactionExtended is a library which provide us a set of custom animations between fragments. FragmentTransactio

LiteGo is a Java-based asynchronous concurrency library. It has a smart executor, which can be freely set the maximum number of concurrent at same time , and the number of threads in waiting queue. It can also set waiting policies and overload strategies.

LiteGo:「迷你」的Android异步并发类库 LiteGo是一款基于Java语言的「异步并发类库」,它的核心是一枚「迷你」并发器,它可以自由地设置同一时段的最大「并发」数量,等待「排队」线程数量,还可以设置「排队策略」和「超载策略」。 LiteGo可以直接投入Runnable、Callable

A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates
A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates

WhatTodo Life can feel overwhelming. But it doesn’t have to. A Simple To-do app design in flutter to keep track of your task on daily basis. You can a

****. Use the native and support library variants instead - https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml.html. An android library that makes it easy to add custom fonts to edittexts and textviews

Add to your project Add this line to your dependencies in build.gradle compile 'in.workarounds.typography:typography:0.0.8' Using the views There are

SocyMusic is an open-source Android music player written in Java with the aim of creating an easy-to-use app for exchanging and listening to top-quality music. Help us create it!

SocyMusic SocyMusic is an open-source Android music player written entirely in Java. It's objectives are to provide top-quality music to everyone for

Dokka plugin to render Mermaid graphics, from your code comments to your Dokka documentation.
Dokka plugin to render Mermaid graphics, from your code comments to your Dokka documentation.

Dokka plugin to render Mermaid graphics, from your code comments to your Dokka documentation.

StartPointSeekBar is a custom view for the Android platform that makes it possible to have a SeekBar to have custom start point.
StartPointSeekBar is a custom view for the Android platform that makes it possible to have a SeekBar to have custom start point.

Forked/Inspired from https://code.google.com/p/range-seek-bar/ by [email protected] This solves the problem as described in http://

Introduction your app to the user , Easy to use and set Items as you want

Introduction App This lib helps to introduce the App-by view page based on Kotlin. Features Easy Set up Items: Title, Describe, Background, Buttons Ap

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

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

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://

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

Android widget with pull to refresh for all the views,and support loadMore for ListView , RecyclerView, GridView and SwipeRefreshLayout.
Android widget with pull to refresh for all the views,and support loadMore for ListView , RecyclerView, GridView and SwipeRefreshLayout.

CommonPullToRefresh Android widget with pull to refresh for all the views,and support loadMore for ListView,RecyclerView,GridView and SwipeRefreshLayo

A generic, customizable, open source Android ListView implementation that has 'Pull to Refresh' functionality.
A generic, customizable, open source Android ListView implementation that has 'Pull to Refresh' functionality.

Android 'Pull to Refresh' ListView library Demo video: http://www.youtube.com/watch?v=VjmdELnm3GI Project A generic, customizable, open source Android

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!
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!

RecyclerRefreshLayout English | 中文版 RecyclerRefreshLayout based on the {@link android.support.v4.widget.SwipeRefreshLayout} The RecyclerRefreshLayout

Comments
  • Setting refresh initial offset keeps loading animation after setRefreshing(false) is called

    Setting refresh initial offset keeps loading animation after setRefreshing(false) is called

    Refresh animation still visible after setRefreshing(false) if there's setRefreshInitialOffset() applied.

    Steps to reproduce the behavior:

    1. init with the following: swipeRefresh.setRepeatMode(SSPullToRefreshLayout.RepeatMode.REPEAT) swipeRefresh.setRepeatCount(SSPullToRefreshLayout.RepeatCount.INFINITE) and wrap around a recyclerview that has clipToPadding = false and a top padding at a double size of a standard toolbar height
    2. set the initial offset swipeRefresh.setRefreshInitialOffset(/half the measured height of the above recyclerview padding/)
    3. attach a listener in which loading will be initiated swipeRefresh.setOnRefreshListener.... { loadData() }
    4. set setRefreshing(false) when data load is finished, observe the loading animation is still present

    Expected behavior Loading animation is gone after calling setRefreshing(false) with initial refresh offset set, just as it would be gone if there's no initial refresh offset set - it would probably just be enough to set visibility = GONE to mRefreshView

    bug 
    opened by branislav-zlatkovic 6
  • how to manage stopRefreshing(false) without any specific delay time in OnRefreshListener

    how to manage stopRefreshing(false) without any specific delay time in OnRefreshListener

    First of Thank you so much team for such a beautiful library to make our animation stuff easy.

    I am bit confuse about use of SwipeRefreshLayout that's why i am here to be more clear. I want to start refreshing when I enter in the activity and want to stop refreshing when all my apis getting called and UI is updated, but as per your readme we can add specific delay to stop refreshing.

    please make us clear for this kind of scenario as this is the most common thing in apps.

    enhancement 
    opened by hpcreator 2
  • Add feature to disable and enable SSPullToRefresh

    Add feature to disable and enable SSPullToRefresh

    In some cases I need to disable pull to refresh, and the library does not allow me to do that. It would be good to have that feature to disable SSPullToRefresh.

    enhancement 
    opened by vahan16 1
Releases(1.3)
  • 1.3(Aug 5, 2021)

  • 1.2(Jun 25, 2021)

  • 1.1(Jun 23, 2021)

    • Simple and easy to use ( no complex animations to deal with )
    • Customize the animation view by providing your own ( need to subclass SSAnimationView )
    • Import Lottie Jason in assets folder and apply animation ( as simple as that )
    • Customize repeated, repeat count, and Interpolators on different points of animations
    Source code(tar.gz)
    Source code(zip)
  • 1.0(Jun 22, 2021)

Owner
Simform Solutions
Simform Solutions
A library that makes it easier to write high quality automated acceptance tests

Getting started with Serenity and Cucumber Serenity BDD is a library that makes it easier to write high quality automated acceptance tests, with power

ricardo larrahondo 1 Oct 20, 2021
A RecyclerView that implements pullrefresh and loadingmore featrues.you can use it like a standard RecyclerView

XRecyclerView a RecyclerView that implements pullrefresh , loadingmore and header featrues.you can use it like a standard RecyclerView. you don't need

XRecyclerView 5.3k Dec 26, 2022
A RecyclerView that implements pullrefresh and loadingmore featrues.you can use it like a standard RecyclerView

XRecyclerView a RecyclerView that implements pullrefresh , loadingmore and header featrues.you can use it like a standard RecyclerView. you don't need

XRecyclerView 5.3k Dec 26, 2022
DMIV aims to provide a flexible and customizable instrument for automated images moving on display. It provides scroll, gyroscope or time based moving. But you can create your own evaluator.

DexMovingImageView DMIV aims to provide a flexible and customizable instrument for automated images moving on display. It provides scroll, gyroscope o

Diego Grancini 310 Feb 7, 2022
This project aims to provide a reusable pull to refresh widget for Android.

Pull To Refresh for Android Note This library is deprecated, a swipe refresh layout is available in the v4 support library. This project aims to provi

Johan Berg 2.5k Jan 2, 2023
Quality-Tools-for-Android 7.5 0.0 L5 Java This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android platform.

Quality Tools for Android This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android pl

Stéphane Nicolas 1.3k Dec 27, 2022
null 2.4k Dec 30, 2022
AppUI Sample Application - display how you can create your own custom AppUI application within a few minutes

AppUI Sample Application This is an open-source project to display how you can create your own custom AppUI application within a few minutes. I have a

Formaloo 5 Sep 5, 2022
High-quality Interactive Audio/Video Android SDK

High-quality Interactive Audio/Video Android SDK

LiteAVSDK 34 Jan 4, 2023
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