Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Dsiner committed Dec 16, 2020
1 parent b016be5 commit e64b305
Show file tree
Hide file tree
Showing 57 changed files with 828 additions and 662 deletions.
178 changes: 152 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
[![API](https://img.shields.io/badge/API-11%2B-green.svg?style=flat)](https://android-arsenal.com/api?level=11)
[![Download](https://api.bintray.com/packages/dsiner/maven/pulllayout/images/download.svg) ](https://bintray.com/dsiner/maven/pulllayout/_latestVersion)

> Damping effect & Pull down refresh, load more.
## Demo
<p>
<img src="https://github.com/Dsiner/Resouce/blob/master/lib/PullLayout/pulllayout.gif" width="320" alt="Screenshot"/>
</p>
> A reusable Pull to Refresh library for Android.
## Set up
Maven:
Expand All @@ -25,21 +20,39 @@ or Gradle:
implementation 'com.dsiner.lib:pulllayout:1.0.1'
```

## Chapter 1 Sliding damping

### Support
- [x] ViewGroup
- [x] ListView
- [x] RecyclerView
- [x] ScrollView

### Usage
```java
## 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](https://github.com/Dsiner/PullLayout/blob/master/app/src/main/java/com/d/pulllayout/MainActivity.java) options!

## Screenshot
![Artboard](https://github.com/Dsiner/Resouce/blob/master/lib/PullLayout/pulllayout.png)

## How do I use it?

## Configuration ##

### Via XML ###
#### Damp ####
```XML
<com.d.lib.pulllayout.PullLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
...
app:lib_pull_enable="true"
app:lib_pull_gravity="top|left|right">
app:lib_pull_gravity="left|top|right|bottom">

<ViewGroup
android:layout_width="match_parent"
Expand All @@ -48,17 +61,130 @@ implementation 'com.dsiner.lib:pulllayout:1.0.1'
</com.d.lib.pulllayout.PullLayout>
```

## Chapter 2 Pull down refresh, load more
| attribute name | description |
|---|---|
| lib_pull_enable | Draggable |
| lib_pull_gravity | Draggable direction |

#### Pull to Refresh list ####
```XML
<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`:

```Java

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`:

```Java

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: ###

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

### Using custom views ###
For using custom views just implement `IEdgeView`:

```Java

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

## Adapter ##

### Simple adapter ###
```Java
public class SimpleAdapter extends CommonAdapter<Bean> {

### Support
- [x] PullRecyclerLayout
- [x] PullRecyclerView
- [x] RecyclerView
- [x] ListView
- [x] PullRecyclerView
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 ###
```Java
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 ###
```Java
.addHeaderView(view);
.addFooterView(view);

.removeHeaderView(view);
.removeFooterView(view);
```

More usage see [Demo](app/src/main/java/com/d/pulllayout/MainActivity.java)

## Thanks
- [Android-PullToRefresh](https://github.com/chrisbanes/Android-PullToRefresh) - A pull to refresh widget
- [XRecyclerView](https://github.com/jianghejie/XRecyclerView) - RecyclerView that implements pullrefresh , loadingmore and header featrues

## Licence

```txt
Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ dependencies {
implementation 'com.android.support:design:27.1.1'

implementation project(':lib')
implementation project(':integration:edge')
implementation project(':integration:edge_ripple')
implementation project(':integration:edge_elastic')
implementation('com.dsiner.lib:common:1.1.1') {
exclude group: 'com.dsiner.lib', module: 'pulllayout'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.animation.BounceInterpolator;
import android.view.animation.DecelerateInterpolator;

import com.d.lib.common.component.loader.v4.AbsFragment;
import com.d.lib.common.component.mvp.MvpView;
import com.d.lib.pulllayout.Pullable;
import com.d.lib.pulllayout.Refreshable;
import com.d.lib.pulllayout.edge.ripple.ExtendFooterView;
import com.d.lib.pulllayout.edge.ripple.ExtendHeaderView;
import com.d.lib.pulllayout.edge.ripple.FooterView;
import com.d.lib.pulllayout.edge.ripple.HeaderView;
import com.d.lib.pulllayout.loader.RecyclerAdapter;
import com.d.pulllayout.R;
import com.d.pulllayout.list.activity.ListActivity;
import com.d.pulllayout.list.adapter.rv.SimpleAdapter;
import com.d.pulllayout.list.model.Bean;
import com.d.pulllayout.list.model.EdgeType;
import com.d.pulllayout.list.model.ListType;
import com.d.pulllayout.list.presenter.LoadPresenter;

Expand Down Expand Up @@ -70,12 +64,10 @@ protected void initList() {
@Override
protected void init() {
super.init();
((Refreshable) mPullList).setHeader(new HeaderView(mContext));
((Refreshable) mPullList).setFooter(new FooterView(mContext));
((Refreshable) mPullList).setAutoLoadMore(true);
mPullList.setHeader(EdgeType.getEdgeView(mContext, mEdgeType)[0]);
mPullList.setFooter(EdgeType.getEdgeView(mContext, mEdgeType)[1]);
((Pullable) mPullList).setPullFactor(0.49f);
((Pullable) mPullList).setDuration(250);
((Pullable) mPullList).setInterpolator(new DecelerateInterpolator());
((Pullable) mPullList).addOnPullListener(new Pullable.OnPullListener() {
@Override
public void onPullStateChanged(Pullable pullable, int newState) {
Expand Down
34 changes: 34 additions & 0 deletions app/src/main/java/com/d/pulllayout/list/model/EdgeType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.d.pulllayout.list.model;

import android.content.Context;

import com.d.lib.common.view.popup.MenuPopup;
import com.d.lib.pulllayout.edge.IEdgeView;
import com.d.pulllayout.R;

import java.util.Arrays;
Expand All @@ -9,6 +12,7 @@
public class EdgeType {
public static final int TYPE_CLASSIC = 0;
public static final int TYPE_RIPPLE = 1;
public static final int TYPE_ELASTIC = 2;

public static List<MenuPopup.Bean> getMenus(int type) {
return Arrays.asList(
Expand All @@ -18,6 +22,10 @@ public static List<MenuPopup.Bean> getMenus(int type) {
: R.color.lib_pub_color_white, false),
new MenuPopup.Bean("Ripple",
type == EdgeType.TYPE_RIPPLE ?
R.color.lib_pub_color_main
: R.color.lib_pub_color_white, false),
new MenuPopup.Bean("Elastic",
type == EdgeType.TYPE_ELASTIC ?
R.color.lib_pub_color_main
: R.color.lib_pub_color_white, false));
}
Expand All @@ -27,8 +35,34 @@ public static String getTypeTitle(int type) {
return "Classic";
} else if (TYPE_RIPPLE == type) {
return "Ripple";
} else if (TYPE_ELASTIC == type) {
return "Elastic";
} else {
return "";
}
}

public static IEdgeView[] getEdgeView(Context context, int type) {
if (TYPE_CLASSIC == type) {
return new IEdgeView[]{
new com.d.lib.pulllayout.edge.arrow.HeaderView(context),
new com.d.lib.pulllayout.edge.arrow.FooterView(context)
};
} else if (TYPE_RIPPLE == type) {
return new IEdgeView[]{
new com.d.lib.pulllayout.edge.ripple.HeaderView(context),
new com.d.lib.pulllayout.edge.ripple.FooterView(context)
};
} else if (TYPE_ELASTIC == type) {
return new IEdgeView[]{
new com.d.lib.pulllayout.edge.elastic.HeaderView(context),
new com.d.lib.pulllayout.edge.arrow.FooterView(context)
};
} else {
return new IEdgeView[]{
new com.d.lib.pulllayout.edge.arrow.HeaderView(context),
new com.d.lib.pulllayout.edge.arrow.FooterView(context)
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:lib_pull_type="listView" />
app:lib_pull_type="list_view" />
</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:lib_pull_type="recyclerView" />
app:lib_pull_type="recycler_view" />
</FrameLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">PullLayout</string>
<string name="page_provide">页面由pulllayout.lib.d.com提供</string>
<string name="technical_support">[email protected]提供技术支持</string>
</resources>
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">PullLayout</string>
<string name="page_provide">页面由pulllayout.lib.d.com提供</string>
<string name="technical_support">Dsiner@github.com提供技术支持</string>
<string name="page_provide">Page provided by pulllayout.lib.d.com</string>
<string name="technical_support">Dsiner@github.com provides technical support</string>
</resources>
2 changes: 0 additions & 2 deletions integration/edge/src/main/AndroidManifest.xml

This file was deleted.

Loading

0 comments on commit e64b305

Please sign in to comment.