Android ZIM file size is displayed correctly for split ZIMs #329

This commit is contained in:
mhutti1 2016-09-27 15:28:01 +01:00
parent 1750fa90b1
commit 792452e4ef
8 changed files with 38 additions and 13 deletions

17
kiwix.c
View File

@ -109,6 +109,23 @@ JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getId(JNIEnv *env,
return id;
}
JNIEXPORT jint JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getFileSize(JNIEnv *env, jobject obj) {
jint size;
pthread_mutex_lock(&readerLock);
if (reader != NULL) {
try {
int cSize = reader->getFileSize();
size = c2jni(cSize);
} catch (exception &e) {
std::cerr << e.what() << std::endl;
}
}
pthread_mutex_unlock(&readerLock);
return size;
}
JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getCreator(JNIEnv *env, jobject obj) {
jstring creator;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -55,7 +55,7 @@ public class JNIKiwix {
public native String getPublisher();
public native boolean getFileSize(JNIKiwixInt size);
public native int getFileSize();
public native int getArticleCount();

View File

@ -102,6 +102,14 @@ public class ZimContentProvider extends ContentProvider {
}
}
public static int getFileSize() {
if (jniKiwix == null || zimFileName == null) {
return 0;
} else {
return jniKiwix.getFileSize();
}
}
public static int getArticleCount() {
if (jniKiwix == null || zimFileName == null) {
return 0;

View File

@ -148,7 +148,7 @@ public class FileSearch {
b.title = ZimContentProvider.getZimFileTitle();
b.id = ZimContentProvider.getId();
b.file = new File(file);
b.size = String.valueOf(b.file.length() / 1024);
b.size = String.valueOf(ZimContentProvider.getFileSize());
b.favicon = ZimContentProvider.getFavicon();
b.creator = ZimContentProvider.getCreator();
b.publisher = ZimContentProvider.getPublisher();