Skip to content

Commit

Permalink
fix: onCancelled seems to be called while doInBackground is running. …
Browse files Browse the repository at this point in the history
…Adding stupid guards against that.
  • Loading branch information
renard314 committed Jul 10, 2015
1 parent c192df9 commit e5e8997
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class PreparePixForCropTask extends AsyncTask<Void, Void, CropData> {
private final int mHeight;

public PreparePixForCropTask(Pix pix, int width, int height) {
if(width==0 || height==0) {
if (width == 0 || height == 0) {
Log.e(TAG, "scaling to 0 value: (" + width + "," + height + ")");
}
mPix = pix;
Expand Down Expand Up @@ -81,8 +81,16 @@ protected CropData doInBackground(Void... params) {
return null;
}
scaleResult = scaler.scale(mPix, mWidth, mHeight);
if (isCancelled()) {
return null;
}
Bitmap bitmap = WriteFile.writeBitmap(scaleResult.getPix());
Log.d(TAG, "scaling result (" + bitmap.getWidth() + "," + bitmap.getHeight() + ")");
if (isCancelled()) {
return null;
}
if (bitmap != null) {
Log.d(TAG, "scaling result (" + bitmap.getWidth() + "," + bitmap.getHeight() + ")");
}
return new CropData(bitmap, scaleResult, blurDetectionResult);

}
Expand Down

0 comments on commit e5e8997

Please sign in to comment.