Giter Site home page Giter Site logo

todou / nestrefresh Goto Github PK

View Code? Open in Web Editor NEW
108.0 5.0 20.0 17.05 MB

Android refresh kit by nest scroll. Pull-to-refresh and pull-to-load-more by behaviors

License: Apache License 2.0

Kotlin 97.33% Java 2.56% Shell 0.11%
nestrefresh appbarlayout spring pull-to-refresh nestscroll childcoordinatorlayout loadmoreandrefresh loadmore

nestrefresh's People

Contributors

todou 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

nestrefresh's Issues

OnRefreshListener getting triggered only once

Hello,

Thank you for this awesome library, it works just fine. but when I'm using RefreshbarLayout and RefreshHeaderView, the onRefreshListener is getting triggered only once, for the first time. After that on pulling it down, the loading view just stays there and does not get a callback.

Following is how I'm using it:

Layout:

    <com.todou.nestrefresh.RefreshBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorWhite"
        android:fitsSystemWindows="true">

        <com.todou.nestrefresh.RefreshHeaderView
            android:id="@+id/refresh_header_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:nr_layout_scrollFlags="flag_refresh_header" />

        <com.todou.nestrefresh.NRCollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:nr_layout_scrollFlags="flag_collapse">

           

        </com.todou.nestrefresh.NRCollapsingToolbarLayout>

    </com.todou.nestrefresh.RefreshBarLayout>

In code:

    mRefreshListener = object : OnRefreshListener {
        override fun onRefresh() {
            mBinding.refreshHeaderView.stopRefresh()
            Log.e("CustomerWalletFragment", "onRefresh: ")
        }

    }

    mBinding.refreshHeaderView.setOnRefreshListener(mRefreshListener!!)

Is this bug? or am I doing something wrong?

Thanks again.

Error when building project

I can't use the library, once the project starts building the error below comes up.

I'm using AndroidX version

dependencies {
    implementation 'com.github.todou:nestrefresh-androidx:0.0.7'
}

The Error


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\pc\.gradle\caches\transforms-2\files-2.1\b6f44d4fc412f7a45d5a43e1ba92708f\jetified-nestrefresh-androidx-0.0.7\res\values\values.xml:19:5-110:25: AAPT: error: resource attr/nr_title (aka com.alaa.testproject/nr_title) not found.
         

Question about RefreshHeaderView

<com.todou.nestrefresh.RefreshHeaderView

there is 3 text sentences appears when we call this object RefreshHeaderView

private lateinit var textBelowThreshold: CharSequence
private lateinit var textAboveThreshold: CharSequence
private lateinit var textRefreshing: CharSequence

can you add simple check to the library, to show/hide it by request?
in case of idea to hide the sentence

by example, something like this public function:

fun toggleTextAppear(toggle Boolean) {
_showHide = toggle
}
and variable _showHide will show or hide that text

RefreshBarLayout too Long , causing sliding and shaking

RefreshBarLayout too Long , causing sliding and shaking.
When you quickly pull up the RefreshBarLayout, immediately pull down the RecyclerView

example for your demo For example, in your demo SingleActivity(I added a ImageView):

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f4f4f5">

<com.todou.nestrefresh.RefreshBarLayout
    android:id="@+id/pull_refresh_hover"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <com.todou.nestrefresh.RefreshHeaderView
        android:id="@+id/view_refresh_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/margin_normal"
        app:nr_layout_scrollFlags="flag_refresh_header"/>

    <LinearLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_margin="10dp"
        android:elevation="@dimen/common_elevation"
        android:background="@drawable/shape_radius"
        android:orientation="vertical"
        android:visibility="visible">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/text_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/margin_normal"
                android:layout_marginTop="@dimen/margin_normal"
                android:text="By ToDou"
                android:textStyle="bold"
                android:textSize="20sp"
                android:textColor="?android:attr/textColorSecondary"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="This is one nest refresh kit"
                android:layout_marginTop="6dp"
                android:layout_marginBottom="@dimen/margin_normal"
                app:layout_constraintTop_toBottomOf="@+id/text_title"
                app:layout_constraintLeft_toLeftOf="@+id/text_title"
                app:layout_constraintBottom_toBottomOf="parent"
                android:textSize="12sp"/>

        </android.support.constraint.ConstraintLayout>

        <View
            android:layout_width="240dp"
            android:layout_height="1dp"
            android:layout_marginLeft="@dimen/margin_normal"
            android:background="@drawable/shape_divider_header_title"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view_inner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:layout_margin="0dp"
            android:visibility="visible"/>

    </LinearLayout>
    <ImageView
        android:id="@+id/iv_icon"
        android:layout_width="match_parent"
        android:layout_height="220dp"
        android:src="@mipmap/ic_launcher_round"
        android:visibility="visible"
        />
    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="140dp"
        android:layout_marginRight="@dimen/margin_normal"
        android:layout_marginLeft="@dimen/margin_normal"
        android:overScrollMode="never"
        android:scrollbars="none">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="140dp">

            <TextView
                android:layout_width="140dp"
                android:layout_height="match_parent"
                android:text="#1"
                style="@style/HorizontalItemStyle"/>

            <TextView
                android:layout_width="140dp"
                android:layout_height="match_parent"
                android:text="#2"
                style="@style/HorizontalItemStyle"/>

            <TextView
                android:layout_width="140dp"
                android:layout_height="match_parent"
                android:text="#3"
                style="@style/HorizontalItemStyle"/>

            <TextView
                android:layout_width="140dp"
                android:layout_height="match_parent"
                android:text="#4"
                style="@style/HorizontalItemStyle"/>

            <TextView
                android:layout_width="140dp"
                android:layout_height="match_parent"
                android:text="#5"
                style="@style/HorizontalItemStyle"
                android:layout_marginRight="0dp"/>

        </LinearLayout>
    </HorizontalScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="@dimen/margin_normal"
        android:layout_marginLeft="@dimen/margin_normal"
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        app:nr_layout_scrollFlags="flag_sticky">

        <TextView
            android:id="@+id/text_tab_one"
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:text="Tab1"
            style="@style/TabStyle"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:text="Tab2"
            style="@style/TabStyle"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:text="Tab3"
            style="@style/TabStyle"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:text="Tab4"
            style="@style/TabStyle"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:text="Tab5"
            style="@style/TabStyle"/>
    </LinearLayout>

</com.todou.nestrefresh.RefreshBarLayout>


<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/nest_refresh_bar_scroll_behavior"/>

</android.support.design.widget.CoordinatorLayout>

----------------------------------solution ----------------------------------
RefreshHeaderBehavior.class
override fun onNestedScrollAccepted(
coordinatorLayout: CoordinatorLayout,
child: V,
directTargetChild: View,
target: View,
axes: Int,
type: Int
) {
super.onNestedScrollAccepted(coordinatorLayout, child, directTargetChild, target, axes, type)
totalSpringOffset = calculateScrollUnconsumed().toFloat()
//this my solution
if (this.flingRunnable != null) {
child?.removeCallbacks(this.flingRunnable)
this.flingRunnable = null
}
}

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.