Skip to content

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. πŸŽ‰πŸ’₯

License

Notifications You must be signed in to change notification settings

SimformSolutionsPvtLtd/SSPullToRefresh

Repository files navigation

SSPullToRefresh

Pull to Refresh with custom animations

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 interactive RefreshViews (need to implement RefreshCallbacks)
  • Set Gif animations in refresh view
  • Import lottie json in assets folder and apply animation (as simple as that)
  • Customize repeatMode, repeatCount and Interpolator on different points of animations

🎬 Preview

Default refreshView Gif animation Wave animation (Custom class)
Lottie animation 1 Lottie animation 2 Lottie animation 3
Custom view with user interactions

How it works:

  1. Gradle Dependency
  • Add the JitPack repository to your project's build.gradle file
allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
  • With the newer android studio project structure you will need to define the jitpack url in settings.gradle instead of build.gradle
dependencyResolutionManagement {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
  • Add the dependency in your app's build.gradle file
dependencies {
    implementation 'com.github.SimformSolutionsPvtLtd:SSPullToRefresh:1.5.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 {
   CoroutineScope(Dispatchers.Main).launch {
      delay(2000)
      ssPullRefresh.setRefreshing(false) // This stops refreshing
      mAdapter.randomizeData()
      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 your lottie animations in assets folder of your app module

ssPullRefresh.setLottieAnimation("lottie_isometric-plane.json")
  • To customize repeatMode 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

    Here is an example class WaveAnimation.

  • Provide your CustomView by setRefreshView() method

ssPullRefresh.setRefreshView(WaveAnimation(this))
  • Provide layoutParams if you need to change 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.

Awesome Mobile Libraries

License

MIT License

Copyright (c) 2022 Simform Solutions

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.

About

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. πŸŽ‰πŸ’₯

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages