Skip to content

Commit

Permalink
add set the pull-down refresh resisitance factor interface
Browse files Browse the repository at this point in the history
  • Loading branch information
lucklygaj committed Feb 14, 2017
1 parent b695353 commit f9152b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ task clean(type: Delete) {
* You need to add library dependencies infomation to build.gradle in your module.

```
compile 'com.github.anzaizai:EasyRefreshLayout:1.1.4'
compile 'com.github.anzaizai:EasyRefreshLayout:1.1.5'
```
* last releases version is 1.1.4 can be use
* last releases version is 1.1.5 can be use

## step 3

Expand Down
16 changes: 8 additions & 8 deletions library/src/main/java/com/ajguan/library/EasyRefreshLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class EasyRefreshLayout extends ViewGroup {
private static long SHOW_COMPLETED_TIME = 500;
private static long SCROLL_TO_LOADING_DURATION = 500;
private static long SHOW_SCROLL_DOWN_DURATION = 300;
private static double PUll_RESISTANCE = 2;
private double pull_resistance = 2.0f;

private State state = State.RESET;

Expand Down Expand Up @@ -395,7 +395,7 @@ private void moveSpinner(float offsetY) {
float extraOS = nextOffsetTop - totalDragDistance;
float slingshotDist = totalDragDistance;
float tensionSlingshotPercent = Math.max(0, Math.min(extraOS, slingshotDist * 2) / slingshotDist);
float tensionPercent = (float) (tensionSlingshotPercent - Math.pow(tensionSlingshotPercent / PUll_RESISTANCE, 2));
float tensionPercent = (float) (tensionSlingshotPercent - Math.pow(tensionSlingshotPercent / this.pull_resistance, 2));

if (offset > 0) { // 下拉的时候才添加阻力
offset = (int) (offset * (1f - tensionPercent));
Expand Down Expand Up @@ -995,16 +995,16 @@ public void setHideLoadViewAnimatorDuration(long showCompletedTime) {
SHOW_COMPLETED_TIME = showCompletedTime;
}

public static double getPUll_RESISTANCE() {
return PUll_RESISTANCE;

public double getPullResistance() {
return this.pull_resistance;
}

/**
* Set the pull-down refresh resistance factor
* @param PUll_RESISTANCE resistance factor
* @param PullResistance resistance factor
*/
public static void setPUll_RESISTANCE(double PUll_RESISTANCE) {
EasyRefreshLayout.PUll_RESISTANCE = PUll_RESISTANCE;
public void setPullResistance(double PullResistance) {
this.pull_resistance = PullResistance;
}
}

0 comments on commit f9152b9

Please sign in to comment.