27
27
public class TwinklingRefreshLayout extends RelativeLayout implements PullListener {
28
28
29
29
//波浪的高度,最大扩展高度
30
- protected float mWaveHeight ;
30
+ protected float mMaxHeadHeight ;
31
+ protected float mMaxBottomHeight ;
31
32
32
33
//头部的高度
33
34
protected float mHeadHeight ;
@@ -100,8 +101,9 @@ public TwinklingRefreshLayout(Context context, AttributeSet attrs, int defStyleA
100
101
101
102
TypedArray a = context .obtainStyledAttributes (attrs , R .styleable .TwinklingRefreshLayout , defStyleAttr , 0 );
102
103
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 ));
104
105
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 ));
105
107
mBottomHeight = a .getDimensionPixelSize (R .styleable .TwinklingRefreshLayout_tr_bottom_height , (int ) DensityUtil .dp2px (context , 60 ));
106
108
mOverScrollHeight = a .getDimensionPixelSize (R .styleable .TwinklingRefreshLayout_tr_overscroll_height , (int ) mHeadHeight );
107
109
enableLoadmore = a .getBoolean (R .styleable .TwinklingRefreshLayout_tr_enable_loadmore , true );
@@ -177,7 +179,6 @@ private void initGestureDetector() {
177
179
178
180
@ Override
179
181
public boolean onScroll (MotionEvent e1 , MotionEvent e2 , float distanceX , float distanceY ) {
180
- //TODO 添加回调
181
182
decorator .onFingerScroll (e1 , e2 , distanceX , distanceY , vy );
182
183
return super .onScroll (e1 , e2 , distanceX , distanceY );
183
184
}
@@ -423,11 +424,9 @@ public void run() {
423
424
424
425
/**
425
426
* 设置wave的下拉高度
426
- *
427
- * @param waveHeightDp
428
427
*/
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 );
431
430
}
432
431
433
432
/**
@@ -437,6 +436,10 @@ public void setHeaderHeight(float headHeightDp) {
437
436
this .mHeadHeight = DensityUtil .dp2px (getContext (), headHeightDp );
438
437
}
439
438
439
+ public void setMaxBottomHeight (float maxBottomHeight ){
440
+ mMaxBottomHeight = DensityUtil .dp2px (getContext (),maxBottomHeight );
441
+ }
442
+
440
443
/**
441
444
* 设置底部高度
442
445
*/
@@ -493,8 +496,9 @@ public void setPureScrollModeOn(boolean pureScrollModeOn) {
493
496
if (pureScrollModeOn ) {
494
497
isOverScrollTopShow = false ;
495
498
isOverScrollBottomShow = false ;
496
- setWaveHeight (mOverScrollHeight );
499
+ setMaxHeadHeight (mOverScrollHeight );
497
500
setHeaderHeight (mOverScrollHeight );
501
+ setMaxBottomHeight (mOverScrollHeight );
498
502
setBottomHeight (mOverScrollHeight );
499
503
}
500
504
}
@@ -535,38 +539,38 @@ private void setPullListener(PullListener pullListener) {
535
539
536
540
@ Override
537
541
public void onPullingDown (TwinklingRefreshLayout refreshLayout , float fraction ) {
538
- mHeadView .onPullingDown (fraction , mWaveHeight , mHeadHeight );
542
+ mHeadView .onPullingDown (fraction , mMaxHeadHeight , mHeadHeight );
539
543
if (refreshListener != null ) refreshListener .onPullingDown (refreshLayout , fraction );
540
544
}
541
545
542
546
@ Override
543
547
public void onPullingUp (TwinklingRefreshLayout refreshLayout , float fraction ) {
544
- mBottomView .onPullingUp (fraction , mWaveHeight , mHeadHeight );
548
+ mBottomView .onPullingUp (fraction , mMaxHeadHeight , mHeadHeight );
545
549
if (refreshListener != null ) refreshListener .onPullingUp (refreshLayout , fraction );
546
550
}
547
551
548
552
@ Override
549
553
public void onPullDownReleasing (TwinklingRefreshLayout refreshLayout , float fraction ) {
550
- mHeadView .onPullReleasing (fraction , mWaveHeight , mHeadHeight );
554
+ mHeadView .onPullReleasing (fraction , mMaxHeadHeight , mHeadHeight );
551
555
if (refreshListener != null )
552
556
refreshListener .onPullDownReleasing (refreshLayout , fraction );
553
557
}
554
558
555
559
@ Override
556
560
public void onPullUpReleasing (TwinklingRefreshLayout refreshLayout , float fraction ) {
557
- mBottomView .onPullReleasing (fraction , mWaveHeight , mHeadHeight );
561
+ mBottomView .onPullReleasing (fraction , mMaxBottomHeight , mBottomHeight );
558
562
if (refreshListener != null ) refreshListener .onPullUpReleasing (refreshLayout , fraction );
559
563
}
560
564
561
565
@ Override
562
566
public void onRefresh (TwinklingRefreshLayout refreshLayout ) {
563
- mHeadView .startAnim (mWaveHeight , mHeadHeight );
567
+ mHeadView .startAnim (mMaxHeadHeight , mHeadHeight );
564
568
if (refreshListener != null ) refreshListener .onRefresh (refreshLayout );
565
569
}
566
570
567
571
@ Override
568
572
public void onLoadMore (TwinklingRefreshLayout refreshLayout ) {
569
- mBottomView .startAnim (mWaveHeight , mHeadHeight );
573
+ mBottomView .startAnim (mMaxBottomHeight , mBottomHeight );
570
574
if (refreshListener != null ) refreshListener .onLoadMore (refreshLayout );
571
575
}
572
576
@@ -628,7 +632,7 @@ public AnimProcessor getAnimProcessor() {
628
632
}
629
633
630
634
public float getMaxHeadHeight () {
631
- return mWaveHeight ;
635
+ return mMaxHeadHeight ;
632
636
}
633
637
634
638
public int getHeadHeight () {
@@ -639,6 +643,9 @@ public int getExtraHeadHeight() {
639
643
return mExtraHeadLayout .getHeight ();
640
644
}
641
645
646
+ public int getMaxBottomHeight (){
647
+ return (int ) mMaxBottomHeight ;
648
+ }
642
649
public int getBottomHeight () {
643
650
return (int ) mBottomHeight ;
644
651
}
0 commit comments