@@ -221,11 +221,11 @@ static void calculateInSampleSize(int reqWidth, int reqHeight, BitmapFactory.Opt
221
221
222
222
static Bitmap applyCustomTransformations (List <Transformation > transformations , Bitmap result ) {
223
223
for (int i = 0 , count = transformations .size (); i < count ; i ++) {
224
- Transformation transformation = transformations .get (i );
224
+ final Transformation transformation = transformations .get (i );
225
225
Bitmap newResult = transformation .transform (result );
226
226
227
227
if (newResult == null ) {
228
- StringBuilder builder = new StringBuilder () //
228
+ final StringBuilder builder = new StringBuilder () //
229
229
.append ("Transformation " )
230
230
.append (transformation .key ())
231
231
.append (" returned null after " )
@@ -234,20 +234,36 @@ static Bitmap applyCustomTransformations(List<Transformation> transformations, B
234
234
for (Transformation t : transformations ) {
235
235
builder .append (t .key ()).append ('\n' );
236
236
}
237
- throw new NullPointerException (builder .toString ());
237
+ Picasso .HANDLER .post (new Runnable () {
238
+ @ Override public void run () {
239
+ throw new NullPointerException (builder .toString ());
240
+ }
241
+ });
242
+ return null ;
238
243
}
239
244
240
245
if (newResult == result && result .isRecycled ()) {
241
- throw new IllegalStateException (
242
- "Transformation " + transformation .key () + " returned input Bitmap but recycled it." );
246
+ Picasso .HANDLER .post (new Runnable () {
247
+ @ Override public void run () {
248
+ throw new IllegalStateException (
249
+ "Transformation " + transformation .key () + " returned input Bitmap but recycled it." );
250
+ }
251
+ });
252
+ return null ;
243
253
}
244
254
245
255
// If the transformation returned a new bitmap ensure they recycled the original.
246
256
if (newResult != result && !result .isRecycled ()) {
247
- throw new IllegalStateException ("Transformation "
248
- + transformation .key ()
249
- + " mutated input Bitmap but failed to recycle the original." );
257
+ Picasso .HANDLER .post (new Runnable () {
258
+ @ Override public void run () {
259
+ throw new IllegalStateException ("Transformation "
260
+ + transformation .key ()
261
+ + " mutated input Bitmap but failed to recycle the original." );
262
+ }
263
+ });
264
+ return null ;
250
265
}
266
+
251
267
result = newResult ;
252
268
}
253
269
return result ;
0 commit comments