()
| 503 | |
| 504 | Helper.getDownloadTaskExecutor().submit(new Runnable() { |
| 505 | @Override |
| 506 | public void run() { |
| 507 | try { |
| 508 | // Check cache again |
| 509 | Drawable cached = getCachedImage(context, id, source); |
| 510 | if (cached != null) { |
| 511 | fitDrawable(cached, aw, ah, scale, view); |
| 512 | post(cached, source); |
| 513 | return; |
| 514 | } |
| 515 | |
| 516 | // Download image |
| 517 | Drawable d; |
| 518 | try { |
| 519 | if (slow) |
| 520 | semaphore.acquire(); |
| 521 | String mimeType = (source.endsWith(".svg") ? "image/svg+xml" : null); |
| 522 | d = downloadImage(context, id, source, mimeType); |
| 523 | } finally { |
| 524 | if (slow) |
| 525 | semaphore.release(); |
| 526 | } |
| 527 | |
| 528 | fitDrawable(d, aw, ah, scale, view); |
| 529 | post(d, source); |
| 530 | } catch (Throwable ex) { |
| 531 | // Show broken icon |
| 532 | Log.i(ex); |
| 533 | int resid = (ex instanceof IOException && !(ex instanceof FileNotFoundException) |
| 534 | ? R.drawable.twotone_cloud_off_24 |
| 535 | : R.drawable.twotone_broken_image_24); |
| 536 | Drawable d = ContextCompat.getDrawable(context, resid); |
| 537 | d.setBounds(0, 0, px, px); |
| 538 | post(d, source); |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | private void post(final Drawable d, String source) { |
| 543 | Log.i("Posting image=" + source); |
nothing calls this directly
no test coverage detected