Skip to content

Commit f7fb087

Browse files
Merge pull request #48 from douglasjunior/issue-42
Fixing crash in OverlayView when bitmap has already been recycled. #42
2 parents 225839d + dba4725 commit f7fb087

File tree

1 file changed

+4
-3
lines changed
  • library/src/main/java/io/github/douglasjunior/androidSimpleTooltip

1 file changed

+4
-3
lines changed

library/src/main/java/io/github/douglasjunior/androidSimpleTooltip/OverlayView.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ public class OverlayView extends View {
6464

6565
@Override
6666
protected void dispatchDraw(Canvas canvas) {
67-
if (invalidated)
67+
if (invalidated || bitmap == null || bitmap.isRecycled())
6868
createWindowFrame();
69-
70-
canvas.drawBitmap(bitmap, 0, 0, null);
69+
// The bitmap is checked again because of Android memory cleanup behavior. (See #42)
70+
if (bitmap != null && !bitmap.isRecycled())
71+
canvas.drawBitmap(bitmap, 0, 0, null);
7172
}
7273

7374
private void createWindowFrame() {

0 commit comments

Comments
 (0)