+ public Image getCustomSourceCover(String source) {
+ synchronized (lock) {
+ if (sourceCovers == null) {
+ sourceCovers = new HashMap<String, Image>();
+ }
+ }
+
+ synchronized (lock) {
+ Image img = sourceCovers.get(source);
+ if (img != null) {
+ return img;
+ }
+ }
+
+ File coverDir = getExpectedDir(source);
+ if (coverDir.isDirectory()) {
+ File cover = new File(coverDir, ".cover.png");
+ if (cover.exists()) {
+ InputStream in;
+ try {
+ in = new FileInputStream(cover);
+ try {
+ synchronized (lock) {
+ sourceCovers.put(source, new Image(in));
+ }
+ } finally {
+ in.close();
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ Instance.getInstance().getTraceHandler()
+ .error(new IOException(
+ "Cannot load the existing custom source cover: "
+ + cover,
+ e));
+ }
+ }
+ }
+
+ synchronized (lock) {
+ return sourceCovers.get(source);
+ }
+ }
+
+ @Override
+ public Image getCustomAuthorCover(String author) {
+ synchronized (lock) {
+ if (authorCovers == null) {
+ authorCovers = new HashMap<String, Image>();
+ }
+ }
+
+ synchronized (lock) {
+ Image img = authorCovers.get(author);
+ if (img != null) {
+ return img;
+ }
+ }
+
+ File cover = getAuthorCoverFile(author);
+ if (cover.exists()) {
+ InputStream in;
+ try {
+ in = new FileInputStream(cover);
+ try {
+ synchronized (lock) {
+ authorCovers.put(author, new Image(in));
+ }
+ } finally {
+ in.close();
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ Instance.getInstance().getTraceHandler()
+ .error(new IOException(
+ "Cannot load the existing custom author cover: "
+ + cover,
+ e));
+ }