mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
Constructor class
This commit is contained in:
parent
3f2836844e
commit
4f6ef22b33
5 changed files with 48 additions and 26 deletions
|
@ -17,11 +17,10 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <AndroidUtil.h>
|
||||
#include <JniEnvelope.h>
|
||||
|
||||
#include "fbreader/src/formats/FormatPlugin.h"
|
||||
|
||||
|
@ -29,18 +28,17 @@ extern "C"
|
|||
JNIEXPORT jobjectArray JNICALL Java_org_geometerplus_fbreader_formats_PluginCollection_nativePlugins(JNIEnv* env, jobject thiz) {
|
||||
const std::vector<shared_ptr<FormatPlugin> > plugins = PluginCollection::Instance().plugins();
|
||||
const size_t size = plugins.size();
|
||||
jclass cls = env->FindClass(AndroidUtil::Class_NativeFormatPlugin);
|
||||
jclass cls = AndroidUtil::Class_NativeFormatPlugin->j();
|
||||
// TODO: memory leak?
|
||||
jobjectArray javaPlugins = env->NewObjectArray(size, cls, 0);
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
jstring fileType = AndroidUtil::createJavaString(env, plugins[i]->supportedFileType());
|
||||
jobject p = env->NewObject(cls, AndroidUtil::MID_NativeFormatPlugin_init, fileType);
|
||||
jobject p = AndroidUtil::Constructor_NativeFormatPlugin->call(fileType);
|
||||
env->SetObjectArrayElement(javaPlugins, i, p);
|
||||
env->DeleteLocalRef(p);
|
||||
env->DeleteLocalRef(fileType);
|
||||
}
|
||||
env->DeleteLocalRef(cls);
|
||||
return javaPlugins;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue