All Projects → miomin → Shswiperefreshlayout

miomin / Shswiperefreshlayout

Licence: mit
Android 升级版 SwipeRefreshLayout,支持RecyclerView、ScrollView等大部分组件,下拉刷新(Refresh)和上拉加载(Loadmore),支持自定义HeaderView和FooterView

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Shswiperefreshlayout

Brv
Android上最强大的RecyclerView库
Stars: ✭ 345 (+46.19%)
Mutual labels:  recyclerview, listview, refreshlayout
Smilerefresh
微笑下拉刷新。这是在 SwipeRefreshLayout基础上修改的下拉刷新库。
Stars: ✭ 203 (-13.98%)
Mutual labels:  recyclerview, listview, refresh
Smoothrefreshlayout
一款支持上下拉刷新、越界回弹、二级刷新、横向刷新、拉伸回弹、平滑滚动、嵌套滚动的多功能刷新控件
Stars: ✭ 1,166 (+394.07%)
Mutual labels:  refresh, refreshlayout
Videolistplayer
Play video in ListView or RecyclerView
Stars: ✭ 1,308 (+454.24%)
Mutual labels:  recyclerview, listview
Admobadapter
It wraps your Adapter to display Admob native ads and banners in a ListView/RecyclerView data set. It based on the Yahoo fetchr project https://github.com/yahoo/fetchr
Stars: ✭ 224 (-5.08%)
Mutual labels:  recyclerview, listview
Ultimaterefreshview
UltimateRefreshView 实现下拉刷新,上拉加载更多的轻量级库;支持RecyclerView ,ListView ,ScrollView & WebView
Stars: ✭ 64 (-72.88%)
Mutual labels:  recyclerview, listview
Countdowntask
⌛️A countdown library for Android.
Stars: ✭ 64 (-72.88%)
Mutual labels:  recyclerview, listview
Xrefreshlayout
【已过时,不再更新,请使用更强大的SmartRefreshLayout!】A refresh layout(无侵入下拉刷新和加载布局), can refresh RecyclerView for all LayoutManager, NestedScrollView。
Stars: ✭ 127 (-46.19%)
Mutual labels:  recyclerview, refreshlayout
Swiperefreshlayout
swipeRefreshLayout refresh pull-to-refresh
Stars: ✭ 26 (-88.98%)
Mutual labels:  refresh, refreshlayout
Easyadapter
Android 轻量级适配器,简化使用,适应所有的AbsListView、RecyclerView。支持HeaderView与FooterView~
Stars: ✭ 160 (-32.2%)
Mutual labels:  recyclerview, listview
React Native Mjrefresh
基于ios MJRefresh https://github.com/CoderMJLee/MJRefresh 开发的插件,可提供自定义的弹性刷新
Stars: ✭ 140 (-40.68%)
Mutual labels:  refresh, refreshlayout
Overscroll Decor
Android: iOS-like over-scrolling effect applicable over almost all scrollable Android views.
Stars: ✭ 2,671 (+1031.78%)
Mutual labels:  recyclerview, listview
Flutter refresh
flutter refresh 上拉刷新 下拉加载 进度条
Stars: ✭ 51 (-78.39%)
Mutual labels:  refresh, refreshlayout
Multi type list view
A flutter customer ListView that displays multiple widget types.
Stars: ✭ 47 (-80.08%)
Mutual labels:  recyclerview, listview
Collapsingrefresh
AppBarLayout+ViewPager+RecyclerView的刷新功能
Stars: ✭ 69 (-70.76%)
Mutual labels:  recyclerview, refresh
Google Books Android Viewer
Android library to bridge between RecyclerView and sources like web page or database. Includes demonstrator (Google Books viewer)
Stars: ✭ 37 (-84.32%)
Mutual labels:  recyclerview, listview
Swipemenulayout
🔥一个零耦合的侧滑菜单,支持RecyclerView、ListView、GridView等不同条目布局,支持菜单在左或在右,可选滑动阻塞,是否禁用等功能
Stars: ✭ 120 (-49.15%)
Mutual labels:  recyclerview, listview
Superadapter
[Deprecated]. 🚀 Adapter(BaseAdapter, RecyclerView.Adapter) wrapper for Android. 一个Adapter同时适用RecyclerView、ListView、GridView等。
Stars: ✭ 638 (+170.34%)
Mutual labels:  recyclerview, listview
Swipemenu
[DEPRECATED] A swipe menu for horizontal/vertical, support left/right and top/bottom directions
Stars: ✭ 817 (+246.19%)
Mutual labels:  recyclerview, listview
Kotlin Adapter
🔥 RecyclerView,AbsListView适配器, 支持多种视图样式, 支持吸顶、侧滑删除、拖拽效果
Stars: ✭ 132 (-44.07%)
Mutual labels:  recyclerview, listview

SHSwipeRefreshLayout by miomin

支持下拉刷新和上拉加载更多,支持自定义HeaderView和FooterView,支持RecyclerView、ScrollView嵌套滚动,支持所有Layout,支持自定义动画


提示

如使用其它控件时遇到滑动冲突,请参考源码中ShareScrollView、SHListView的实现自行解决,只需让该控件实现NestedScrollingChild接口即可。


简介

gif

  • 使用方法与Google的SwipeRefreshLayout一致,采用内包裹的方式
  • 支持下拉刷新和上拉加载更多
  • 支持通过Resource ID或View自定义HeaderView和FooterView的样式
  • 通过NestedScrolling支持RecyclerView和ScrollView的嵌套滚动不收影响
  • 支持所有Layout、View
  • 支持在回调中设置自定义动画

