Skip to content

Commit 7832318

Browse files
committed
开启模糊
1 parent 22fd3f3 commit 7832318

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

dragsloplayout/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ android {
1111
targetSdkVersion 23
1212
versionCode 2
1313
versionName "1.0.2"
14-
// renderscriptTargetApi 23
15-
// renderscriptSupportModeEnabled true
14+
renderscriptTargetApi 23
15+
renderscriptSupportModeEnabled true
1616
}
1717
buildTypes {
1818
release {

dragsloplayout/src/main/java/com/dl7/drag/DragSlopLayout.java

+21-16
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22

33
import android.content.Context;
44
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;
513
import android.support.annotation.IntDef;
614
import android.support.v4.view.ViewCompat;
715
import android.support.v4.view.ViewPager;
816
import android.support.v4.widget.NestedScrollView;
917
import android.support.v4.widget.ScrollerCompat;
1018
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;
1123
import android.util.AttributeSet;
1224
import android.view.GestureDetector;
25+
import android.view.Gravity;
1326
import android.view.MotionEvent;
1427
import android.view.View;
1528
import android.view.ViewGroup;
@@ -231,12 +244,10 @@ protected void onDetachedFromWindow() {
231244
if (mAnimPresenter != null) {
232245
mAnimPresenter.stopAllAnimator();
233246
}
234-
/*
235247
if (mBitmapToBlur != null) {
236248
mBitmapToBlur.recycle();
237249
mBitmapToBlur = null;
238250
}
239-
*/
240251
}
241252

242253
/***********************************
@@ -545,7 +556,6 @@ public void run() {
545556
* @param percent 百分比
546557
*/
547558
private void _dragPositionChanged(int visibleHeight, float percent) {
548-
/*
549559
if (mEnableBlur && mBlurDrawable != null) {
550560
if (visibleHeight < mFixHeight) {
551561
return;
@@ -558,7 +568,6 @@ private void _dragPositionChanged(int visibleHeight, float percent) {
558568
}
559569
mBlurDrawable.setAlpha((int) (percent * 255));
560570
}
561-
*/
562571
if (visibleHeight >= 0) {
563572
ViewCompat.setTranslationY(mMainView, -visibleHeight * (1 - mCollapseParallax));
564573
}
@@ -592,11 +601,9 @@ private boolean _isNeedIntercept(MotionEvent ev) {
592601
if (mDragHelper.isViewUnder(mAttachScrollView, (int) ev.getX(), y) && mMode != MODE_ANIMATE) {
593602
return true;
594603
}
595-
/*
596604
if (mEnableBlur && mDragStatus == STATUS_EXPANDED) {
597605
return true;
598606
}
599-
*/
600607
return false;
601608
}
602609

@@ -833,7 +840,6 @@ public void setCustomAnimator(CustomViewAnimator inAnimator, CustomViewAnimator
833840
/*************************************
834841
* Blur
835842
********************************************/
836-
/*
837843
private final static int DEFAULT_SAMPLE_FACTOR = 4;
838844
private final static int DEFAULT_BLUR_RADIUS = 5;
839845

@@ -878,11 +884,11 @@ public void setBlurFull(boolean blurFull) {
878884
mIsBlurFull = blurFull;
879885
}
880886

881-
*//**
887+
/**
882888
* 设置使能模糊效果
883889
*
884890
* @param enableBlur
885-
*//*
891+
*/
886892
public void setEnableBlur(boolean enableBlur) {
887893
if (mEnableBlur == enableBlur) {
888894
return;
@@ -913,21 +919,21 @@ public void run() {
913919
}
914920
}
915921

916-
*//**
922+
/**
917923
* 刷新模糊视图
918-
*//*
924+
*/
919925
public void updateBlurView() {
920926
if (mEnableBlur) {
921927
mBlurDrawable = null;
922928
_handleBlurInThread();
923929
}
924930
}
925931

926-
*//**
932+
/**
927933
* 模糊视图
928934
*
929935
* @param view
930-
*//*
936+
*/
931937
private void _blurView(View view) {
932938
final int width = view.getWidth();
933939
final int height = view.getHeight();
@@ -990,9 +996,9 @@ private void _blurView(View view) {
990996
}
991997
}
992998

993-
*//**
999+
/**
9941000
* 在线程处理图片模糊
995-
*//*
1001+
*/
9961002
@SuppressWarnings("deprecation")
9971003
private void _handleBlurInThread() {
9981004
new Thread(new Runnable() {
@@ -1013,5 +1019,4 @@ public void run() {
10131019
}
10141020
}).start();
10151021
}
1016-
*/
10171022
}

simple/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ dependencies {
2727
testCompile 'junit:junit:4.12'
2828
compile 'com.android.support:appcompat-v7:23.4.0'
2929
compile project(':dragsloplayout')
30+
// compile 'com.github.Rukey7:DragSlopLayout:1.0.2'
3031
// photoview
3132
compile 'com.github.chrisbanes.photoview:library:1.2.4'
3233
// butterknife
3334
compile 'com.jakewharton:butterknife:8.4.0'
3435
apt 'com.jakewharton:butterknife-compiler:8.4.0'
3536

36-
compile 'com.eightbitlab:blurview:1.2.0'
3737
}

simple/src/main/java/com/dl7/simple/drag/activity/DragBlurActivity.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
4646
setContentView(R.layout.activity_drag_blur);
4747
ButterKnife.bind(this);
4848
initToolBar(mToolBar, true, "");
49-
// mDragLayout.setEnableBlur(true);
49+
mDragLayout.setEnableBlur(true);
5050
}
5151

5252
@Override
@@ -60,10 +60,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
6060
item.setChecked(true);
6161
switch (item.getItemId()) {
6262
case R.id.blur_local:
63-
// mDragLayout.setBlurFull(false);
63+
mDragLayout.setBlurFull(false);
6464
return true;
6565
case R.id.blur_full:
66-
// mDragLayout.setBlurFull(true);
66+
mDragLayout.setBlurFull(true);
6767
return true;
6868
}
6969
return super.onOptionsItemSelected(item);
@@ -77,7 +77,7 @@ public void onClick(View view) {
7777
break;
7878
case R.id.ll_next:
7979
mIvPhoto.setImageResource(mImgRes[mIndex++ % mImgRes.length]);
80-
// mDragLayout.updateBlurView();
80+
mDragLayout.updateBlurView();
8181
break;
8282
case R.id.ll_download:
8383
Toast.makeText(this, "下载", Toast.LENGTH_SHORT).show();

0 commit comments

Comments
 (0)