/** * Constructor to load dictionary with given path. * * @param url Path of one of stardict file or Path of folder contains stardict files */ public StarDict(String url) { File file = new File(url); if (!file.isDirectory()) { strURL = getFileNameWithoutExtension(url); Log.d(LOG_TAG, "strURL=" + strURL); ifoFile = new IfoFile(strURL + ".ifo"); idxFile = new IdxFile(strURL + ".idx", ifoFile.getLongWordCount(), ifoFile.getLongIdxFileSize()); dictFile = new DictFile(strURL + ".dict"); Log.d(LOG_TAG, "done " + ifoFile.isBoolIsLoaded() + " " + idxFile.isLoaded() + " "); } else { String[] list = file.list(); strURL = url; Log.d(LOG_TAG, "strURL=" + strURL); for (int i = list.length - 1; i >= 0; i--) { String extension = getExtension(list[i]); String path = url + File.separator + list[i]; if (extension.equals("ifo")) { ifoFile = new IfoFile(path); } else if (extension.equals("idx")) { idxFile = new IdxFile(path, ifoFile.getLongWordCount(), ifoFile.getLongIdxFileSize()); } else if (extension.equals("dict")) { dictFile = new DictFile(path); } } } if (ifoFile.isBoolIsLoaded() && idxFile.isLoaded()) { boolAvailable = true; } }
/** load index file and info file. */ public void reLoad() { boolAvailable = false; ifoFile.reload(); idxFile.reload(); if (ifoFile.isBoolIsLoaded() && idxFile.isLoaded()) { boolAvailable = true; } }