X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FBasicLibrary.java;h=d753267ee5bce6082cfb4c0f277a2b0244efe3bb;hb=e1de8087ab1623f7624018af905ea3bb0ef45802;hp=a9b6ef3b1e19e0c259a49d136311605e19c1fa85;hpb=88664350f0b3849538d4f41f7c3d56d81d03e1a4;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index a9b6ef3..d753267 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -94,7 +94,8 @@ abstract public class BasicLibrary { /** * Return the cover image associated to this source. *

- * By default, return the cover of the first story with this source. + * By default, return the custom cover if any, and if not, return the cover + * of the first story with this source. * * @param source * the source @@ -102,6 +103,11 @@ abstract public class BasicLibrary { * @return the cover image or NULL */ public Image getSourceCover(String source) { + Image custom = getCustomSourceCover(source); + if (custom != null) { + return custom; + } + List metas = getListBySource(source); if (metas.size() > 0) { return getCover(metas.get(0).getLuid()); @@ -110,6 +116,20 @@ abstract public class BasicLibrary { return null; } + /** + * Return the custom cover image associated to this source. + *

+ * By default, return NULL. + * + * @param source + * the source to look for + * + * @return the custom cover or NULL if none + */ + public Image getCustomSourceCover(@SuppressWarnings("unused") String source) { + return null; + } + /** * Fix the source cover to the given story cover. * @@ -353,9 +373,9 @@ abstract public class BasicLibrary { .getType()); URL url = file.toURI().toURL(); if (type != null) { -System.out.println("selected support: "+BasicSupport.getSupport(type, url)); story = BasicSupport.getSupport(type, url) // .process(pgProcess); + // Because we do not want to clear the meta cache: meta.setCover(story.getMeta().getCover()); story.setMeta(meta); @@ -398,12 +418,24 @@ System.out.println("selected support: "+BasicSupport.getSupport(type, url)); * in case of I/O error */ public Story imprt(URL url, Progress pg) throws IOException { + if (pg == null) + pg = new Progress(); + + pg.setMinMax(0, 1000); + Progress pgProcess = new Progress(); + Progress pgSave = new Progress(); + pg.addProgress(pgProcess, 800); + pg.addProgress(pgSave, 200); + BasicSupport support = BasicSupport.getSupport(url); if (support == null) { throw new UnknownHostException("" + url); } - return save(support.process(pg), null); + Story story = save(support.process(pgProcess), pgSave); + pg.done(); + + return story; } /** @@ -519,6 +551,9 @@ System.out.println("selected support: "+BasicSupport.getSupport(type, url)); public synchronized Story save(Story story, String luid, Progress pg) throws IOException { + Instance.getTraceHandler().trace( + this.getClass().getSimpleName() + ": saving story " + luid); + // Do not change the original metadata, but change the original story MetaData meta = story.getMeta().clone(); story.setMeta(meta); @@ -537,6 +572,10 @@ System.out.println("selected support: "+BasicSupport.getSupport(type, url)); updateInfo(story.getMeta()); + Instance.getTraceHandler().trace( + this.getClass().getSimpleName() + ": story saved (" + luid + + ")"); + return story; } @@ -550,8 +589,15 @@ System.out.println("selected support: "+BasicSupport.getSupport(type, url)); * in case of I/O error */ public synchronized void delete(String luid) throws IOException { + Instance.getTraceHandler().trace( + this.getClass().getSimpleName() + ": deleting story " + luid); + doDelete(luid); deleteInfo(luid); + + Instance.getTraceHandler().trace( + this.getClass().getSimpleName() + ": story deleted (" + luid + + ")"); } /**