mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
+ new getId() JNI method
This commit is contained in:
parent
413e4c2ee1
commit
46104f74ba
17
kiwix.c
17
kiwix.c
@ -81,6 +81,23 @@ JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getMainPage(JNIEnv
|
||||
return url;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getId(JNIEnv *env, jobject obj) {
|
||||
jstring id;
|
||||
|
||||
pthread_mutex_lock(&readerLock);
|
||||
if (reader != NULL) {
|
||||
try {
|
||||
std::string cId = reader->getId();
|
||||
id = c2jni(cId, env);
|
||||
} catch (exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&readerLock);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_loadZIM(JNIEnv *env, jobject obj, jstring path) {
|
||||
jboolean retVal = JNI_TRUE;
|
||||
std::string cPath = jni2c(path, env);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
package org.kiwix.kiwixmobile;
|
||||
public class JNIKiwix {
|
||||
public native String getMainPage();
|
||||
public native String getId();
|
||||
public native boolean loadZIM(String path);
|
||||
public native byte[] getContent(String url, JNIKiwixString mimeType, JNIKiwixInt size);
|
||||
public native boolean searchSuggestions(String prefix, int count);
|
||||
|
@ -67,6 +67,14 @@ public class ZimContentProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getId() {
|
||||
if (jniKiwix==null || zimFileName==null)
|
||||
return null;
|
||||
else {
|
||||
return jniKiwix.getId();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean searchSuggestions(String prefix, int count) {
|
||||
if (jniKiwix==null || zimFileName==null)
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user