CollapsingRefresh

by ckrgithub

AppBarLayout+ViewPager+RecyclerView的刷新功能

69 Stars 12 Forks Last release: over 2 years ago (v1.0.1) Apache License 2.0 151 Commits 2 Releases

Available items

Free trial

CollapsingRefresh

Repository access
$5.00/ month

CollapsingRefresh

AppBarLayout+ViewPager+RecyclerView的刷新功能。最低支持api 16,recyclerView:26.1.0。

效果演示

Demo

下载 APK

依赖

添加依赖:

    dependencies {
        implementation 'ckrjfrog.Refresh:CollapsingRefresh:1.0.3'//gradle plugin 3.0(包含)以上使用
        //compile 'ckrjfrog.Refresh:CollapsingRefresh:1.0.3'//gradle plugin 3.0一下使用
    }

功能及使用

1.布局引用

     

    <com.scwang.smartrefresh.header.classicsheader android:id="@+id/classicsHeader" android:layout_width="match_parent" android:layout_height="wrap_content" app:srlclassicsspinnerstyle="Translate"></com.scwang.smartrefresh.header.classicsheader>

    <com.ckr.behavior.smoothrecyclerview android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="wrap_content" android:cliptopadding="false" android:paddingbottom="5dp" android:paddingleft="5dp" android:paddingright="5dp" android:paddingtop="0dp"></com.ckr.behavior.smoothrecyclerview>

    <com.scwang.smartrefresh.footer.classicsfooter android:layout_width="match_parent" android:layout_height="wrap_content" app:srlclassicsspinnerstyle="Translate"></com.scwang.smartrefresh.footer.classicsfooter>
</com.scwang.smartrefresh.smartrefreshlayout>

2.代码使用

  • 设置监听器
    appBarLayout.addOnOffsetChangedListener(this);
    recyclerView.setOnSmoothScrollListener(appBarLayout);
    smartRefreshLayout.setOnCollapsingListener(this);
    
  • 是否允许刷新
    @Override
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
        this.verticalOffset = verticalOffset;
        Logd(TAG, "onOffsetChanged: verticalOffset:" + this.verticalOffset);
        if (verticalOffset != 0) {
            boolean enableRefresh = smartRefreshLayout.isEnableRefresh();
            if (enableRefresh) {
                smartRefreshLayout.setEnableRefresh(false);
            }
        } else {
            smartRefreshLayout.setEnableRefresh(true);
        }
    }
    

感谢

SmartRefreshLayout

smooth-app-bar-layout

我的开源项目

PageRecyclerView:自定义RecyclerView实现翻页功能及无限轮播

FlexItemDecoration:recyclerView分割线的绘制

更新日志

  • 1.0.1-release

    • 修复:上拉刷新时拖动布局会闪烁的bug等一系列bug
    • 其他:重构代码完成
    • 依赖:ckrjfrog.Refresh:CollapsingRefresh:1.0.2
  • 1.0.1-beta

    • 实现AppBarLayout+ViewPager+RecyclerView的下拉刷新和上拉加载功能

License

Copyright 2018 ckrgithub

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.