code cleanup
[fanfix.git] / src / be / nikiroo / fanfix / reader / ui / GuiReaderBookInfo.java
index 23d4c3160169e0244a1070720d376fc0aba06ab6..a5743c7b10f8ab80b21ff50a4aae5cf2273fbac4 100644 (file)
@@ -5,6 +5,7 @@ import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.fanfix.data.Story;
 import be.nikiroo.fanfix.library.BasicLibrary;
 import be.nikiroo.utils.Image;
+import be.nikiroo.utils.StringUtils;
 
 /**
  * Some meta information related to a "book" (which can either be a
@@ -154,7 +155,7 @@ public class GuiReaderBookInfo {
                                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
@@ -179,7 +180,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);
@@ -203,7 +205,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);
@@ -211,26 +214,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
-        */
-       static private String formatNumber(long number) {
-               String displayNumber;
-               if (number >= 4000) {
-                       displayNumber = "" + (number / 1000) + "k";
-               } else if (number > 0) {
-                       displayNumber = "" + number;
-               } else {
-                       displayNumber = "";
-               }
-
-               return displayNumber;
-       }
 }