Skip to content

Commit

Permalink
Update 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
GIGAMOLE committed May 14, 2016
1 parent 52fab69 commit b0bf2b5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
Or Gradle Maven Central:

```groovy
compile 'com.github.devlight.shadowlayout:library:1.0.0'
compile 'com.github.devlight.shadowlayout:library:1.0.1'
```

Or Maven:
Expand All @@ -41,15 +41,15 @@ Or Maven:
<dependency>
<groupId>com.github.devlight.shadowlayout</groupId>
<artifactId>library</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<type>aar</type>
</dependency>
```

Android SDK Version
=========

ShadowLayout requires a minimum sdk version of 11.
ShadowLayout requires a minimum SDK version of 11.

Sample
========
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'

version = "1.0.0"
version = "1.0.1"

android {
compileSdkVersion 23
Expand All @@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
versionName "1.0.1"
}
buildTypes {
release {
Expand Down
33 changes: 27 additions & 6 deletions library/src/main/java/com/gigamole/library/ShadowLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.support.annotation.FloatRange;
import android.util.AttributeSet;
Expand Down Expand Up @@ -112,6 +113,16 @@ public ShadowLayout(final Context context, final AttributeSet attrs, final int d
}
}

@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// Clear shadow bitmap
if (mBitmap != null) {
mBitmap.recycle();
mBitmap = null;
}
}

public boolean isShadowed() {
return mIsShadowed;
}
Expand Down Expand Up @@ -224,17 +235,27 @@ protected void dispatchDraw(final Canvas canvas) {
// paint does`t draw shadow, it draw another copy of bitmap
super.dispatchDraw(mCanvas);

// Draw alpha chanel bitmap of our local canvas
mCanvas.drawBitmap(mBitmap.extractAlpha(), mShadowDx, mShadowDy, mPaint);
// Get the alpha bounds of bitmap
final Bitmap extractedAlpha = mBitmap.extractAlpha();
// Clear past content content to draw shadow
mCanvas.drawColor(0, PorterDuff.Mode.CLEAR);

// Draw extracted alpha bounds of our local canvas
mCanvas.drawBitmap(extractedAlpha, mShadowDx, mShadowDy, mPaint);

// Recycle and clear extracted alpha
extractedAlpha.recycle();
} else {
// Clear shadow bitmap
mBitmap.recycle();
mBitmap = null;
// Create placeholder bitmap when size is zero and wait until new size coming up
mBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
}
}

// Draw shadow bitmap
if (mCanvas != null && mBitmap != null) canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
if (mCanvas != null) {
if (mBitmap != null && !mBitmap.isRecycled())
canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
}
}

// Draw child`s
Expand Down

0 comments on commit b0bf2b5

Please sign in to comment.