项目作者: HirayClay

项目描述 :
[DEPRECATED] bullshit code
高级语言: Kotlin
项目地址: git://github.com/HirayClay/RefreshLayout.git
创建时间: 2017-09-21T09:21:18Z
项目社区:https://github.com/HirayClay/RefreshLayout

开源协议:

下载


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的像这样

  1. <com.refresh.RefreshLayout
  2. android:id="@+id/refreshlayout"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. app:targetId="@+id/recyclerView">
  6. <android.support.v7.widget.RecyclerView
  7. android:id="@+id/recyclerView"
  8. android:layout_width="match_parent"
  9. android:layout_height="match_parent"
  10. android:background="@android:color/darker_gray" ></android.support.v7.widget.RecyclerView>
  11. </com.refresh.RefreshLayout>

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

  1. <com.refresh.RefreshLayout
  2. android:id="@+id/refreshlayout"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. app:targetId="@+id/wrapper">
  6. <com.refreh.SafeNestedScrollView
  7. android:id="@+id/wrapper"
  8. android:layout_width="match_parent"
  9. android:layout_height="match_parent">
  10. <android.support.v7.widget.AppCompatTextView
  11. android:id="@+id/textview"
  12. android:layout_margin="16dp"
  13. android:layout_width="match_parent"
  14. android:layout_height="wrap_content"
  15. android:text="@string/large_text" ></android.support.v7.widget.AppCompatTextView>
  16. </com.refreh.SafeNestedScrollView>
  17. </com.refresh.RefreshLayout>

apk

demo