2
2
3
3
import android .content .Context ;
4
4
import android .content .res .TypedArray ;
5
+ import android .graphics .Bitmap ;
6
+ import android .graphics .Canvas ;
7
+ import android .graphics .Color ;
8
+ import android .graphics .drawable .BitmapDrawable ;
9
+ import android .graphics .drawable .ClipDrawable ;
10
+ import android .graphics .drawable .ColorDrawable ;
11
+ import android .graphics .drawable .Drawable ;
12
+ import android .os .Build ;
5
13
import android .support .annotation .IntDef ;
6
14
import android .support .v4 .view .ViewCompat ;
7
15
import android .support .v4 .view .ViewPager ;
8
16
import android .support .v4 .widget .NestedScrollView ;
9
17
import android .support .v4 .widget .ScrollerCompat ;
10
18
import android .support .v4 .widget .ViewDragHelper ;
19
+ import android .support .v8 .renderscript .Allocation ;
20
+ import android .support .v8 .renderscript .Element ;
21
+ import android .support .v8 .renderscript .RenderScript ;
22
+ import android .support .v8 .renderscript .ScriptIntrinsicBlur ;
11
23
import android .util .AttributeSet ;
12
24
import android .view .GestureDetector ;
25
+ import android .view .Gravity ;
13
26
import android .view .MotionEvent ;
14
27
import android .view .View ;
15
28
import android .view .ViewGroup ;
@@ -231,12 +244,10 @@ protected void onDetachedFromWindow() {
231
244
if (mAnimPresenter != null ) {
232
245
mAnimPresenter .stopAllAnimator ();
233
246
}
234
- /*
235
247
if (mBitmapToBlur != null ) {
236
248
mBitmapToBlur .recycle ();
237
249
mBitmapToBlur = null ;
238
250
}
239
- */
240
251
}
241
252
242
253
/***********************************
@@ -545,7 +556,6 @@ public void run() {
545
556
* @param percent 百分比
546
557
*/
547
558
private void _dragPositionChanged (int visibleHeight , float percent ) {
548
- /*
549
559
if (mEnableBlur && mBlurDrawable != null ) {
550
560
if (visibleHeight < mFixHeight ) {
551
561
return ;
@@ -558,7 +568,6 @@ private void _dragPositionChanged(int visibleHeight, float percent) {
558
568
}
559
569
mBlurDrawable .setAlpha ((int ) (percent * 255 ));
560
570
}
561
- */
562
571
if (visibleHeight >= 0 ) {
563
572
ViewCompat .setTranslationY (mMainView , -visibleHeight * (1 - mCollapseParallax ));
564
573
}
@@ -592,11 +601,9 @@ private boolean _isNeedIntercept(MotionEvent ev) {
592
601
if (mDragHelper .isViewUnder (mAttachScrollView , (int ) ev .getX (), y ) && mMode != MODE_ANIMATE ) {
593
602
return true ;
594
603
}
595
- /*
596
604
if (mEnableBlur && mDragStatus == STATUS_EXPANDED ) {
597
605
return true ;
598
606
}
599
- */
600
607
return false ;
601
608
}
602
609
@@ -833,7 +840,6 @@ public void setCustomAnimator(CustomViewAnimator inAnimator, CustomViewAnimator
833
840
/*************************************
834
841
* Blur
835
842
********************************************/
836
- /*
837
843
private final static int DEFAULT_SAMPLE_FACTOR = 4 ;
838
844
private final static int DEFAULT_BLUR_RADIUS = 5 ;
839
845
@@ -878,11 +884,11 @@ public void setBlurFull(boolean blurFull) {
878
884
mIsBlurFull = blurFull ;
879
885
}
880
886
881
- */ /**
887
+ /**
882
888
* 设置使能模糊效果
883
889
*
884
890
* @param enableBlur
885
- */ /*
891
+ */
886
892
public void setEnableBlur (boolean enableBlur ) {
887
893
if (mEnableBlur == enableBlur ) {
888
894
return ;
@@ -913,21 +919,21 @@ public void run() {
913
919
}
914
920
}
915
921
916
- */ /**
922
+ /**
917
923
* 刷新模糊视图
918
- */ /*
924
+ */
919
925
public void updateBlurView () {
920
926
if (mEnableBlur ) {
921
927
mBlurDrawable = null ;
922
928
_handleBlurInThread ();
923
929
}
924
930
}
925
931
926
- */ /**
932
+ /**
927
933
* 模糊视图
928
934
*
929
935
* @param view
930
- */ /*
936
+ */
931
937
private void _blurView (View view ) {
932
938
final int width = view .getWidth ();
933
939
final int height = view .getHeight ();
@@ -990,9 +996,9 @@ private void _blurView(View view) {
990
996
}
991
997
}
992
998
993
- */ /**
999
+ /**
994
1000
* 在线程处理图片模糊
995
- */ /*
1001
+ */
996
1002
@ SuppressWarnings ("deprecation" )
997
1003
private void _handleBlurInThread () {
998
1004
new Thread (new Runnable () {
@@ -1013,5 +1019,4 @@ public void run() {
1013
1019
}
1014
1020
}).start ();
1015
1021
}
1016
- */
1017
1022
}
0 commit comments