From 630bdacd6ce180eb4b59201dadf0bcb297f84e09 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Wed, 13 Jan 2016 19:14:11 +0100 Subject: [PATCH] DroidFish: Handle screen resize (for example show/hide navigation bar) when drawing the tour guide overlay. --- .../tourguide/FrameLayoutWithHole.java | 59 ++++++------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/DroidFish/src/tourguide/tourguide/FrameLayoutWithHole.java b/DroidFish/src/tourguide/tourguide/FrameLayoutWithHole.java index 69eaf48..352fa23 100644 --- a/DroidFish/src/tourguide/tourguide/FrameLayoutWithHole.java +++ b/DroidFish/src/tourguide/tourguide/FrameLayoutWithHole.java @@ -2,18 +2,15 @@ package tourguide.tourguide; import android.animation.AnimatorSet; import android.app.Activity; -import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.Path.FillType; import android.graphics.Point; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; import android.support.v4.view.MotionEventCompat; import android.text.TextPaint; import android.util.AttributeSet; import android.util.Log; -import android.view.Display; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -28,12 +25,9 @@ public class FrameLayoutWithHole extends FrameLayout { private TextPaint mTextPaint; private Activity mActivity; private TourGuide.MotionType mMotionType; - private Paint mEraser; - Bitmap mEraserBitmap; - private Canvas mEraserCanvas; + private Path mPath; private Paint mPaint; - private Paint transparentPaint; private View mViewHole; // This is the targeted view to be highlighted, where the hole should be placed private int mRadius; private int [] mPos; @@ -115,27 +109,10 @@ public class FrameLayoutWithHole extends FrameLayout { mTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG); mTextPaint.setTextAlign(Paint.Align.LEFT); - Point size = new Point(); - size.x = mActivity.getResources().getDisplayMetrics().widthPixels; - size.y = mActivity.getResources().getDisplayMetrics().heightPixels; - - mEraserBitmap = Bitmap.createBitmap(size.x, size.y, Bitmap.Config.ARGB_8888); - mEraserCanvas = new Canvas(mEraserBitmap); + mPath = new Path(); mPaint = new Paint(); - mPaint.setColor(0xcc000000); - transparentPaint = new Paint(); - transparentPaint.setColor(getResources().getColor(android.R.color.transparent)); - transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); - - mEraser = new Paint(); - mEraser.setColor(0xFFFFFFFF); - mEraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); - mEraser.setFlags(Paint.ANTI_ALIAS_FLAG); - - Log.d("tourguide","getHeight: "+ size.y); - Log.d("tourguide","getWidth: " + size.x); - + mPaint.setAntiAlias(true); } private boolean mCleanUpLock = false; @@ -168,9 +145,6 @@ public class FrameLayoutWithHole extends FrameLayout { @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - /* cleanup reference to prevent memory leak */ - mEraserCanvas.setBitmap(null); - mEraserBitmap = null; if (mAnimatorSetArrayList != null && mAnimatorSetArrayList.size() > 0){ for(int i=0;i