Skip to content

Commit

Permalink
屏蔽模糊
Browse files Browse the repository at this point in the history
  • Loading branch information
Rukey7 committed Feb 10, 2017
1 parent f7c87a3 commit 8725f17
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 35 deletions.
4 changes: 2 additions & 2 deletions dragsloplayout/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
targetSdkVersion 23
versionCode 4
versionName "1.0.4"
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
// renderscriptTargetApi 23
// renderscriptSupportModeEnabled true
}
buildTypes {
release {
Expand Down
45 changes: 16 additions & 29 deletions dragsloplayout/src/main/java/com/dl7/drag/DragSlopLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,15 @@

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.IntDef;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.NestedScrollView;
import android.support.v4.widget.ScrollerCompat;
import android.support.v4.widget.ViewDragHelper;
import android.support.v8.renderscript.Allocation;
import android.support.v8.renderscript.Element;
import android.support.v8.renderscript.RenderScript;
import android.support.v8.renderscript.ScriptIntrinsicBlur;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
Expand Down Expand Up @@ -260,10 +247,10 @@ protected void onDetachedFromWindow() {
if (mAnimPresenter != null) {
mAnimPresenter.stopAllAnimator();
}
if (mBitmapToBlur != null) {
/*if (mBitmapToBlur != null) {
mBitmapToBlur.recycle();
mBitmapToBlur = null;
}
}*/
}

/***********************************
Expand Down Expand Up @@ -607,7 +594,7 @@ private void _dragPositionChanged(int visibleHeight, float percent) {
mIsUp = (mDragViewTop < mLastDragViewTop);
mLastDragViewTop = mDragViewTop;
}
if (mEnableBlur && mBlurDrawable != null) {
/*if (mEnableBlur && mBlurDrawable != null) {
if (visibleHeight < mFixHeight) {
return;
}
Expand All @@ -618,7 +605,7 @@ private void _dragPositionChanged(int visibleHeight, float percent) {
mBlurDrawable.setLevel(blurLevel);
}
mBlurDrawable.setAlpha((int) (percent * 255));
}
}*/
if (visibleHeight >= 0) {
ViewCompat.setTranslationY(mMainView, -visibleHeight * (1 - mCollapseParallax));
}
Expand Down Expand Up @@ -655,9 +642,9 @@ private boolean _isNeedIntercept(MotionEvent ev) {
if (mDragHelper.isViewUnder(mAttachScrollView, (int) ev.getX(), y) && mMode != MODE_ANIMATE) {
return true;
}
if (mEnableBlur && mDragStatus == STATUS_EXPANDED) {
/*if (mEnableBlur && mDragStatus == STATUS_EXPANDED) {
return true;
}
}*/
return false;
}

Expand Down Expand Up @@ -894,7 +881,7 @@ public void setCustomAnimator(CustomViewAnimator inAnimator, CustomViewAnimator
/*************************************
* Blur
********************************************/
private final static int DEFAULT_SAMPLE_FACTOR = 4;
/*private final static int DEFAULT_SAMPLE_FACTOR = 4;
private final static int DEFAULT_BLUR_RADIUS = 5;
// 使能模糊
Expand Down Expand Up @@ -938,11 +925,11 @@ public void setBlurFull(boolean blurFull) {
mIsBlurFull = blurFull;
}
/**
*//**
* 设置使能模糊效果
*
* @param enableBlur
*/
*//*
public void setEnableBlur(boolean enableBlur) {
if (mEnableBlur == enableBlur) {
return;
Expand Down Expand Up @@ -973,21 +960,21 @@ public void run() {
}
}
/**
*//**
* 刷新模糊视图
*/
*//*
public void updateBlurView() {
if (mEnableBlur) {
mBlurDrawable = null;
_handleBlurInThread();
}
}
/**
*//**
* 模糊视图
*
* @param view
*/
*//*
private void _blurView(View view) {
final int width = view.getWidth();
final int height = view.getHeight();
Expand Down Expand Up @@ -1050,9 +1037,9 @@ private void _blurView(View view) {
}
}
/**
*//**
* 在线程处理图片模糊
*/
*//*
@SuppressWarnings("deprecation")
private void _handleBlurInThread() {
new Thread(new Runnable() {
Expand All @@ -1073,7 +1060,7 @@ public void run() {
}
}).start();
}

*/
/** ================================ 监听器 ================================ */

// 监听器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_drag_blur);
ButterKnife.bind(this);
initToolBar(mToolBar, true, "");
mDragLayout.setEnableBlur(true);
// mDragLayout.setEnableBlur(true);
}

@Override
Expand All @@ -60,10 +60,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
item.setChecked(true);
switch (item.getItemId()) {
case R.id.blur_local:
mDragLayout.setBlurFull(false);
// mDragLayout.setBlurFull(false);
return true;
case R.id.blur_full:
mDragLayout.setBlurFull(true);
// mDragLayout.setBlurFull(true);
return true;
}
return super.onOptionsItemSelected(item);
Expand All @@ -77,7 +77,7 @@ public void onClick(View view) {
break;
case R.id.ll_next:
mIvPhoto.setImageResource(mImgRes[mIndex++ % mImgRes.length]);
mDragLayout.updateBlurView();
// mDragLayout.updateBlurView();
break;
case R.id.ll_download:
Toast.makeText(this, "下载", Toast.LENGTH_SHORT).show();
Expand Down

0 comments on commit 8725f17

Please sign in to comment.