Skip to content

Commit

Permalink
开启模糊
Browse files Browse the repository at this point in the history
  • Loading branch information
Rukey7 committed Jan 4, 2017
1 parent 22fd3f3 commit 7832318
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 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 2
versionName "1.0.2"
// renderscriptTargetApi 23
// renderscriptSupportModeEnabled true
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
}
buildTypes {
release {
Expand Down
37 changes: 21 additions & 16 deletions dragsloplayout/src/main/java/com/dl7/drag/DragSlopLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@

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.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.ViewGroup;
Expand Down Expand Up @@ -231,12 +244,10 @@ protected void onDetachedFromWindow() {
if (mAnimPresenter != null) {
mAnimPresenter.stopAllAnimator();
}
/*
if (mBitmapToBlur != null) {
mBitmapToBlur.recycle();
mBitmapToBlur = null;
}
*/
}

/***********************************
Expand Down Expand Up @@ -545,7 +556,6 @@ public void run() {
* @param percent 百分比
*/
private void _dragPositionChanged(int visibleHeight, float percent) {
/*
if (mEnableBlur && mBlurDrawable != null) {
if (visibleHeight < mFixHeight) {
return;
Expand All @@ -558,7 +568,6 @@ private void _dragPositionChanged(int visibleHeight, float percent) {
}
mBlurDrawable.setAlpha((int) (percent * 255));
}
*/
if (visibleHeight >= 0) {
ViewCompat.setTranslationY(mMainView, -visibleHeight * (1 - mCollapseParallax));
}
Expand Down Expand Up @@ -592,11 +601,9 @@ private boolean _isNeedIntercept(MotionEvent ev) {
if (mDragHelper.isViewUnder(mAttachScrollView, (int) ev.getX(), y) && mMode != MODE_ANIMATE) {
return true;
}
/*
if (mEnableBlur && mDragStatus == STATUS_EXPANDED) {
return true;
}
*/
return false;
}

Expand Down Expand Up @@ -833,7 +840,6 @@ public void setCustomAnimator(CustomViewAnimator inAnimator, CustomViewAnimator
/*************************************
* Blur
********************************************/
/*
private final static int DEFAULT_SAMPLE_FACTOR = 4;
private final static int DEFAULT_BLUR_RADIUS = 5;

Expand Down Expand Up @@ -878,11 +884,11 @@ public void setBlurFull(boolean blurFull) {
mIsBlurFull = blurFull;
}

*//**
/**
* 设置使能模糊效果
*
* @param enableBlur
*//*
*/
public void setEnableBlur(boolean enableBlur) {
if (mEnableBlur == enableBlur) {
return;
Expand Down Expand Up @@ -913,21 +919,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 @@ -990,9 +996,9 @@ private void _blurView(View view) {
}
}

*//**
/**
* 在线程处理图片模糊
*//*
*/
@SuppressWarnings("deprecation")
private void _handleBlurInThread() {
new Thread(new Runnable() {
Expand All @@ -1013,5 +1019,4 @@ public void run() {
}
}).start();
}
*/
}
2 changes: 1 addition & 1 deletion simple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(':dragsloplayout')
// compile 'com.github.Rukey7:DragSlopLayout:1.0.2'
// photoview
compile 'com.github.chrisbanes.photoview:library:1.2.4'
// butterknife
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'

compile 'com.eightbitlab:blurview:1.2.0'
}
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 7832318

Please sign in to comment.