X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReaderBookInfo.java;h=3c5cc8a22ea20daec39f79452a357702c8c9057b;hb=fb4753428d43f0f4ca06523efbeab887164b5c91;hp=eb6dfbf36294a1f8711b173b394d25187222ba8a;hpb=596ed3d65b2585c4358935d6fbb130f50e237787;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBookInfo.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBookInfo.java index eb6dfbf..3c5cc8a 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBookInfo.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBookInfo.java @@ -127,7 +127,15 @@ public class GuiReaderBookInfo { public Image getBaseImage(BasicLibrary lib) { switch (type) { case STORY: - return lib.getCover(meta.getLuid()); + if (meta.getCover() != null) { + return meta.getCover(); + } + + if (meta.getLuid() != null) { + return lib.getCover(meta.getLuid()); + } + + return null; case SOURCE: return lib.getSourceCover(value); case AUTHOR: @@ -150,12 +158,15 @@ public class GuiReaderBookInfo { if (uid == null || uid.trim().isEmpty()) { uid = meta.getLuid(); } + if (uid == null || uid.trim().isEmpty()) { + uid = meta.getUrl(); + } GuiReaderBookInfo info = new GuiReaderBookInfo(Type.STORY, uid, meta.getTitle()); info.meta = meta; - info.count = formatNumber(meta.getWords()); + info.count = StringUtils.formatNumber(meta.getWords()); if (!info.count.isEmpty()) { info.count = GuiReader.trans( meta.isImageDocument() ? StringIdGui.BOOK_COUNT_IMAGES @@ -180,7 +191,8 @@ public class GuiReaderBookInfo { GuiReaderBookInfo info = new GuiReaderBookInfo(Type.SOURCE, "source_" + source, source); - info.count = formatNumber(lib.getListBySource(source).size()); + info.count = StringUtils.formatNumber(lib.getListBySource(source) + .size()); if (!info.count.isEmpty()) { info.count = GuiReader.trans(StringIdGui.BOOK_COUNT_STORIES, info.count); @@ -204,7 +216,8 @@ public class GuiReaderBookInfo { GuiReaderBookInfo info = new GuiReaderBookInfo(Type.AUTHOR, "author_" + author, author); - info.count = formatNumber(lib.getListByAuthor(author).size()); + info.count = StringUtils.formatNumber(lib.getListByAuthor(author) + .size()); if (!info.count.isEmpty()) { info.count = GuiReader.trans(StringIdGui.BOOK_COUNT_STORIES, info.count); @@ -212,30 +225,4 @@ public class GuiReaderBookInfo { return info; } - - /** - * Format a number for display (use the "k" notation if higher or equal to - * 4000). - * - * @param number - * the number to parse - * - * @return the displayable version of the number - * - * @deprecated use {@link StringUtils} after update instead - */ - @Deprecated - static private String formatNumber(long number) { - // TODO: replace with StringUtils after update - String displayNumber; - if (number >= 4000) { - displayNumber = "" + (number / 1000) + "k"; - } else if (number > 0) { - displayNumber = "" + number; - } else { - displayNumber = ""; - } - - return displayNumber; - } }