依赖

  • Step1:在工程build.gradle中添加如下maven仓库

allprojects {
   repositories {
       jcenter()
       // 添加这一行即可
       maven { url "https://raw.githubusercontent.com/miomin/mvn-repo-ione/master" }
   }
}
  • Step2:在Module的build.gradle或者全局添加如下依赖

 compile 'com.miomin:shswiperefreshlayout:1.3.0'

How to use

可参考sample中的示例

In XML

<com.scu.miomin.shswiperefresh.core.SHSwipeRefreshLayout
        android:id="@+id/swipeRefreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:load_text="加载更多"
        app:progress_bar_color="@color/colorPrimary"
        app:refresh_text="下拉刷新"
        app:guidance_text_color="@color/colorPrimary"
        app:guidance_view_bg_color="@color/transparent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
</com.scu.miomin.shswiperefresh.core.SHSwipeRefreshLayout>

如需使用ScrollView,请使用ShareScrollView

<com.scu.miomin.shswiperefresh.core.SHSwipeRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.scu.miomin.shswiperefresh.view.ShareScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </com.scu.miomin.shswiperefresh.view.ShareScrollView>

</com.scu.miomin.shswiperefresh.core.SHSwipeRefreshLayout>

如需使用ListView,请使用SHListView

<com.scu.miomin.shswiperefresh.core.SHSwipeRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.scu.miomin.shswiperefresh.view.SHListView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
        </com.scu.miomin.shswiperefresh.view.ShareScrollView>

</com.scu.miomin.shswiperefresh.core.SHSwipeRefreshLayout>

其它属性

  • Guidance视图背景颜色 :
<attr name="guidance_view_bg_color" format="color|reference" /> 
  • Guidance视图中文字颜色 :
<attr name="guidance_text_color" format="color|reference" /> 
  • 进度条颜色 :
<attr name="progress_bar_color" format="color|reference" /> 
  • 进度条背景色 :
<attr name="progress_bg_color" format="color|reference" /> 
  • 下拉刷新文字描述 :
<attr name="refresh_text" format="string|reference" /> 
  • 上拉加载文字描述 :
<attr name="load_text" format="string|reference" /> 
  • 下拉刷新是否可用 :
<attr name="pull_refresh_enable" format="boolean" /> 
  • 上拉加载是否可用 :
<attr name="loadmore_enable" format="boolean" /> 

如何自定义HeaderView、FooterView

如果不设置,则使用默认的ProgressBar

可通过如下代码设置 :

  • 设置Resource ID
swipeRefreshLayout.setFooterView(R.layout.refresh_view);

  • 设置View
swipeRefreshLayout.setFooterView(myview);


事件监听

  
        swipeRefreshLayout.setOnRefreshListener(new SHSwipeRefreshLayout.SHSOnRefreshListener() {
               @Override
               public void onRefresh() {
                   swipeRefreshLayout.postDelayed(new Runnable() {
                       @Override
                       public void run() {
                           swipeRefreshLayout.finishRefresh();
                           Toast.makeText(MainActivity.this, "刷新完成", Toast.LENGTH_SHORT).show();
                       }
                   }, 1600);
               }
   
               @Override
               public void onLoading() {
                   swipeRefreshLayout.postDelayed(new Runnable() {
                       @Override
                       public void run() {
                           swipeRefreshLayout.finishLoadmore();
                           Toast.makeText(MainActivity.this, "加载完成", Toast.LENGTH_SHORT).show();
                       }
                   }, 1600);
               }
   
               /**
                * 监听下拉刷新过程中的状态改变
                * @param percent 当前下拉距离的百分比(0-1)
                * @param state 分三种状态{NOT_OVER_TRIGGER_POINT:还未到触发下拉刷新的距离;OVER_TRIGGER_POINT:已经到触发下拉刷新的距离;START:正在下拉刷新}
                */
               @Override
               public void onRefreshPulStateChange(float percent, int state) {
                   switch (state) {
                       case SHSwipeRefreshLayout.NOT_OVER_TRIGGER_POINT:
                           swipeRefreshLayout.setLoaderViewText("下拉刷新");
                           break;
                       case SHSwipeRefreshLayout.OVER_TRIGGER_POINT:
                           swipeRefreshLayout.setLoaderViewText("松开刷新");
                           break;
                       case SHSwipeRefreshLayout.START:
                           swipeRefreshLayout.setLoaderViewText("正在刷新");
                           break;
                   }
               }
   
               @Override
               public void onLoadmorePullStateChange(float percent, int state) {
                   switch (state) {
                       case SHSwipeRefreshLayout.NOT_OVER_TRIGGER_POINT:
                           textView.setText("上拉加载");
                           break;
                       case SHSwipeRefreshLayout.OVER_TRIGGER_POINT:
                           textView.setText("松开加载");
                           break;
                       case SHSwipeRefreshLayout.START:
                           textView.setText("正在加载...");
                           break;
                   }
               }
           });
       }
 
  • 可以在onRefreshPulStateChange和onLoadmorePullStateChange中,根据参数值来做一些自定义动画

其他接口

  • 结束下拉刷新
  
  swipeRefreshLayout.finishRefresh();
 
  • 结束上拉加载
  
  swipeRefreshLayout.finishLoadmore();
 

License

The MIT License (MIT)

Copyright (c) 2016 莫绪旻

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].