Last active
August 27, 2016 19:00
-
-
Save ayublin/c628370368a5b97175df8748d7927002 to your computer and use it in GitHub Desktop.
Tapdaq Android Universal Bootup Callback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company.myawesomeapp; | |
import android.content.Context; | |
import android.view.Display; | |
import android.view.Surface; | |
import android.view.WindowManager; | |
import com.tapdaq.sdk.Tapdaq; | |
import com.tapdaq.sdk.TapdaqCallbacks; | |
public class BootupTapDaqCallbacks extends TapdaqCallbacks { | |
private final Context context; | |
private boolean hasDisplayedInterstitial; | |
public BootupTapDaqCallbacks(final Context context) { | |
this.context = context; | |
this.hasDisplayedInterstitial = false; | |
} | |
@Override | |
public void hasPortraitInterstitialAvailable() { | |
Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); | |
int rotation = display.getRotation(); | |
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { | |
if (!hasDisplayedInterstitial) { | |
hasDisplayedInterstitial = true; | |
if(! ((Activity) context).isFinishing() ) { | |
Tapdaq.tapdaq().displayInterstitial(context, this); | |
} | |
} | |
} | |
} | |
@Override | |
public void hasLandscapeInterstitialAvailable() { | |
Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); | |
int rotation = display.getRotation(); | |
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { | |
if (!hasDisplayedInterstitial) { | |
hasDisplayedInterstitial = true; | |
if(! ((Activity) context).isFinishing() ) { | |
Tapdaq.tapdaq().displayInterstitial(context, this); | |
} | |
} | |
} | |
} | |
@Override | |
public void didDisplayInterstitial() { | |
hasDisplayedInterstitial = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment