# HG changeset patch # User John Tsiombikas # Date 1444269345 -10800 # Node ID c6c45fa9658dbc5dc2a515c3fe7e5c13cd9812ee # Parent 74b50b538858d9063992747840ffc15601a9dd11 fixed jni calls for ads diff -r 74b50b538858 -r c6c45fa9658d src/android/MainActivity.java --- a/src/android/MainActivity.java Mon Oct 05 17:16:31 2015 +0300 +++ b/src/android/MainActivity.java Thu Oct 08 04:55:45 2015 +0300 @@ -173,7 +173,9 @@ }); - request_ad(); + if(!waiting_for_ad) { + request_ad(); + } Log.i(tag, "Done creating ad popup"); } @@ -210,11 +212,15 @@ private void show_ad() { Log.i(tag, "show_ad called"); - //ad_view.setVisibility(View.VISIBLE); if(ad_ready) { + if(ad_win == null) { + create_ad_popup(); + } + ad_view.setVisibility(View.VISIBLE); ad_win.showAtLocation(ad_main_layout, Gravity.TOP, 0, 0); ad_win.update(); + Log.i(tag, "showing ad window: " + ad_win); } else { if(!waiting_for_ad) { request_ad(); @@ -226,7 +232,11 @@ { Log.i(tag, "hide_ad called"); //ad_view.setVisibility(View.GONE); + Log.i(tag, "hiding ad window: " + ad_win); ad_win.dismiss(); + ad_win.update(); + //ad_win.update(); + //destroy_ad_popup(); ad_ready = false; waiting_for_ad = false; } diff -r 74b50b538858 -r c6c45fa9658d src/android/amain.c --- a/src/android/amain.c Mon Oct 05 17:16:31 2015 +0300 +++ b/src/android/amain.c Thu Oct 08 04:55:45 2015 +0300 @@ -29,6 +29,7 @@ static JavaVM *jvm; static JNIEnv *jni; static jclass activity_class; +static jobject activity; void android_main(struct android_app *app_ptr) { @@ -47,6 +48,7 @@ fprintf(stderr, "failed to attach native thread to Java VM\n"); exit(1); } + activity = app->activity->clazz; activity_class = (*jni)->GetObjectClass(jni, app->activity->clazz); for(;;) { @@ -88,7 +90,7 @@ fprintf(stderr, "failed to retrieve MainActivity.show_ad method\n"); return; } - (*jni)->CallVoidMethod(jni, activity_class, method); + (*jni)->CallVoidMethod(jni, activity, method); } void ad_banner_hide(void) @@ -100,7 +102,7 @@ fprintf(stderr, "failed to retrieve MainActivity.hide_ad method\n"); return; } - (*jni)->CallVoidMethod(jni, activity_class, method); + (*jni)->CallVoidMethod(jni, activity, method); } static void handle_command(struct android_app *app, int32_t cmd)