-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vinokurov Kirill
committed
Apr 19, 2019
1 parent
728e5d4
commit de91d74
Showing
10 changed files
with
148 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
app/src/main/java/my/neomer/sixtyseconds/ads/AdMobAdProvider.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package my.neomer.sixtyseconds.ads; | ||
|
||
import android.content.Context; | ||
import android.net.sip.SipSession; | ||
import android.util.Log; | ||
|
||
import com.google.android.gms.ads.AdListener; | ||
import com.google.android.gms.ads.AdRequest; | ||
import com.google.android.gms.ads.InterstitialAd; | ||
import com.google.android.gms.ads.MobileAds; | ||
|
||
public class AdMobAdProvider extends AdListener implements IAdsProvider { | ||
private static final String LOG_TAG = "AdMobAdProvider"; | ||
|
||
//private static final String ADMOB_APP_KEY = "ca-app-pub-5078878060587689~8320307873"; | ||
private static final String ADMOB_APP_KEY = "ca-app-pub-3940256099942544~3347511713"; // Sample adMob app | ||
//private static final String ADMOB_BETWEEN_ACTIVITY_KEY = "ca-app-pub-5078878060587689/9345738647"; | ||
private static final String ADMOB_BETWEEN_ACTIVITY_KEY = "ca-app-pub-3940256099942544/1033173712"; // Sample InterstitialAd | ||
|
||
private InterstitialAd interstitialAd; | ||
private IRewardedAdResultListener resultListener; | ||
|
||
@Override | ||
public void initialize(Context context) { | ||
MobileAds.initialize(context, ADMOB_APP_KEY); | ||
interstitialAd = new InterstitialAd(context); | ||
interstitialAd.setAdUnitId(ADMOB_BETWEEN_ACTIVITY_KEY); | ||
interstitialAd.loadAd(new AdRequest.Builder().build()); | ||
interstitialAd.setAdListener(this); | ||
} | ||
|
||
@Override | ||
public void onAdClosed() { | ||
Log.d(LOG_TAG, "Ad closed. Reload..."); | ||
interstitialAd.loadAd(new AdRequest.Builder().build()); | ||
if (resultListener != null) { | ||
resultListener.onAdComplete(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdFailedToLoad(int i) { | ||
Log.e(LOG_TAG, "Failed to load ad! Error: " + i); | ||
interstitialAd.loadAd(new AdRequest.Builder().build()); | ||
if (resultListener != null) { | ||
resultListener.onAdLoadFailed(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdClicked() { | ||
Log.d(LOG_TAG, "Ad clicked!"); | ||
interstitialAd.loadAd(new AdRequest.Builder().build()); | ||
if (resultListener != null) { | ||
resultListener.onAdClick(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdImpression() { | ||
Log.d(LOG_TAG, "Ad impressed!"); | ||
interstitialAd.loadAd(new AdRequest.Builder().build()); | ||
if (resultListener != null) { | ||
resultListener.onAdClick(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean showInterstitialAd(IRewardedAdResultListener listener) { | ||
resultListener = listener; | ||
if (interstitialAd.isLoaded()) { | ||
interstitialAd.show(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean showRewardedAd(IRewardedAdResultListener listener) { | ||
resultListener = listener; | ||
return false; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/my/neomer/sixtyseconds/ads/IAdsProvider.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package my.neomer.sixtyseconds.ads; | ||
|
||
import android.content.Context; | ||
|
||
public interface IAdsProvider { | ||
|
||
void initialize(Context context); | ||
|
||
boolean showInterstitialAd(IRewardedAdResultListener listener); | ||
|
||
boolean showRewardedAd(IRewardedAdResultListener listener); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/my/neomer/sixtyseconds/ads/IRewardedAdResultListener.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package my.neomer.sixtyseconds.ads; | ||
|
||
public interface IRewardedAdResultListener { | ||
|
||
void onAdClick(); | ||
|
||
void onAdComplete(); | ||
|
||
void onAdLoadFailed(); | ||
|
||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Thu Mar 28 18:29:56 SAMT 2019 | ||
#Fri Apr 19 08:10:26 SAMT 2019 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip |