862 | | String prefix = isDisabled ? "dis:" : ""; |
863 | | if (name.startsWith("data:")) { |
864 | | String url = name; |
865 | | ImageResource ir = cache.get(prefix+url); |
866 | | if (ir != null) return ir; |
867 | | ir = getIfAvailableDataUrl(url); |
868 | | if (ir != null) { |
869 | | cache.put(prefix+url, ir); |
870 | | } |
| 861 | String prefix = isDisabled ? "dis:" : ""; |
| 862 | if (name.startsWith("data:")) { |
| 863 | String url = name; |
| 864 | ImageResource ir = cache.get(prefix + url); |
| 865 | if (ir != null) |
885 | | } else if (name.startsWith(WIKI_PROTOCOL)) { |
886 | | ImageResource ir = cache.get(prefix+name); |
887 | | if (ir != null) return ir; |
888 | | ir = getIfAvailableWiki(name, type); |
889 | | if (ir != null) { |
890 | | cache.put(prefix+name, ir); |
891 | | } |
| 881 | ir = getIfAvailableHttp(url, type); |
| 882 | if (ir != null) { |
| 883 | cache.put(prefix + url, ir); |
| 884 | } |
| 885 | return ir; |
| 886 | } else if (name.startsWith(WIKI_PROTOCOL)) { |
| 887 | ImageResource ir = cache.get(prefix + name); |
| 888 | if (ir != null) |
895 | | if (subdir == null) { |
896 | | subdir = ""; |
897 | | } else if (!subdir.isEmpty() && !subdir.endsWith("/")) { |
898 | | subdir += '/'; |
899 | | } |
900 | | String[] extensions; |
901 | | if (name.indexOf('.') != -1) { |
902 | | extensions = new String[] {""}; |
903 | | } else { |
904 | | extensions = new String[] {".png", ".svg"}; |
905 | | } |
906 | | final int typeArchive = 0; |
907 | | final int typeLocal = 1; |
908 | | for (int place : new Integer[] {typeArchive, typeLocal}) { |
909 | | for (String ext : extensions) { |
| 897 | if (subdir == null) { |
| 898 | subdir = ""; |
| 899 | } else if (!subdir.isEmpty() && !subdir.endsWith("/")) { |
| 900 | subdir += '/'; |
| 901 | } |
| 902 | String[] extensions; |
| 903 | if (name.indexOf('.') != -1) { |
| 904 | extensions = new String[] { "" }; |
| 905 | } else { |
| 906 | extensions = new String[] { ".png", ".svg" }; |
| 907 | } |
| 908 | final int typeArchive = 0; |
| 909 | final int typeLocal = 1; |
| 910 | for (int place : new Integer[] { typeArchive, typeLocal }) { |
| 911 | for (String ext : extensions) { |
917 | | String fullName = subdir + name + ext; |
918 | | String cacheName = prefix + fullName; |
919 | | /* cache separately */ |
920 | | if (dirs != null && !dirs.isEmpty()) { |
921 | | cacheName = "id:" + id + ':' + fullName; |
922 | | if (archive != null) { |
923 | | cacheName += ':' + archive.getName(); |
924 | | } |
| 919 | String fullName = subdir + name + ext; |
| 920 | String cacheName = prefix + fullName; |
| 921 | /* cache separately */ |
| 922 | if (dirs != null && !dirs.isEmpty()) { |
| 923 | cacheName = "id:" + id + ':' + fullName; |
| 924 | if (archive != null) { |
| 925 | cacheName += ':' + archive.getName(); |
945 | | // getImageUrl() does a ton of "stat()" calls and gets expensive |
946 | | // and redundant when you have a whole ton of objects. So, |
947 | | // index the cache by the name of the icon we're looking for |
948 | | // and don't bother to create a URL unless we're actually creating the image. |
949 | | URL path = getImageUrl(fullName); |
950 | | if (path == null) { |
951 | | continue; |
952 | | } |
953 | | ir = getIfAvailableLocalURL(path, type); |
| 936 | ir = getIfAvailableZip(fullName, archive, inArchiveDir, type); |
| 942 | break; |
| 943 | case typeLocal: |
| 944 | ImageResource ir = cache.get(cacheName); |
| 945 | if (ir != null) |
| 946 | return ir; |
| 947 | |
| 948 | // getImageUrl() does a ton of "stat()" calls and gets expensive |
| 949 | // and redundant when you have a whole ton of objects. So, |
| 950 | // index the cache by the name of the icon we're looking for |
| 951 | // and don't bother to create a URL unless we're actually creating the image. |
| 952 | URL path = getImageUrl(fullName); |
| 953 | if (path == null) { |
| 954 | continue; |
| 955 | } |
| 956 | ir = getIfAvailableLocalURL(path, type); |
| 957 | if (ir != null) { |
| 958 | cache.put(cacheName, ir); |
| 959 | return ir; |
| 960 | } |
| 961 | break; |