Home

Awesome

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

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 namedescription
lib_pull_enableDraggable
lib_pull_gravityDraggable direction

Pull to Refresh list

    <com.d.lib.pulllayout.PullRecyclerLayout
        ...
        app:lib_pull_type="recyclerView" />
attribute namedescription
lib_pull_typeNested 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.