Coder Social home page Coder Social logo

lottieswiperefreshlayout's Introduction

LottieSwipeRefreshLayout

A custom SwipeRefreshLayout that shows a Lottie View on top instead.

The main idea was to make it as similar to the AndroidX SwipeRefreshLayout as possible, so that they are easily interchangable.

Basic usage

A LottieSwipeRefreshLayout accepts only one child. See example for more detail.

<?xml version="1.0" encoding="utf-8"?>
<com.nabilmh.lottieswiperefreshlayout.LottieSwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                       xmlns:app="http://schemas.android.com/apk/res-auto"
                                       android:id="@id/swipe_refresh"
                                       android:layout_width="match_parent"
                                       android:layout_height="match_parent"
                                       app:lottie_rawRes="@raw/pull_to_refresh"
                                       >

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</com.nabilmh.lottieswiperefreshlayout.LottieSwipeRefreshLayout>

Attributes

max_offset_top: The maximum distance in dp that the refresh indicator can be pulled beyond its resting position. indicator_overlay: Whether to overlay the indicator on top of the content or not (default:true) trigger_offset_top: The offset in dp from the top of this view at which the progress indicator should come to rest after a successful swipe gesture.

lottie_rawRes: The Lottie file to use. (placed in the raw folder)

Extensible

You can use the base SimpleSwipeRefreshLayout to make your own pull to refresh view.

How to add the library

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.nabil6391:LottieSwipeRefreshLayout:1.0.0'
}

Inspiration

This library took its original inspiration from https://github.com/timrijckaert/LottieSwipeRefreshLayout

Usage in jetpack Compose

Use it in coordination with accompanist swipe refresh

implementation "com.google.accompanist:accompanist-swiperefresh:"

var loading by viewModel.loading.collectAsState() //observerAsState for livedata

SwipeRefresh(
            state = rememberSwipeRefreshState(isRefreshing = !loading),
            onRefresh = {
                //Refresh
            },
            indicator = { state, trigger ->
                LottieRefreshIndicator(state = state, refreshTriggerDistance = trigger, animation = R.raw.monitor_progress)
            },
        ) {
            //Content
        }

lottieswiperefreshlayout's People

Contributors

nabil6391 avatar

Watchers

 avatar

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.