Fix IDE warnings and make some methods static
.idea/dictionaries/tyreunom.xml
| 2 | 2 | <dictionary name="tyreunom"> | |
| 3 | 3 | <words> | |
| 4 | 4 | <w>kanji</w> | |
| 5 | + | <w>kanjis</w> | |
| 6 | + | <w>mozc</w> | |
| 5 | 7 | </words> | |
| 6 | 8 | </dictionary> | |
| 7 | 9 | </component> | |
| 7 | 9 | = | |
| 8 | 10 | = | \ No newline at end of file |
app/src/main/java/eu/lepiller/nani/DictionaryActivity.java
| 1 | 1 | package eu.lepiller.nani; | |
| 2 | 2 | ||
| 3 | 3 | import android.content.Intent; | |
| 4 | - | import android.graphics.drawable.Drawable; | |
| 5 | 4 | import android.os.AsyncTask; | |
| 6 | 5 | import android.os.Bundle; | |
| 7 | 6 | import androidx.appcompat.app.AppCompatActivity; | |
| 8 | - | import androidx.appcompat.widget.Toolbar; | |
| 9 | 7 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; | |
| 10 | 8 | ||
| 11 | 9 | import android.util.Log; | |
… | |||
| 23 | 21 | import java.net.MalformedURLException; | |
| 24 | 22 | import java.net.URL; | |
| 25 | 23 | import java.util.ArrayList; | |
| 26 | - | import java.util.HashMap; | |
| 27 | 24 | ||
| 28 | 25 | import eu.lepiller.nani.dictionary.DictionariesAdapter; | |
| 29 | 26 | import eu.lepiller.nani.dictionary.DictionaryFactory; | |
app/src/main/java/eu/lepiller/nani/RadicalSelectorView.java
| 29 | 29 | ||
| 30 | 30 | public class RadicalSelectorView extends LinearLayout implements OnTaskCompleted<Map<Integer, List<String>>>, | |
| 31 | 31 | OnOtherTaskCompleted<Pair<Map<Integer, List<String>>, Set<String>>> { | |
| 32 | - | static private String TAG = "RSV"; | |
| 32 | + | static private final String TAG = "RSV"; | |
| 33 | 33 | private Button close_button; | |
| 34 | 34 | private LinearLayout kanji_row1, kanji_row2; | |
| 35 | 35 | private LinearLayout radical_table; |
app/src/main/java/eu/lepiller/nani/dictionary/Dictionary.java
| 31 | 31 | private File file, temporaryFile; | |
| 32 | 32 | ||
| 33 | 33 | private static Drawable drawable=null, newDrawable=null; | |
| 34 | - | private static final String TAG = "DICO"; | |
| 35 | 34 | ||
| 36 | 35 | Dictionary(String n, String descr, String fullDescr, File cacheDir, int fileSize, int entries, String hash) { | |
| 37 | 36 | name = n; | |
… | |||
| 92 | 91 | return drawable; | |
| 93 | 92 | } | |
| 94 | 93 | ||
| 95 | - | private Bitmap drawableToBitmap(Drawable drawable) { | |
| 94 | + | private static Bitmap drawableToBitmap(Drawable drawable) { | |
| 96 | 95 | Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), | |
| 97 | 96 | Bitmap.Config.ARGB_8888); | |
| 98 | 97 | Canvas canvas = new Canvas(bitmap); | |
… | |||
| 101 | 100 | return bitmap; | |
| 102 | 101 | } | |
| 103 | 102 | ||
| 104 | - | private Bitmap drawableToBitmap(Drawable drawable, int width, int height) { | |
| 103 | + | private static Bitmap drawableToBitmap(Drawable drawable, int width, int height) { | |
| 105 | 104 | Bitmap background = drawableToBitmap(drawable); | |
| 106 | 105 | return Bitmap.createScaledBitmap(background, width, height, false); | |
| 107 | 106 | } | |
app/src/main/java/eu/lepiller/nani/dictionary/FileDictionary.java
| 12 | 12 | import java.util.Map; | |
| 13 | 13 | ||
| 14 | 14 | public abstract class FileDictionary extends Dictionary { | |
| 15 | - | String encoding = "UTF-8"; | |
| 15 | + | static final String encoding = "UTF-8"; | |
| 16 | 16 | ||
| 17 | 17 | interface Huffman { | |
| 18 | 18 | } | |
… | |||
| 136 | 136 | return 0; | |
| 137 | 137 | } | |
| 138 | 138 | ||
| 139 | - | String getString(RandomAccessFile file) throws IOException { | |
| 139 | + | static String getString(RandomAccessFile file) throws IOException { | |
| 140 | 140 | byte b; | |
| 141 | 141 | ArrayList<Byte> bs = new ArrayList<>(); | |
| 142 | 142 | while((b = file.readByte()) != 0) { | |
… | |||
| 149 | 149 | return new String(str, encoding); | |
| 150 | 150 | } | |
| 151 | 151 | ||
| 152 | - | ArrayList<String> getStringList(RandomAccessFile file) throws IOException { | |
| 152 | + | static ArrayList<String> getStringList(RandomAccessFile file) throws IOException { | |
| 153 | 153 | ArrayList<String> results = new ArrayList<>(); | |
| 154 | 154 | int number = file.readShort(); | |
| 155 | 155 | for(int i=0; i<number; i++) { | |
… | |||
| 158 | 158 | return results; | |
| 159 | 159 | } | |
| 160 | 160 | ||
| 161 | - | ArrayList<Integer> getIntList(RandomAccessFile file) throws IOException { | |
| 161 | + | static ArrayList<Integer> getIntList(RandomAccessFile file) throws IOException { | |
| 162 | 162 | ArrayList<Integer> results = new ArrayList<>(); | |
| 163 | 163 | int number = file.readShort(); | |
| 164 | 164 | for(int i=0; i<number; i++) { | |
… | |||
| 167 | 167 | return results; | |
| 168 | 168 | } | |
| 169 | 169 | ||
| 170 | - | Huffman loadHuffman(RandomAccessFile file) throws IOException { | |
| 170 | + | static Huffman loadHuffman(RandomAccessFile file) throws IOException { | |
| 171 | 171 | byte b = file.readByte(); | |
| 172 | 172 | if(b == 1) { | |
| 173 | 173 | Huffman left = loadHuffman(file); | |
… | |||
| 191 | 191 | } | |
| 192 | 192 | } | |
| 193 | 193 | ||
| 194 | - | private String getHuffmanString(RandomAccessFile file, Huffman huffman) throws IOException { | |
| 194 | + | private static String getHuffmanString(RandomAccessFile file, Huffman huffman) throws IOException { | |
| 195 | 195 | StringBuilder b = new StringBuilder(); | |
| 196 | 196 | ArrayList<Boolean> bits = new ArrayList<>(); | |
| 197 | 197 | String c = null; | |
… | |||
| 221 | 221 | return b.toString(); | |
| 222 | 222 | } | |
| 223 | 223 | ||
| 224 | - | void logHuffman(Huffman h, ArrayList<Boolean> addr) { | |
| 224 | + | static void logHuffman(Huffman h, ArrayList<Boolean> addr) { | |
| 225 | 225 | if (h instanceof JMDict.HuffmanValue) { | |
| 226 | 226 | Log.d(TAG, "HUFF: " + ((JMDict.HuffmanValue) h).character + " -> " + addr.toString()); | |
| 227 | 227 | } else if(h instanceof JMDict.HuffmanTree) { | |
… | |||
| 234 | 234 | } | |
| 235 | 235 | } | |
| 236 | 236 | ||
| 237 | - | ArrayList<String> getHuffmanStringList(RandomAccessFile file, Huffman huffman) throws IOException { | |
| 237 | + | static ArrayList<String> getHuffmanStringList(RandomAccessFile file, Huffman huffman) throws IOException { | |
| 238 | 238 | ArrayList<String> results = new ArrayList<>(); | |
| 239 | 239 | int number = file.readShort(); | |
| 240 | 240 | Log.d(TAG, "huffmanStrings: " + number); | |
app/src/main/java/eu/lepiller/nani/dictionary/RadicalDict.java
| 99 | 99 | super(name, description, fullDescription, cacheDir, url, fileSize, entries, hash); | |
| 100 | 100 | } | |
| 101 | 101 | ||
| 102 | - | private boolean contains(List<String> lst, String s) { | |
| 102 | + | private static boolean contains(List<String> lst, String s) { | |
| 103 | 103 | if(lst==null) | |
| 104 | 104 | return false; | |
| 105 | 105 | for(String p: lst) { |