Skip to content

Commit 48e5ab1

Browse files
committed
Fix bugs of Bottom-settings, such as maxBottomHeight.
1 parent 8c5d88e commit 48e5ab1

File tree

9 files changed

+35
-31
lines changed

9 files changed

+35
-31
lines changed

app/src/main/java/com/lcodecore/twinklingrefreshlayout/CoordinateActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private void setupRecyclerView(RecyclerView rv) {
4444
refreshLayout.setFloatRefresh(true);
4545
refreshLayout.setEnableOverScroll(false);
4646
refreshLayout.setHeaderHeight(140);
47-
refreshLayout.setWaveHeight(240);
47+
refreshLayout.setMaxHeadHeight(240);
4848
refreshLayout.setTargetView(rv);
4949

5050
refreshCard();

app/src/main/java/com/lcodecore/twinklingrefreshlayout/NestedLayoutActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private void setupRecyclerView(RecyclerView rv) {
5050
// ProgressLayout headerView = new ProgressLayout(this);
5151
BezierLayout headerView = new BezierLayout(this);
5252
refreshLayout.setHeaderView(headerView);
53-
refreshLayout.setWaveHeight(140);
53+
refreshLayout.setMaxHeadHeight(140);
5454
// refreshLayout.setFloatRefresh(true);
5555
// refreshLayout.setPureScrollModeOn(true);
5656
refreshLayout.setOverScrollBottomShow(false);

app/src/main/java/com/lcodecore/twinklingrefreshlayout/PhotoActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private void setupRecyclerView(RecyclerView rv) {
4646
// ProgressLayout headerView = new ProgressLayout(this);
4747
BezierLayout headerView = new BezierLayout(this);
4848
refreshLayout.setHeaderView(headerView);
49-
refreshLayout.setWaveHeight(140);
49+
refreshLayout.setMaxHeadHeight(140);
5050
// refreshLayout.setFloatRefresh(true);
5151
// refreshLayout.setPureScrollModeOn(true);
5252
refreshLayout.setOverScrollBottomShow(false);

app/src/main/java/com/lcodecore/twinklingrefreshlayout/WebActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected void onCreate(Bundle savedInstanceState) {
2828
refreshLayout.setFloatRefresh(true);
2929
refreshLayout.setOverScrollRefreshShow(false);
3030
refreshLayout.setHeaderHeight(140);
31-
refreshLayout.setWaveHeight(240);
31+
refreshLayout.setMaxHeadHeight(240);
3232
refreshLayout.setOverScrollHeight(200);
3333
refreshLayout.setEnableLoadmore(false);
3434
header.setColorSchemeResources(R.color.Blue, R.color.Orange, R.color.Yellow, R.color.Green);

library/src/main/java/com/lcodecore/tkrefreshlayout/IBottomView.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,17 @@ public interface IBottomView {
1313
* 上拉准备加载更多的动作
1414
*
1515
* @param fraction 上拉高度与Bottom总高度之比
16-
* @param maxHeadHeight 头部可拉伸最大高度
17-
* @param headHeight 头部高度
16+
* @param maxBottomHeight 底部部可拉伸最大高度
17+
* @param bottomHeight 底部高度
1818
*/
19-
void onPullingUp(float fraction, float maxHeadHeight, float headHeight);
19+
void onPullingUp(float fraction, float maxBottomHeight, float bottomHeight);
2020

21-
void startAnim(float maxHeadHeight, float headHeight);
21+
void startAnim(float maxBottomHeight, float bottomHeight);
2222

2323
/**
2424
* 上拉释放过程
25-
*
26-
* @param fraction
27-
* @param maxHeadHeight
28-
* @param headHeight
2925
*/
30-
void onPullReleasing(float fraction, float maxHeadHeight, float headHeight);
26+
void onPullReleasing(float fraction, float maxBottomHeight, float bottomHeight);
3127

3228
void onFinish();
3329

library/src/main/java/com/lcodecore/tkrefreshlayout/TwinklingRefreshLayout.java

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
public class TwinklingRefreshLayout extends RelativeLayout implements PullListener {
2828

2929
//波浪的高度,最大扩展高度
30-
protected float mWaveHeight;
30+
protected float mMaxHeadHeight;
31+
protected float mMaxBottomHeight;
3132

3233
//头部的高度
3334
protected float mHeadHeight;
@@ -100,8 +101,9 @@ public TwinklingRefreshLayout(Context context, AttributeSet attrs, int defStyleA
100101

101102
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TwinklingRefreshLayout, defStyleAttr, 0);
102103
try {
103-
mWaveHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_wave_height, (int) DensityUtil.dp2px(context, 120));
104+
mMaxHeadHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_max_head_height, (int) DensityUtil.dp2px(context, 120));
104105
mHeadHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_head_height, (int) DensityUtil.dp2px(context, 80));
106+
mMaxBottomHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_max_bottom_height, (int) DensityUtil.dp2px(context, 60));
105107
mBottomHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_bottom_height, (int) DensityUtil.dp2px(context, 60));
106108
mOverScrollHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_overscroll_height, (int) mHeadHeight);
107109
enableLoadmore = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_loadmore, true);
@@ -177,7 +179,6 @@ private void initGestureDetector() {
177179

178180
@Override
179181
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
180-
//TODO 添加回调
181182
decorator.onFingerScroll(e1, e2, distanceX, distanceY, vy);
182183
return super.onScroll(e1, e2, distanceX, distanceY);
183184
}
@@ -423,11 +424,9 @@ public void run() {
423424

424425
/**
425426
* 设置wave的下拉高度
426-
*
427-
* @param waveHeightDp
428427
*/
429-
public void setWaveHeight(float waveHeightDp) {
430-
this.mWaveHeight = DensityUtil.dp2px(getContext(), waveHeightDp);
428+
public void setMaxHeadHeight(float maxHeightDp) {
429+
this.mMaxHeadHeight = DensityUtil.dp2px(getContext(), maxHeightDp);
431430
}
432431

433432
/**
@@ -437,6 +436,10 @@ public void setHeaderHeight(float headHeightDp) {
437436
this.mHeadHeight = DensityUtil.dp2px(getContext(), headHeightDp);
438437
}
439438

439+
public void setMaxBottomHeight(float maxBottomHeight){
440+
mMaxBottomHeight = DensityUtil.dp2px(getContext(),maxBottomHeight);
441+
}
442+
440443
/**
441444
* 设置底部高度
442445
*/
@@ -493,8 +496,9 @@ public void setPureScrollModeOn(boolean pureScrollModeOn) {
493496
if (pureScrollModeOn) {
494497
isOverScrollTopShow = false;
495498
isOverScrollBottomShow = false;
496-
setWaveHeight(mOverScrollHeight);
499+
setMaxHeadHeight(mOverScrollHeight);
497500
setHeaderHeight(mOverScrollHeight);
501+
setMaxBottomHeight(mOverScrollHeight);
498502
setBottomHeight(mOverScrollHeight);
499503
}
500504
}
@@ -535,38 +539,38 @@ private void setPullListener(PullListener pullListener) {
535539

536540
@Override
537541
public void onPullingDown(TwinklingRefreshLayout refreshLayout, float fraction) {
538-
mHeadView.onPullingDown(fraction, mWaveHeight, mHeadHeight);
542+
mHeadView.onPullingDown(fraction, mMaxHeadHeight, mHeadHeight);
539543
if (refreshListener != null) refreshListener.onPullingDown(refreshLayout, fraction);
540544
}
541545

542546
@Override
543547
public void onPullingUp(TwinklingRefreshLayout refreshLayout, float fraction) {
544-
mBottomView.onPullingUp(fraction, mWaveHeight, mHeadHeight);
548+
mBottomView.onPullingUp(fraction, mMaxHeadHeight, mHeadHeight);
545549
if (refreshListener != null) refreshListener.onPullingUp(refreshLayout, fraction);
546550
}
547551

548552
@Override
549553
public void onPullDownReleasing(TwinklingRefreshLayout refreshLayout, float fraction) {
550-
mHeadView.onPullReleasing(fraction, mWaveHeight, mHeadHeight);
554+
mHeadView.onPullReleasing(fraction, mMaxHeadHeight, mHeadHeight);
551555
if (refreshListener != null)
552556
refreshListener.onPullDownReleasing(refreshLayout, fraction);
553557
}
554558

555559
@Override
556560
public void onPullUpReleasing(TwinklingRefreshLayout refreshLayout, float fraction) {
557-
mBottomView.onPullReleasing(fraction, mWaveHeight, mHeadHeight);
561+
mBottomView.onPullReleasing(fraction, mMaxBottomHeight, mBottomHeight);
558562
if (refreshListener != null) refreshListener.onPullUpReleasing(refreshLayout, fraction);
559563
}
560564

561565
@Override
562566
public void onRefresh(TwinklingRefreshLayout refreshLayout) {
563-
mHeadView.startAnim(mWaveHeight, mHeadHeight);
567+
mHeadView.startAnim(mMaxHeadHeight, mHeadHeight);
564568
if (refreshListener != null) refreshListener.onRefresh(refreshLayout);
565569
}
566570

567571
@Override
568572
public void onLoadMore(TwinklingRefreshLayout refreshLayout) {
569-
mBottomView.startAnim(mWaveHeight, mHeadHeight);
573+
mBottomView.startAnim(mMaxBottomHeight, mBottomHeight);
570574
if (refreshListener != null) refreshListener.onLoadMore(refreshLayout);
571575
}
572576

@@ -628,7 +632,7 @@ public AnimProcessor getAnimProcessor() {
628632
}
629633

630634
public float getMaxHeadHeight() {
631-
return mWaveHeight;
635+
return mMaxHeadHeight;
632636
}
633637

634638
public int getHeadHeight() {
@@ -639,6 +643,9 @@ public int getExtraHeadHeight() {
639643
return mExtraHeadLayout.getHeight();
640644
}
641645

646+
public int getMaxBottomHeight(){
647+
return (int) mMaxBottomHeight;
648+
}
642649
public int getBottomHeight() {
643650
return (int) mBottomHeight;
644651
}

library/src/main/java/com/lcodecore/tkrefreshlayout/processor/AnimProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void scrollHeadByMove(float moveY) {
4646
}
4747

4848
public void scrollBottomByMove(float moveY) {
49-
float offsetY = decelerateInterpolator.getInterpolation(moveY / cp.getBottomHeight() / 2) * moveY / 2;
49+
float offsetY = decelerateInterpolator.getInterpolation(moveY / cp.getMaxBottomHeight() / 2) * moveY / 2;
5050

5151
if (cp.getFooter().getVisibility() != VISIBLE) cp.getFooter().setVisibility(VISIBLE);
5252

library/src/main/java/com/lcodecore/tkrefreshlayout/processor/RefreshProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public boolean dealTouchEvent(MotionEvent e) {
5757
cp.getAnimProcessor().scrollHeadByMove(dy);
5858
} else if (cp.isStatePBU()) {
5959
//加载更多的动作
60-
dy = Math.min(cp.getBottomHeight() * 2, Math.abs(dy));
60+
dy = Math.min(cp.getMaxBottomHeight() * 2, Math.abs(dy));
6161
dy = Math.max(0, dy);
6262
cp.getAnimProcessor().scrollBottomByMove(dy);
6363
}

library/src/main/res/values/attrs.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<declare-styleable name="TwinklingRefreshLayout">
4-
<attr name="tr_wave_height" format="dimension"/>
4+
<attr name="tr_max_head_height" format="dimension"/>
55
<attr name="tr_head_height" format="dimension"/>
6+
<attr name="tr_max_bottom_height" format="dimension"/>
67
<attr name="tr_bottom_height" format="dimension"/>
78
<attr name="tr_overscroll_height" format="dimension"/>
89
<attr name="tr_enable_loadmore" format="boolean"/>

0 commit comments

Comments
 (0)