Skip to content

Commit

Permalink
blurLayout do not need setalpha temporary any more
Browse files Browse the repository at this point in the history
  • Loading branch information
medivh397 committed Jun 7, 2021
1 parent 1b0143a commit 3b60f75
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 23 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.medivh.blurview"
minSdkVersion 17
targetSdkVersion 30
targetSdkVersion 29
versionCode 1
versionName "1.0"
renderscriptTargetApi 20
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/medivh/blurview/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected void onCreate(Bundle savedInstanceState) {
blurLayout = findViewById(R.id.blurLayout);

recyclerView = findViewById(R.id.recyclerView);
recyclerView.setAdapter(new RVAdapter(R.layout.list_item));
recyclerView.setAdapter(new SimpleAdapter(R.layout.list_item));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

class RVAdapter extends RecyclerView.Adapter<RVAdapter.Holder> {
class SimpleAdapter extends RecyclerView.Adapter<SimpleAdapter.Holder> {

int itemLayoutId;
public RVAdapter(int itemLayoutId){
public SimpleAdapter(int itemLayoutId){
this.itemLayoutId = itemLayoutId;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/medivh/blurview/TestTabDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void onCreate(Bundle savedInstanceState) {
blurLayout.setCoverColor(Color.parseColor("#ddffffff"));

recyclerView = findViewById(R.id.recyclerView);
recyclerView.setAdapter(new RVAdapter(R.layout.list_item2));
recyclerView.setAdapter(new SimpleAdapter(R.layout.list_item2));
recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayout.VERTICAL));
}

Expand Down
16 changes: 0 additions & 16 deletions app/src/main/java/com/medivh/blurview/core/BlurLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class BlurLayout extends FrameLayout {

private boolean canvasDrawLock;
private boolean preDrawLock;
private boolean isPauseBlurRunnablePost;

public BlurLayout(@NonNull Context context) {
this(context, null);
Expand Down Expand Up @@ -117,16 +116,9 @@ private void prepareBitmapAndPost() {
surfaceViewCanvas.setMatrix(surfaceMatrix);
surfaceViewCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);

setAlpha(0f);
activityView.draw(surfaceViewCanvas);
setAlpha(1);
canvasDrawLock = false;

if (!isPauseBlurRunnablePost) {
isPauseBlurRunnablePost = true;
//暂停surfaceView的更新
getHandler().postDelayed(pauseBlurRunnable, 300);
}

}

Expand All @@ -135,14 +127,6 @@ private void prepareBitmapAndPost() {
surfaceRender.updateBackground(surfaceViewBitmap);
}

private Runnable pauseBlurRunnable = new Runnable() {
@Override
public void run() {
preDrawLock = true;
isPauseBlurRunnablePost = false;
Log.i("BlurLayout", "pauseBlur");
}
};

@Override
protected void onDetachedFromWindow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
Expand Down Expand Up @@ -116,6 +119,7 @@ public void run() {
Canvas canvas = lockCanvas();

if (canvas != null) {
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
canvas.drawBitmap(blurBackground, null, dst, paint);
if(coverColor != 0){
canvas.drawColor(coverColor);
Expand Down

0 comments on commit 3b60f75

Please sign in to comment.