Skip to content

Commit

Permalink
Merge pull request douglasjunior#48 from douglasjunior/issue-42
Browse files Browse the repository at this point in the history
Fixing crash in OverlayView when bitmap has already been recycled. douglasjunior#42
  • Loading branch information
douglasjunior authored Jul 17, 2017
2 parents 225839d + dba4725 commit f7fb087
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ public class OverlayView extends View {

@Override
protected void dispatchDraw(Canvas canvas) {
if (invalidated)
if (invalidated || bitmap == null || bitmap.isRecycled())
createWindowFrame();

canvas.drawBitmap(bitmap, 0, 0, null);
// The bitmap is checked again because of Android memory cleanup behavior. (See #42)
if (bitmap != null && !bitmap.isRecycled())
canvas.drawBitmap(bitmap, 0, 0, null);
}

private void createWindowFrame() {
Expand Down

0 comments on commit f7fb087

Please sign in to comment.