IGRefreshLayout

General

Category
Free
Tag
Layouts
License
N/A
Registered
Sep 6, 2019
Favorites
1
Link
https://github.com/Jamshid-M/IGRefreshLayout
See also
simple-view-behavior
RollingLayout
FlatUI
ExpandablePager
Scrollable

Additional

Language
Kotlin
Version
1.0.2 (Aug 16, 2019)
Created
Aug 16, 2019
Updated
Sep 25, 2019
Owner
Jamshid M (Jamshid-M)
Contributor
Jamshid M (Jamshid-M)
1
Activity
Badge
Generate
Download
Source code
APK file

Advertisement

IGRefreshLayout

Instagram like refresh layout

It is similar to pull to refresh layout, which has in instagram.

Main idea was taken from https://github.com/Yalantis/Phoenix and behaviour of layout was changed.

Usage

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

repositories {

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

For a working implementation check out source from sample directory

dependencies {
 implementation 'com.github.Jamshid-M:IGRefreshLayout:1.0.2'
}

Include IGRefreshLayout in your xml and put inside ListView or Recyclerview

<uz.jamshid.library.IGRefreshLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools" 
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/swipe"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:offsetTop="120"
        app:customBar="true"
        tools:context=".MainActivity">

    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
    />

</uz.jamshid.library.IGRefreshLayout>

Open activity and specify IGRefreshLayout object and setup InstaRefreshCallback

        var swipe = findViewById<IGRefreshLayout>(R.id.swipe)
        swipe.setRefreshListener {
            Handler().postDelayed({
                swipe.setRefreshing(false)
            }, 3000)
        }

You can use lambda callback or callback through object

Enabling and disabling refreshing state

swipe.setRefreshing(false)

Using custom views

swipe.setCustomBar(CircleProgressBar(this))

or

swipe.setCustomBar(LineProgressBar(this))

You can also change color and width of line

val cp = CircleProgressBar(this)
cp.setColors(Color.RED, Color.BLUE)
cp.setBorderWidth(4)

val lp = LineProgressBar(this)
lp.setColors(Color.RED, Color.BLUE)
lp.setBorderWidth(4)

Use your own view e.g Android components (Button, ImageView, TextView should be View)

Extend it from BaseProgressBar

class Circle @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : BaseProgressBar(context, attrs, defStyleAttr)

Specify view you want in custom view

var bar = ImageView(context)

And call setCustomView method in mParent object

mParent.setCustomView(bar, dp2px(80), dp2px(80))

That's all, after that you can bind your view into percent which cames from IGRefreshLayout

    override fun setPercent(percent: Float) {
        mPercent = percent
        bar.alpha = percent/100
    }

For detailed info go to sample directory and check out Circle.kt class