MCPcopy Create free account
hub / github.com/M66B/FairEmail / run

Method run

app/src/main/java/eu/faircode/email/ImageHelper.java:505–540  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 14

getCachedImageMethod · 0.95
fitDrawableMethod · 0.95
postMethod · 0.95
downloadImageMethod · 0.95
iMethod · 0.95
animateMethod · 0.95
widthMethod · 0.80
heightMethod · 0.80
getDrawableMethod · 0.65
setTextMethod · 0.65
acquireMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected