istereo2

changeset 29:c6c45fa9658d

fixed jni calls for ads
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 08 Oct 2015 04:55:45 +0300
parents 74b50b538858
children 900651a2f401
files src/android/MainActivity.java src/android/amain.c
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/src/android/MainActivity.java	Mon Oct 05 17:16:31 2015 +0300
     1.2 +++ b/src/android/MainActivity.java	Thu Oct 08 04:55:45 2015 +0300
     1.3 @@ -173,7 +173,9 @@
     1.4  				});
     1.5  
     1.6  
     1.7 -				request_ad();
     1.8 +				if(!waiting_for_ad) {
     1.9 +					request_ad();
    1.10 +				}
    1.11  
    1.12  				Log.i(tag, "Done creating ad popup");
    1.13  			}
    1.14 @@ -210,11 +212,15 @@
    1.15  	private void show_ad()
    1.16  	{
    1.17  		Log.i(tag, "show_ad called");
    1.18 -		//ad_view.setVisibility(View.VISIBLE);
    1.19  
    1.20  		if(ad_ready) {
    1.21 +			if(ad_win == null) {
    1.22 +				create_ad_popup();
    1.23 +			}
    1.24 +			ad_view.setVisibility(View.VISIBLE);
    1.25  			ad_win.showAtLocation(ad_main_layout, Gravity.TOP, 0, 0);
    1.26  			ad_win.update();
    1.27 +			Log.i(tag, "showing ad window: " + ad_win);
    1.28  		} else {
    1.29  			if(!waiting_for_ad) {
    1.30  				request_ad();
    1.31 @@ -226,7 +232,11 @@
    1.32  	{
    1.33  		Log.i(tag, "hide_ad called");
    1.34  		//ad_view.setVisibility(View.GONE);
    1.35 +		Log.i(tag, "hiding ad window: " + ad_win);
    1.36  		ad_win.dismiss();
    1.37 +		ad_win.update();
    1.38 +		//ad_win.update();
    1.39 +		//destroy_ad_popup();
    1.40  		ad_ready = false;
    1.41  		waiting_for_ad = false;
    1.42  	}
     2.1 --- a/src/android/amain.c	Mon Oct 05 17:16:31 2015 +0300
     2.2 +++ b/src/android/amain.c	Thu Oct 08 04:55:45 2015 +0300
     2.3 @@ -29,6 +29,7 @@
     2.4  static JavaVM *jvm;
     2.5  static JNIEnv *jni;
     2.6  static jclass activity_class;
     2.7 +static jobject activity;
     2.8  
     2.9  void android_main(struct android_app *app_ptr)
    2.10  {
    2.11 @@ -47,6 +48,7 @@
    2.12  		fprintf(stderr, "failed to attach native thread to Java VM\n");
    2.13  		exit(1);
    2.14  	}
    2.15 +	activity = app->activity->clazz;
    2.16  	activity_class = (*jni)->GetObjectClass(jni, app->activity->clazz);
    2.17  
    2.18  	for(;;) {
    2.19 @@ -88,7 +90,7 @@
    2.20  		fprintf(stderr, "failed to retrieve MainActivity.show_ad method\n");
    2.21  		return;
    2.22  	}
    2.23 -	(*jni)->CallVoidMethod(jni, activity_class, method);
    2.24 +	(*jni)->CallVoidMethod(jni, activity, method);
    2.25  }
    2.26  
    2.27  void ad_banner_hide(void)
    2.28 @@ -100,7 +102,7 @@
    2.29  		fprintf(stderr, "failed to retrieve MainActivity.hide_ad method\n");
    2.30  		return;
    2.31  	}
    2.32 -	(*jni)->CallVoidMethod(jni, activity_class, method);
    2.33 +	(*jni)->CallVoidMethod(jni, activity, method);
    2.34  }
    2.35  
    2.36  static void handle_command(struct android_app *app, int32_t cmd)