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

dependencies {
implementation 'ckrjfrog.Refresh:CollapsingRefresh:1.0.2'//gradle plugin 3.0(包含)以上使用
//compile 'ckrjfrog.Refresh:CollapsingRefresh:1.0.2'//gradle plugin 3.0一下使用
}
<com.scwang.smartrefresh.SmartRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlDisableContentWhenLoading="false"
app:srlDisableContentWhenRefresh="false"
app:srlEnableAutoLoadmore="false"
app:srlEnableHeaderTranslationContent="true"
app:srlEnableLoadmore="true">
<com.scwang.smartrefresh.header.ClassicsHeader
android:id="@+id/classicsHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srlClassicsSpinnerStyle="Translate"/>
<com.ckr.smoothappbarlayout.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.scwang.smartrefresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srlClassicsSpinnerStyle="Translate"/>
</com.scwang.smartrefresh.SmartRefreshLayout>
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);
}
}
PageRecyclerView:自定义RecyclerView实现翻页功能及无限轮播
FlexItemDecoration:recyclerView分割线的绘制
依赖:ckrjfrog.Refresh:CollapsingRefresh:1.0.2
1.0.1-beta
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.
$ claude mcp add CollapsingRefresh \
-- python -m otcore.mcp_server <graph>