Should help debugging "dictionaries disappear" issues.
for (final String uncompressedFilename : oldDictionaryConfig.dictionaryFilesOrdered) {
final File dictFile = getPath(uncompressedFilename);
final DictionaryInfo dictionaryInfo = Dictionary.getDictionaryInfo(dictFile);
for (final String uncompressedFilename : oldDictionaryConfig.dictionaryFilesOrdered) {
final File dictFile = getPath(uncompressedFilename);
final DictionaryInfo dictionaryInfo = Dictionary.getDictionaryInfo(dictFile);
- if (dictionaryInfo != null) {
+ if (dictionaryInfo.isValid()) {
newDictionaryConfig.dictionaryFilesOrdered.add(uncompressedFilename);
newDictionaryConfig.uncompressedFilenameToDictionaryInfo.put(
uncompressedFilename, dictionaryInfo);
newDictionaryConfig.dictionaryFilesOrdered.add(uncompressedFilename);
newDictionaryConfig.uncompressedFilenameToDictionaryInfo.put(
uncompressedFilename, dictionaryInfo);
continue;
}
final DictionaryInfo dictionaryInfo = Dictionary.getDictionaryInfo(file);
continue;
}
final DictionaryInfo dictionaryInfo = Dictionary.getDictionaryInfo(file);
- if (dictionaryInfo == null) {
+ if (!dictionaryInfo.isValid()) {
Log.e(LOG, "Unable to parse dictionary: " + file.getPath());
Log.e(LOG, "Unable to parse dictionary: " + file.getPath());
}
toAddSorted.add(file.getName());
}
toAddSorted.add(file.getName());
+ public boolean isValid() {
+ return !indexInfos.isEmpty();
+ }
+
public StringBuilder append(final StringBuilder result) {
result.append(uncompressedFilename);
result.append("\t").append(downloadUrl);
public StringBuilder append(final StringBuilder result) {
result.append(uncompressedFilename);
result.append("\t").append(downloadUrl);
}
private View createDictionaryRow(final DictionaryInfo dictionaryInfo,
}
private View createDictionaryRow(final DictionaryInfo dictionaryInfo,
- final ViewGroup parent, final boolean canLaunch) {
+ final ViewGroup parent, boolean canLaunch) {
View row = LayoutInflater.from(parent.getContext()).inflate(
R.layout.dictionary_manager_row, parent, false);
View row = LayoutInflater.from(parent.getContext()).inflate(
R.layout.dictionary_manager_row, parent, false);
final boolean updateAvailable = application.updateAvailable(dictionaryInfo);
final Button downloadButton = (Button) row.findViewById(R.id.downloadButton);
final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename);
final boolean updateAvailable = application.updateAvailable(dictionaryInfo);
final Button downloadButton = (Button) row.findViewById(R.id.downloadButton);
final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename);
- if (!canLaunch || updateAvailable) {
+ boolean broken = false;
+ if (!dictionaryInfo.isValid()) {
+ broken = true;
+ canLaunch = false;
+ }
+ if (downloadable != null && (!canLaunch || updateAvailable)) {
downloadButton
.setText(getString(
R.string.downloadButton,
downloadButton
.setText(getString(
R.string.downloadButton,
builder.append("; ");
builder.append(getString(R.string.downloadButton, downloadable.uncompressedBytes / 1024.0 / 1024.0));
}
builder.append("; ");
builder.append(getString(R.string.downloadButton, downloadable.uncompressedBytes / 1024.0 / 1024.0));
}
+ if (broken) {
+ name.setText("Broken: " + application.getDictionaryName(dictionaryInfo.uncompressedFilename));
+ builder.append("; Cannot be used, redownload, check hardware/file system");
+ }
details.setText(builder.toString());
if (canLaunch) {
details.setText(builder.toString());
if (canLaunch) {
raf.close();
return dictionaryInfo;
} catch (IOException e) {
raf.close();
return dictionaryInfo;
} catch (IOException e) {
+ final DictionaryInfo dictionaryInfo = new DictionaryInfo();
+ dictionaryInfo.uncompressedFilename = file.getName();
+ dictionaryInfo.uncompressedBytes = file.length();
+ return dictionaryInfo;
} finally {
if (raf != null) {
try {
} finally {
if (raf != null) {
try {