Skip to content

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. 拖放排序.

Notifications You must be signed in to change notification settings

Dsiner/PullLayout

Repository files navigation

PullLayout for Android

License API Download

A reusable Pull to Refresh library for Android.

Set up

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'

Features

  • Supports both Pulling Down from the top, and Pulling Up from the bottom (or even both).
  • Animated Scrolling for all devices.
  • Currently works with:
    • RecyclerView
    • ListView
    • ScrollView
    • WebView
    • ViewPager
    • CoordinatorLayout
  • Integrated End of List Listener for use of detecting when the user has scrolled to the bottom.
  • Callback method to be invoked when Pullable's scroll state changes.
  • Dynamically add headers and footers.
  • Support duration factor TimeInterpolator
  • Sliding damping, supports all directions (left top right bottom).
  • Multi-type adapter support.
  • Drag and drop sort.
  • Lots of Customisation options!

Screenshot

Artboard

How do I use it?

Configuration

Via XML

Damp

    <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

Pull to Refresh list

    <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

Animation

Refreshing callback

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
    }
});

Pulling callback

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.
    }
});

To start or stop animation:

mPullList.refresh();
mPullList.loadMore();
mPullList.refreshSuccess();
mPullList.refreshError();
mPullList.loadMoreSuccess();
mPullList.loadMoreError();
mPullList.loadMoreNoMore();

Using custom views

For using custom views just implement IEdgeView:

mPullList.setHeader(new HeaderView(context));
mPullList.setFooter(new FooterView(context));

Adapter

Simple adapter

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) {
        ...
    }
}

Multiple adapter

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) {
            ...
        }
    }
}

Support headers or footers

mPullList.addHeaderView(view);
mPullList.addFooterView(view);

mPullList.removeHeaderView(view);
mPullList.removeFooterView(view);

More usage see Demo

Thanks

Licence

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.

About

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. 拖放排序.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages