()
| 501 | private void loadImageFromLocalUrl(final String targetKey, final boolean useFileSystemStorage) { |
| 502 | imageLoader.run(new Runnable() { |
| 503 | @Override |
| 504 | public void run() { |
| 505 | try { |
| 506 | InputStream input = null; //NOPMD CloseResource |
| 507 | OutputStream output = null; //NOPMD CloseResource |
| 508 | try { |
| 509 | if (url.startsWith("file:/")) { |
| 510 | input = FileSystemStorage.getInstance().openInputStream(url); |
| 511 | } else if (url.startsWith("jar:/")) { |
| 512 | input = CN.getResourceAsStream(url.substring(url.lastIndexOf("/"))); |
| 513 | } else if (url.startsWith("image:")) { |
| 514 | input = null; |
| 515 | } else { |
| 516 | input = Storage.getInstance().createInputStream(url); |
| 517 | } |
| 518 | if (input != null) { |
| 519 | output = useFileSystemStorage ? FileSystemStorage.getInstance().openOutputStream(targetKey) : Storage.getInstance().createOutputStream(targetKey); |
| 520 | Util.copy(input, output); |
| 521 | } |
| 522 | } finally { |
| 523 | Util.cleanup(output); |
| 524 | Util.cleanup(input); |
| 525 | } |
| 526 | runAndWait(new Runnable() { |
| 527 | @Override |
| 528 | public void run() { |
| 529 | InputStream imageInput = null; //NOPMD CloseResource |
| 530 | try { |
| 531 | Image value = url.startsWith("image:") ? Resources.getGlobalResources().getImage(url) : |
| 532 | Image.createImage(imageInput = useFileSystemStorage ? FileSystemStorage.getInstance().openInputStream(targetKey) : Storage.getInstance().createInputStream(targetKey)); |
| 533 | DownloadCompleted onComplete = new DownloadCompleted(); |
| 534 | onComplete.setSourceImage(value); |
| 535 | onComplete.actionPerformed(new ActionEvent(value)); |
| 536 | } catch (IOException ex) { |
| 537 | if (exceptionHandler != null) { |
| 538 | exceptionHandler.onError(URLImage.this, ex); |
| 539 | } else { |
| 540 | Log.e(new RuntimeException(ex.toString())); |
| 541 | } |
| 542 | } finally { |
| 543 | Util.cleanup(imageInput); |
| 544 | } |
| 545 | } |
| 546 | }); |
| 547 | } catch (IOException t) { |
| 548 | if (exceptionHandler != null) { |
| 549 | exceptionHandler.onError(URLImage.this, t); |
| 550 | } else { |
| 551 | Log.e(new RuntimeException(t.toString())); |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | }); |
| 556 | } |
| 557 |
nothing calls this directly
no test coverage detected