mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 06:42:21 -04:00
Update JNI and catch the new exception thrown by an invalid ZIM
This commit is contained in:
parent
2f93ebf800
commit
41c0bb84c4
@ -34,7 +34,7 @@ dependencies {
|
||||
|
||||
// Get kiwixlib online if it is not populated locally
|
||||
if (file("../kiwixlib/src/main").list().length == 1) {
|
||||
implementation 'org.kiwix.kiwixlib:kiwixlib:1.0.6'
|
||||
implementation 'org.kiwix.kiwixlib:kiwixlib:1.0.8'
|
||||
} else {
|
||||
implementation project(':kiwixlib')
|
||||
archs = file("../kiwixlib/src/main/jniLibs").list()
|
||||
|
@ -31,6 +31,7 @@ import android.webkit.MimeTypeMap;
|
||||
|
||||
import java.io.RandomAccessFile;
|
||||
import org.kiwix.kiwixlib.JNIKiwix;
|
||||
import org.kiwix.kiwixlib.JNIKiwixException;
|
||||
import org.kiwix.kiwixlib.JNIKiwixInt;
|
||||
import org.kiwix.kiwixlib.JNIKiwixReader;
|
||||
import org.kiwix.kiwixlib.JNIKiwixSearcher;
|
||||
@ -110,19 +111,24 @@ public class ZimContentProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
public synchronized static String setZimFile(String fileName) {
|
||||
JNIKiwixReader reader = new JNIKiwixReader(fileName);
|
||||
if (!new File(fileName).exists() || reader == null) {
|
||||
Log.e(TAG_KIWIX, "Unable to open the ZIM file " + fileName);
|
||||
if (!new File(fileName).exists()) {
|
||||
Log.e(TAG_KIWIX, "Unable to find the ZIM file " + fileName);
|
||||
zimFileName = null;
|
||||
} else {
|
||||
return zimFileName;
|
||||
}
|
||||
try {
|
||||
JNIKiwixReader reader = new JNIKiwixReader(fileName);
|
||||
Log.i(TAG_KIWIX, "Opening ZIM file " + fileName);
|
||||
if(!listedEntries.contains(reader.getId())) {
|
||||
listedEntries.add(reader.getId());
|
||||
jniSearcher.addKiwixReader(reader);
|
||||
currentJNIReader = reader;
|
||||
}
|
||||
zimFileName = fileName;
|
||||
} catch (JNIKiwixException e) {
|
||||
Log.e(TAG_KIWIX, "Unable to open the ZIM file " + fileName);
|
||||
zimFileName = null;
|
||||
}
|
||||
currentJNIReader = reader;
|
||||
return zimFileName;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user