Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,13 @@ public void setSignatureBitmap(final Bitmap signature) {

Canvas canvas = new Canvas(mSignatureBitmap);
canvas.drawBitmap(signature, drawMatrix, null);
setIsEmpty(false);

//determine whether the passing bitmap is an empty bitmap
//if it is an empty bitmap, do not set mIsEmpty as false.
//fix the bug of nothing drew on signature pad
//and onRestoreInstanceState is called (for example rotate the screen to landscape)
//mIsEmpty set to false.
setIsEmpty(isBitmapEmpty(signature));
invalidate();
}
// View not laid out yet e.g. called from onCreate(), onRestoreInstanceState()...
Expand All @@ -320,6 +326,12 @@ public Bitmap getTransparentSignatureBitmap() {
return mSignatureBitmap;
}

//determine whether bitmap is empty
private boolean isBitmapEmpty(Bitmap bitmap) {
Bitmap emptyBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
return bitmap.sameAs(emptyBitmap);
}

public Bitmap getTransparentSignatureBitmap(boolean trimBlankSpace) {

if (!trimBlankSpace) {
Expand Down