Giter Site home page Giter Site logo

simformsolutionspvtltd / sspulltorefresh Goto Github PK

View Code? Open in Web Editor NEW
116.0 8.0 20.0 66.76 MB

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: MIT License

Kotlin 100.00%
pulltorefresh recyclerview android kotlin kotlin-android custom listview library refreshlayout custom-pull-to-refresh

sspulltorefresh's Introduction

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.

sspulltorefresh's People

Contributors

l2hyunwoo avatar mobile-simformsolutions avatar nishchal-v avatar shwetachauhan-simform avatar shwetachauhan18 avatar sohamsimform avatar yashwantgowla avatar yashwantgowla-simform avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sspulltorefresh's Issues

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

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.

Custom view is not displayed when refreshing manually

Hi, i have implemented a custom refresh view using version 1.5 from library and it works perfectly when swipe but is not visible when call setRefreshing from code.
My custom view is a Constraint layout with a lottie animation and TextView.

In this video you can view when I click the "chip button" the refresh view is not visible.
Thanks!

pull-to-refresh.webm

wrong behavior with app bar

if i have screen with coordinatorLayout appBar and collapsingToolbar in it and SSPullToRefreshLayout with recycler in it and this attiribute app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"

and the problem is: when you half collapse app bar and scroll up refresh is triggers, but it shouldnt, and app bar shoud fully expand.
how to solve this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.