mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-10 07:48:30 -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
|
// Get kiwixlib online if it is not populated locally
|
||||||
if (file("../kiwixlib/src/main").list().length == 1) {
|
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 {
|
} else {
|
||||||
implementation project(':kiwixlib')
|
implementation project(':kiwixlib')
|
||||||
archs = file("../kiwixlib/src/main/jniLibs").list()
|
archs = file("../kiwixlib/src/main/jniLibs").list()
|
||||||
|
@ -31,6 +31,7 @@ import android.webkit.MimeTypeMap;
|
|||||||
|
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import org.kiwix.kiwixlib.JNIKiwix;
|
import org.kiwix.kiwixlib.JNIKiwix;
|
||||||
|
import org.kiwix.kiwixlib.JNIKiwixException;
|
||||||
import org.kiwix.kiwixlib.JNIKiwixInt;
|
import org.kiwix.kiwixlib.JNIKiwixInt;
|
||||||
import org.kiwix.kiwixlib.JNIKiwixReader;
|
import org.kiwix.kiwixlib.JNIKiwixReader;
|
||||||
import org.kiwix.kiwixlib.JNIKiwixSearcher;
|
import org.kiwix.kiwixlib.JNIKiwixSearcher;
|
||||||
@ -110,19 +111,24 @@ public class ZimContentProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static String setZimFile(String fileName) {
|
public synchronized static String setZimFile(String fileName) {
|
||||||
JNIKiwixReader reader = new JNIKiwixReader(fileName);
|
if (!new File(fileName).exists()) {
|
||||||
if (!new File(fileName).exists() || reader == null) {
|
Log.e(TAG_KIWIX, "Unable to find the ZIM file " + fileName);
|
||||||
Log.e(TAG_KIWIX, "Unable to open the ZIM file " + fileName);
|
|
||||||
zimFileName = null;
|
zimFileName = null;
|
||||||
} else {
|
return zimFileName;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JNIKiwixReader reader = new JNIKiwixReader(fileName);
|
||||||
Log.i(TAG_KIWIX, "Opening ZIM file " + fileName);
|
Log.i(TAG_KIWIX, "Opening ZIM file " + fileName);
|
||||||
if(!listedEntries.contains(reader.getId())) {
|
if(!listedEntries.contains(reader.getId())) {
|
||||||
listedEntries.add(reader.getId());
|
listedEntries.add(reader.getId());
|
||||||
jniSearcher.addKiwixReader(reader);
|
jniSearcher.addKiwixReader(reader);
|
||||||
|
currentJNIReader = reader;
|
||||||
}
|
}
|
||||||
zimFileName = fileName;
|
zimFileName = fileName;
|
||||||
|
} catch (JNIKiwixException e) {
|
||||||
|
Log.e(TAG_KIWIX, "Unable to open the ZIM file " + fileName);
|
||||||
|
zimFileName = null;
|
||||||
}
|
}
|
||||||
currentJNIReader = reader;
|
|
||||||
return zimFileName;
|
return zimFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user