From 0db06d98a85c26661c9f6612512ed250a9eb548f Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 24 Sep 2019 11:47:05 +0200 Subject: [PATCH] Add missing implementation of android's getArticleCount and getMediaCount. Fix #281 --- src/android/kiwixreader.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/android/kiwixreader.cpp b/src/android/kiwixreader.cpp index f306d81e1..4af589a4b 100644 --- a/src/android/kiwixreader.cpp +++ b/src/android/kiwixreader.cpp @@ -424,6 +424,35 @@ Java_org_kiwix_kiwixlib_JNIKiwixReader_getDescription(JNIEnv* env, jobject obj) return description; } +JNIEXPORT jint JNICALL +Java_org_kiwix_kiwixlib_JNIKiwixReader_getArticleCount(JNIEnv* env, jobject obj) +{ + jint articleCount = 0; + try { + auto cArticleCount = READER->getArticleCount(); + articleCount = c2jni(cArticleCount); + } catch (std::exception& e) { + __android_log_print(ANDROID_LOG_ERROR, "kiwix", "Unable to get article count."); + __android_log_print(ANDROID_LOG_ERROR, "kiwix", e.what()); + } + return articleCount; +} + +JNIEXPORT jint JNICALL +Java_org_kiwix_kiwixlib_JNIKiwixReader_getMediaCount(JNIEnv* env, jobject obj) +{ + jint mediaCount = 0; + try { + auto cMediaCount = READER->getMediaCount(); + mediaCount = c2jni(cMediaCount); + } catch (std::exception& e) { + __android_log_print(ANDROID_LOG_ERROR, "kiwix", "Unable to get media count."); + __android_log_print(ANDROID_LOG_ERROR, "kiwix", e.what()); + } + return mediaCount; +} + + JNIEXPORT jboolean JNICALL Java_org_kiwix_kiwixlib_JNIKiwixReader_getRandomPage( JNIEnv* env, jobject obj, jobject urlObj) {