<commit_before>#ifdef PLATFORM_ANDROID

#include "platform.h"

#include <jni.h>
#include <android/log.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <cstdarg>

static JavaVM* jvm;
static jobject tangramObj;
static jmethodID requestRenderMethodID;
static AAssetManager* assetManager;

void jniInit(JNIEnv* _jniEnv, jobject _tangramInstance, jobject _assetManager) {

    assetManager = AAssetManager_fromJava(_jniEnv, _assetManager);

    if (assetManager == nullptr) {
        logMsg("ERROR: Could not obtain Asset Manager reference\n");
    }

    _jniEnv->GetJavaVM(&jvm);
    tangramObj = _jniEnv->NewGlobalRef(_tangramInstance);
    
}

void logMsg(const char* fmt, ...) {

    va_list args;
    va_start(args, fmt);
    __android_log_vprint(ANDROID_LOG_DEBUG, "Tangram", fmt, args);
    va_end(args);

}

void requestRender() {
    
    JNIEnv *jniEnv;

    bool isAttached = false;
    int status = jvm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6);
    if(status == JNI_EDETACHED) {
        status = jvm->AttachCurrentThread(&jniEnv, NULL);
        isAttached = true;
    }
    jclass tangramClass = jniEnv->GetObjectClass(tangramObj);
    requestRenderMethodID = jniEnv->GetMethodID(tangramClass, "requestRender", "()V");
    jniEnv->CallVoidMethod(tangramObj, requestRenderMethodID);
    if(isAttached) {
        jvm->DetachCurrentThread();
    }
}

std::string stringFromResource(const char* _path) {

    std::string out;
    
    // Open asset<commit_msg>Implement getter/setter for continuous rendering on Android<commit_after>#ifdef PLATFORM_ANDROID

#include "platform.h"

#include <jni.h>
#include <android/log.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <cstdarg>

static JavaVM* jvm;
static jobject tangramObj;
static jmethodID requestRenderMethodID;
static AAssetManager* assetManager;
static bool s_isContinuousRendering = false;

void jniInit(JNIEnv* _jniEnv, jobject _tangramInstance, jobject _assetManager) {

    assetManager = AAssetManager_fromJava(_jniEnv, _assetManager);

    if (assetManager == nullptr) {
        logMsg("ERROR: Could not obtain Asset Manager reference\n");
    }

    _jniEnv->GetJavaVM(&jvm);
    tangramObj = _jniEnv->NewGlobalRef(_tangramInstance);
    
}

void logMsg(const char* fmt, ...) {

    va_list args;
    va_start(args, fmt);
    __android_log_vprint(ANDROID_LOG_DEBUG, "Tangram", fmt, args);
    va_end(args);

}

void requestRender() {
    
    JNIEnv *jniEnv;

    bool isAttached = false;
    int status = jvm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6);
    if(status == JNI_EDETACHED) {
        status = jvm->AttachCurrentThread(&jniEnv, NULL);
        isAttached = true;
    }
    jclass tangramClass = jniEnv->GetObjectClass(tangramObj);
    requestRenderMethodID = jniEnv->GetMethodID(tangramClass, "requestRender", "()V");
    jniEnv->CallVoidMethod(tangramObj, requestRenderMethodID);
    if(isAttached) {
        jvm->DetachCurrentThread();
    }
}

void setContinuousRendering(bool _isContinuous) {

    s_isContinuousRendering = _isContinuous;

    JNIEnv *jniEnv;

    bool isAttached = false;
    int status = jvm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6);
    if(status == JNI_EDETACHED) {
        status = jvm->AttachCurrentThread(&jniEnv, NULL);
        isAttached = true;
    }
    jclass tangramClass = jniEnv->GetObjectClass(tangramObj);
    requestRenderMethodID = jniEnv->GetMethodID(tangramClass, "setRenderMode", "(I)V");
    jniEnv->CallVoidMethod(tangramObj, requestRenderMethodID, _isContinuous ? 1 : 0);
    if(isAttached) {
        jvm->DetachCurrentThread();
    }

}

bool isContinuousRendering() {

    return s_isContinuousRendering;

}

std::string stringFromResource(const char* _path) {

    std::string out;
    
    // Open asset
{'fraction_non_alphanumeric': 0.11665790856542302, 'fraction_numerical': 0.0021019442984760903, 'mean_word_length': 4.172554347826087, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6865290', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1329, 'n_words': 246}