Remember hash, size and number of entries in dictionaries
app/src/main/java/eu/lepiller/nani/dictionary/Dictionary.java
| 12 | 12 | abstract public class Dictionary { | |
| 13 | 13 | private String name; | |
| 14 | 14 | private String description, fullDescription; | |
| 15 | + | private int expectedFileSize; | |
| 16 | + | private int expectedEntries; | |
| 17 | + | private String sha256; | |
| 15 | 18 | File file; | |
| 16 | 19 | ||
| 17 | - | Dictionary(String n, String descr, String fullDescr, File cacheDir) { | |
| 20 | + | Dictionary(String n, String descr, String fullDescr, File cacheDir, int fileSize, int entries, String hash) { | |
| 18 | 21 | name = n; | |
| 19 | 22 | description = descr; | |
| 20 | 23 | fullDescription = fullDescr; | |
| 24 | + | expectedEntries = entries; | |
| 25 | + | expectedFileSize = fileSize; | |
| 26 | + | sha256 = hash; | |
| 21 | 27 | this.file = new File(cacheDir, "/dico/" + name); | |
| 22 | 28 | } | |
| 23 | 29 | ||
| 24 | 30 | public String getName() { | |
| 25 | 31 | return name; | |
| 26 | 32 | } | |
| 27 | - | ||
| 28 | 33 | public String getDescription() { | |
| 29 | 34 | return description; | |
| 30 | 35 | } | |
| 31 | 36 | public String getFullDescription() { | |
| 32 | 37 | return fullDescription; | |
| 33 | 38 | } | |
| 39 | + | public int getExpectedFileSize() { | |
| 40 | + | return expectedFileSize; | |
| 41 | + | } | |
| 42 | + | public int getExpectedEntries() { | |
| 43 | + | return expectedEntries; | |
| 44 | + | } | |
| 45 | + | public String getSha256() { | |
| 46 | + | return sha256; | |
| 47 | + | } | |
| 34 | 48 | ||
| 35 | 49 | protected File getFile() { | |
| 36 | 50 | return file; |
app/src/main/java/eu/lepiller/nani/dictionary/DictionaryFactory.java
| 92 | 92 | chooseLanguage(synopsis), | |
| 93 | 93 | chooseLanguage(description), | |
| 94 | 94 | cacheDir, | |
| 95 | - | url)); | |
| 95 | + | url, | |
| 96 | + | size, | |
| 97 | + | entries, | |
| 98 | + | sha256)); | |
| 96 | 99 | } else if (type.compareTo("jmdict") == 0) { | |
| 97 | 100 | dictionaries.add(new JMDict(name, | |
| 98 | 101 | chooseLanguage(synopsis), | |
| 99 | 102 | chooseLanguage(description), | |
| 100 | 103 | cacheDir, | |
| 101 | - | url)); | |
| 104 | + | url, | |
| 105 | + | size, | |
| 106 | + | entries, | |
| 107 | + | sha256)); | |
| 102 | 108 | } | |
| 103 | 109 | } | |
| 104 | 110 |
app/src/main/java/eu/lepiller/nani/dictionary/FileDictionary.java
| 39 | 39 | private String mUrl; | |
| 40 | 40 | private static String TAG = "FILEDIC"; | |
| 41 | 41 | ||
| 42 | - | FileDictionary(String name, String description, String fullDescription, File cacheDir, String url) { | |
| 43 | - | super(name, description, fullDescription, cacheDir); | |
| 42 | + | FileDictionary(String name, String description, String fullDescription, File cacheDir, String url, | |
| 43 | + | int fileSize, int entries, String hash) { | |
| 44 | + | super(name, description, fullDescription, cacheDir, fileSize, entries, hash); | |
| 44 | 45 | mUrl = url; | |
| 45 | 46 | } | |
| 46 | 47 |
app/src/main/java/eu/lepiller/nani/dictionary/JMDict.java
| 20 | 20 | final private static String TAG = "JMDICT"; | |
| 21 | 21 | private Huffman kanjiHuffman, readingHuffman, meaningHuffman; | |
| 22 | 22 | ||
| 23 | - | JMDict(String name, String description, String fullDescription, File cacheDir, String url) { | |
| 24 | - | super(name, description, fullDescription, cacheDir, url); | |
| 23 | + | JMDict(String name, String description, String fullDescription, File cacheDir, String url, | |
| 24 | + | int fileSize, int entries, String hash) { | |
| 25 | + | super(name, description, fullDescription, cacheDir, url, fileSize, entries, hash); | |
| 25 | 26 | } | |
| 26 | 27 | ||
| 27 | 28 | @Override |
app/src/main/java/eu/lepiller/nani/dictionary/RadicalDict.java
| 94 | 94 | } | |
| 95 | 95 | } | |
| 96 | 96 | ||
| 97 | - | RadicalDict(String name, String description, String fullDescription, File cacheDir, String url) { | |
| 98 | - | super(name, description, fullDescription, cacheDir, url); | |
| 97 | + | RadicalDict(String name, String description, String fullDescription, File cacheDir, String url, | |
| 98 | + | int fileSize, int entries, String hash) { | |
| 99 | + | super(name, description, fullDescription, cacheDir, url, fileSize, entries, hash); | |
| 99 | 100 | } | |
| 100 | 101 | ||
| 101 | 102 | private boolean contains(List<String> lst, String s) { |