@Test public void shouldSetGivenImageAsBackgroundOnSettingImageInvoking() { Bitmap imageBitmap = mock(Bitmap.class); ImageView imageView = mock(ImageView.class); drawerBackgroundView.blurBackground = imageView; drawerBackgroundView.orginalBackground = new ImageView(RuntimeEnvironment.application); drawerBackgroundView.setImageBitmap(imageBitmap); verify(imageView).setImageBitmap(imageBitmap); }
public synchronized void setImageBitmap(Bitmap blurredImage) { Log.d(TAG, "Set blurred background"); initBackground(blurredImage); enableBlurredLayers(); if (isDrawerAlreadyOrAlmostOpen()) { isReadyToImmidiatelySetAlpha = true; showBlurWithAnimation(); Log.i(TAG, "[blur time] Set blurred bitmap when drawer is already open, last offset: " + lastAlphaLevel); } else if (isDrawerLittleOpen()) { AnimationWorker animationWorker = new AnimationWorker(blockingQueue.poll()); blurBackground.postDelayed(animationWorker, DELAY_MILLIS_BETWEEN_NEXT_FADE_IN_STEP); } else { isReadyToImmidiatelySetAlpha = true; Log.i(TAG, "[blur time] Set blurred bitmap when drawer is not open yet, last offset: " + lastAlphaLevel); setAlpha(lastAlphaLevel); } }
DrawerBackgroundView { public synchronized void setImageBitmap(Bitmap blurredImage) { Log.d(TAG, "Set blurred background"); initBackground(blurredImage); enableBlurredLayers(); if (isDrawerAlreadyOrAlmostOpen()) { isReadyToImmidiatelySetAlpha = true; showBlurWithAnimation(); Log.i(TAG, "[blur time] Set blurred bitmap when drawer is already open, last offset: " + lastAlphaLevel); } else if (isDrawerLittleOpen()) { AnimationWorker animationWorker = new AnimationWorker(blockingQueue.poll()); blurBackground.postDelayed(animationWorker, DELAY_MILLIS_BETWEEN_NEXT_FADE_IN_STEP); } else { isReadyToImmidiatelySetAlpha = true; Log.i(TAG, "[blur time] Set blurred bitmap when drawer is not open yet, last offset: " + lastAlphaLevel); setAlpha(lastAlphaLevel); } } }
DrawerBackgroundView { public synchronized void setImageBitmap(Bitmap blurredImage) { Log.d(TAG, "Set blurred background"); initBackground(blurredImage); enableBlurredLayers(); if (isDrawerAlreadyOrAlmostOpen()) { isReadyToImmidiatelySetAlpha = true; showBlurWithAnimation(); Log.i(TAG, "[blur time] Set blurred bitmap when drawer is already open, last offset: " + lastAlphaLevel); } else if (isDrawerLittleOpen()) { AnimationWorker animationWorker = new AnimationWorker(blockingQueue.poll()); blurBackground.postDelayed(animationWorker, DELAY_MILLIS_BETWEEN_NEXT_FADE_IN_STEP); } else { isReadyToImmidiatelySetAlpha = true; Log.i(TAG, "[blur time] Set blurred bitmap when drawer is not open yet, last offset: " + lastAlphaLevel); setAlpha(lastAlphaLevel); } } DrawerBackgroundView(DrawerLayoutWithBlurredBackground drawerLayoutWithBlurredBackground); }
DrawerBackgroundView { public synchronized void setImageBitmap(Bitmap blurredImage) { Log.d(TAG, "Set blurred background"); initBackground(blurredImage); enableBlurredLayers(); if (isDrawerAlreadyOrAlmostOpen()) { isReadyToImmidiatelySetAlpha = true; showBlurWithAnimation(); Log.i(TAG, "[blur time] Set blurred bitmap when drawer is already open, last offset: " + lastAlphaLevel); } else if (isDrawerLittleOpen()) { AnimationWorker animationWorker = new AnimationWorker(blockingQueue.poll()); blurBackground.postDelayed(animationWorker, DELAY_MILLIS_BETWEEN_NEXT_FADE_IN_STEP); } else { isReadyToImmidiatelySetAlpha = true; Log.i(TAG, "[blur time] Set blurred bitmap when drawer is not open yet, last offset: " + lastAlphaLevel); setAlpha(lastAlphaLevel); } } DrawerBackgroundView(DrawerLayoutWithBlurredBackground drawerLayoutWithBlurredBackground); synchronized void addBlurredLayer(); synchronized void setImageBitmap(Bitmap blurredImage); synchronized void reset(); synchronized void setAlpha(float alphaLevel); void disableBlurredLayers(); void enableBlurredLayers(); }
DrawerBackgroundView { public synchronized void setImageBitmap(Bitmap blurredImage) { Log.d(TAG, "Set blurred background"); initBackground(blurredImage); enableBlurredLayers(); if (isDrawerAlreadyOrAlmostOpen()) { isReadyToImmidiatelySetAlpha = true; showBlurWithAnimation(); Log.i(TAG, "[blur time] Set blurred bitmap when drawer is already open, last offset: " + lastAlphaLevel); } else if (isDrawerLittleOpen()) { AnimationWorker animationWorker = new AnimationWorker(blockingQueue.poll()); blurBackground.postDelayed(animationWorker, DELAY_MILLIS_BETWEEN_NEXT_FADE_IN_STEP); } else { isReadyToImmidiatelySetAlpha = true; Log.i(TAG, "[blur time] Set blurred bitmap when drawer is not open yet, last offset: " + lastAlphaLevel); setAlpha(lastAlphaLevel); } } DrawerBackgroundView(DrawerLayoutWithBlurredBackground drawerLayoutWithBlurredBackground); synchronized void addBlurredLayer(); synchronized void setImageBitmap(Bitmap blurredImage); synchronized void reset(); synchronized void setAlpha(float alphaLevel); void disableBlurredLayers(); void enableBlurredLayers(); static final float NOT_TRANSPARENT_ALPHA_LEVEL; }