A reusable Pull to Refresh library for Android. Support RecyclerView ListView ScrollView ViewPager CoordinatorLayout. Sliding damping, supports all directions. Drag and drop sort. You can use it like a standard RecyclerView -适用于Android的下拉刷新, 加载更多库. 滑动阻尼, 支持所有方向. 支持RecyclerView ListView ScrollView ViewPager CoordinatorLayout. 拖放排序.
A reusable Pull to Refresh library for Android.
Maven:
<dependency>
<groupId>com.dsiner.lib</groupId>
<artifactId>pulllayout</artifactId>
<version>2.0.0</version>
</dependency>
or Gradle:
// AndroidX
implementation 'com.dsiner.lib:pulllayout:2.0.0'
// Or Support
implementation 'com.dsiner.lib:pulllayout:1.0.4'
duration
factor
TimeInterpolator
left
top
right
bottom
). <com.d.lib.pulllayout.PullLayout
...
app:lib_pull_enable="true"
app:lib_pull_gravity="left|top|right|bottom">
<ViewGroup
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.d.lib.pulllayout.PullLayout>
attribute name | description |
---|---|
lib_pull_enable | Draggable |
lib_pull_gravity | Draggable direction |
<com.d.lib.pulllayout.PullRecyclerLayout
...
app:lib_pull_type="recyclerView" />
attribute name | description |
---|---|
lib_pull_type | Nested style - PullRecyclerview (by default) or RecyclerView or ListView |
Just implement Refreshable.OnRefreshListener
:
mPullList.setOnRefreshListener(new Refreshable.OnRefreshListener() {
@Override
public void onRefresh() {
// Refresh your data here
}
@Override
public void onLoadMore() {
// Load your data here
}
});
Just implement Pullable.OnPullListener
:
mPullList.addOnPullListener(new Pullable.OnPullListener() {
@Override
public void onPullStateChanged(Pullable pullable, int newState) {
// Callback method to be invoked when Pullable's scroll state changes.
}
@Override
public void onPulled(Pullable pullable, int dx, int dy) {
// Callback method to be invoked when the Pullable has been scrolled.
}
});
mPullList.refresh();
mPullList.loadMore();
mPullList.refreshSuccess();
mPullList.refreshError();
mPullList.loadMoreSuccess();
mPullList.loadMoreError();
mPullList.loadMoreNoMore();
For using custom views just implement IEdgeView
:
mPullList.setHeader(new HeaderView(context));
mPullList.setFooter(new FooterView(context));
public class SimpleAdapter extends CommonAdapter<Bean> {
public SimpleAdapter(Context context, List<Bean> datas, int layoutId) {
super(context, datas, layoutId);
}
@Override
public void convert(final int position, CommonHolder holder, Bean item) {
...
}
}
public class MultipleAdapter extends CommonAdapter<Bean> {
public MultipleAdapter(Context context, List<Bean> datas, MultiItemTypeSupport<Bean> multiItemTypeSupport) {
super(context, datas, multiItemTypeSupport);
}
@Override
public void convert(final int position, CommonHolder holder, Bean item) {
switch (holder.layoutId) {
...
}
}
}
mPullList.addHeaderView(view);
mPullList.addFooterView(view);
mPullList.removeHeaderView(view);
mPullList.removeFooterView(view);
More usage see Demo
Copyright 2018 D
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.