GithubHelp home page GithubHelp logo

hirayclay / refreshlayout Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 6.07 MB

[DEPRECATED] bullshit code

Java 24.20% Kotlin 75.80%
refreshlayout ui-components nested-scrolling android-ui pull-to-refresh refresh nestedscroll nestedscrollview

refreshlayout's Introduction

RefreshLayout

A easy refresh widget on the basis of nestedscrolling

Why

就想要个简单的刷新控件,用嵌套滚动这套机制去做最简单.实现起来逻辑很清晰,其实看到很多刷新控件,早一点的时候,为了实现刷新必须手动分发事件,不过后来出来了嵌套滚动,手动分发 那一套就有些不合适了;再有一种是在RecyclerView上添加item作为刷新头和尾,多了一层包装不是太合适,另外有种上拉加载更多直接就是添加滚动监听,当滚动到最后 自动触发loadMore,这样貌似也和刷新控件有些不太契合。最近看到SmartRefreshLayout这个项目是用嵌套滚动机制实现的,模仿的是官方的SwipeRefreshLayout,感觉蛮不错的, 不过实现了NestedScrollingParent,又实现了NestedScrollingChild,窃以为没多大必要实现NestedScrollingChild,所以最后还是自己写一个算了.... 实现思路也比较简单,刷新控件无非那几种状态互相切换 idle ,loading ,settling,prepare。

Display

Usage

使用很简单,如果控件已经实现了NestedScrollingChild的像这样

        <com.refresh.RefreshLayout
            android:id="@+id/refreshlayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:targetId="@+id/recyclerView">
    
            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/darker_gray" />
    
        </com.refresh.RefreshLayout>

要是没有实现这个接口的,就包裹在SafeNestedScrollView里就好了,记得给RefreshLayout指定targetId

    
    <com.refresh.RefreshLayout
        android:id="@+id/refreshlayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:targetId="@+id/wrapper">

        <com.refreh.SafeNestedScrollView
            android:id="@+id/wrapper"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/textview"
                android:layout_margin="16dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/large_text" />
        </com.refreh.SafeNestedScrollView>


    </com.refresh.RefreshLayout>

apk

demo

refreshlayout's People

Contributors

hirayclay avatar

Stargazers

 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.