Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#include "AppDelegate.h"
#include "cocos2d.h"
#include "platform/android/jni/JniHelper.h"
#include <jni.h>
#include <memory>

#include <android/log.h>
#include "PluginJniHelper.h"
#include <jni.h>

#include "platform/android/PluginJniHelper.h"

#include "AppDelegate.h"

#define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)

using namespace cocos2d;
namespace {
std::unique_ptr<AppDelegate> appDelegate;
}

void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init(JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
appDelegate.reset(new AppDelegate());
JavaVM* vm;
env->GetJavaVM(&vm);
PluginJniHelper::setJavaVM(vm);
cocos2d::PluginJniHelper::setJavaVM(vm);
}
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
#include "AppDelegate.h"
#include "cocos2d.h"
#include "platform/android/jni/JniHelper.h"
#include <jni.h>
#include <memory>

#include <android/log.h>
#include <jni.h>

#include "platform/android/PluginJniHelper.h"

#include "AppDelegate.h"
#include "ConfigParser.h"
#include "PluginJniHelper.h"

#define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)

using namespace cocos2d;

void cocos_android_app_init (JNIEnv* env, jobject thiz) {
namespace {
std::unique_ptr<AppDelegate> appDelegate;
}

void cocos_android_app_init(JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
appDelegate.reset(new AppDelegate());
JavaVM* vm;
env->GetJavaVM(&vm);
PluginJniHelper::setJavaVM(vm);
}


extern "C"
{
bool Java_org_cocos2dx_HelloPluginsLua_AppActivity_nativeIsLandScape(JNIEnv *env, jobject thisz)
{
if (!ConfigParser::getInstance()->isInit())
{
ConfigParser::getInstance()->readConfig();
}
return ConfigParser::getInstance()->isLanscape();
}

bool Java_org_cocos2dx_HelloPluginsLua_AppActivity_nativeIsDebug(JNIEnv *env, jobject thisz)
{
#ifdef NDEBUG
return false;
#else
return true;
#endif
}
}
bool Java_org_cocos2dx_HelloPluginsLua_AppActivity_nativeIsLandScape(JNIEnv *env, jobject thisz)
{
if (!ConfigParser::getInstance()->isInit())
{
ConfigParser::getInstance()->readConfig();
}
return ConfigParser::getInstance()->isLanscape();
}

bool Java_org_cocos2dx_HelloPluginsLua_AppActivity_nativeIsDebug(JNIEnv *env, jobject thisz)
{
#ifdef NDEBUG
return false;
#else
return true;
#endif
}
}