forked from victorwon/mopub-android-sdk
-
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
Nathan Shayefar
committed
Nov 12, 2015
1 parent
1415bfe
commit 2a60048
Showing
189 changed files
with
2,457 additions
and
999 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.mopub.mobileads; | ||
|
||
import android.content.Context; | ||
import android.text.TextUtils; | ||
|
||
import com.mopub.common.logging.MoPubLog; | ||
import com.tapjoy.TJActionRequest; | ||
import com.tapjoy.TJError; | ||
import com.tapjoy.TJPlacement; | ||
import com.tapjoy.TJPlacementListener; | ||
|
||
import java.util.Map; | ||
|
||
// Tested with Tapjoy SDK 11.1.0 | ||
public class TapjoyInterstitial extends CustomEventInterstitial implements TJPlacementListener { | ||
private TJPlacement tjPlacement; | ||
private CustomEventInterstitialListener mInterstitialListener; | ||
|
||
@Override | ||
protected void loadInterstitial(Context context, | ||
CustomEventInterstitialListener customEventInterstitialListener, | ||
Map<String, Object> localExtras, | ||
Map<String, String> serverExtras) { | ||
MoPubLog.d("Requesting Tapjoy interstitial"); | ||
|
||
mInterstitialListener = customEventInterstitialListener; | ||
|
||
String name = serverExtras.get("name"); | ||
if (TextUtils.isEmpty(name)) { | ||
MoPubLog.d("Tapjoy interstitial loaded with empty 'name' field. Request will fail."); | ||
} | ||
tjPlacement = new TJPlacement(context, name, this); | ||
tjPlacement.requestContent(); | ||
} | ||
|
||
@Override | ||
protected void onInvalidate() { | ||
// No custom cleanup to do here. | ||
} | ||
|
||
@Override | ||
protected void showInterstitial() { | ||
MoPubLog.d("Tapjoy interstitial will be shown"); | ||
tjPlacement.showContent(); | ||
} | ||
|
||
// Tapjoy | ||
|
||
@Override | ||
public void onRequestSuccess(TJPlacement placement) { | ||
if (placement.isContentAvailable()) { | ||
MoPubLog.d("Tapjoy interstitial request successful"); | ||
mInterstitialListener.onInterstitialLoaded(); | ||
} else { | ||
MoPubLog.d("No Tapjoy interstitials available"); | ||
mInterstitialListener.onInterstitialFailed(MoPubErrorCode.NETWORK_NO_FILL); | ||
} | ||
} | ||
|
||
@Override | ||
public void onRequestFailure(TJPlacement placement, TJError error) { | ||
MoPubLog.d("Tapjoy interstitial request failed"); | ||
mInterstitialListener.onInterstitialFailed(MoPubErrorCode.NETWORK_NO_FILL); | ||
} | ||
|
||
@Override | ||
public void onContentShow(TJPlacement placement) { | ||
MoPubLog.d("Tapjoy interstitial shown"); | ||
mInterstitialListener.onInterstitialShown(); | ||
} | ||
|
||
@Override | ||
public void onContentDismiss(TJPlacement placement) { | ||
MoPubLog.d("Tapjoy interstitial dismissed"); | ||
mInterstitialListener.onInterstitialDismissed(); | ||
} | ||
|
||
@Override | ||
public void onContentReady(TJPlacement placement) { | ||
} | ||
|
||
@Override | ||
public void onPurchaseRequest(TJPlacement placement, TJActionRequest request, | ||
String productId) { | ||
} | ||
|
||
@Override | ||
public void onRewardRequest(TJPlacement placement, TJActionRequest request, String itemId, | ||
int quantity) { | ||
} | ||
|
||
} |
132 changes: 132 additions & 0 deletions
132
extras/src/com/mopub/mobileads/TapjoyRewardedVideo.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,132 @@ | ||
package com.mopub.mobileads; | ||
|
||
import android.app.Activity; | ||
import android.support.annotation.NonNull; | ||
import android.text.TextUtils; | ||
|
||
import com.mopub.common.LifecycleListener; | ||
import com.mopub.common.MediationSettings; | ||
import com.mopub.common.logging.MoPubLog; | ||
import com.tapjoy.TJActionRequest; | ||
import com.tapjoy.TJError; | ||
import com.tapjoy.TJPlacement; | ||
import com.tapjoy.TJPlacementListener; | ||
|
||
import java.util.Map; | ||
|
||
// Tested with Tapjoy SDK 11.1.0 | ||
public class TapjoyRewardedVideo extends CustomEventRewardedVideo { | ||
private static final String TAPJOY_AD_NETWORK_CONSTANT = "tapjoy_id"; | ||
private TJPlacement tjPlacement; | ||
private static TapjoyRewardedVideoListener sTapjoyListener = new TapjoyRewardedVideoListener(); | ||
|
||
@Override | ||
protected CustomEventRewardedVideoListener getVideoListenerForSdk() { | ||
return sTapjoyListener; | ||
} | ||
|
||
@Override | ||
protected LifecycleListener getLifecycleListener() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String getAdNetworkId() { | ||
return TAPJOY_AD_NETWORK_CONSTANT; | ||
} | ||
|
||
@Override | ||
protected void onInvalidate() { | ||
} | ||
|
||
@Override | ||
protected boolean checkAndInitializeSdk(@NonNull Activity launcherActivity, | ||
@NonNull Map<String, Object> localExtras, | ||
@NonNull Map<String, String> serverExtras) | ||
throws Exception { | ||
// Always return false, no special initialization steps to be done from here | ||
return false; | ||
} | ||
|
||
@Override | ||
protected void loadWithSdkInitialized(@NonNull Activity activity, | ||
@NonNull Map<String, Object> localExtras, | ||
@NonNull Map<String, String> serverExtras) | ||
throws Exception { | ||
MoPubLog.d("Requesting Tapjoy rewarded video"); | ||
|
||
String name = serverExtras.get("name"); | ||
if (TextUtils.isEmpty(name)) { | ||
MoPubLog.d("Tapjoy interstitial loaded with empty 'name' field. Request will fail."); | ||
} | ||
tjPlacement = new TJPlacement(activity, name, sTapjoyListener); | ||
tjPlacement.requestContent(); | ||
} | ||
|
||
@Override | ||
protected boolean hasVideoAvailable() { | ||
return tjPlacement.isContentAvailable(); | ||
} | ||
|
||
@Override | ||
protected void showVideo() { | ||
if (hasVideoAvailable()) { | ||
MoPubLog.d("Tapjoy rewarded video will be shown."); | ||
tjPlacement.showContent(); | ||
} else { | ||
MoPubLog.d("Failed to show Tapjoy rewarded video."); | ||
} | ||
|
||
} | ||
|
||
private static class TapjoyRewardedVideoListener implements TJPlacementListener, CustomEventRewardedVideoListener { | ||
@Override | ||
public void onRequestSuccess(TJPlacement placement) { | ||
if (!placement.isContentAvailable()) { | ||
MoPubLog.d("No Tapjoy rewarded videos available"); | ||
MoPubRewardedVideoManager.onRewardedVideoLoadFailure(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT, MoPubErrorCode.NETWORK_NO_FILL); | ||
} | ||
} | ||
|
||
@Override | ||
public void onContentReady(TJPlacement placement) { | ||
MoPubLog.d("Tapjoy rewarded video content is ready"); | ||
MoPubRewardedVideoManager.onRewardedVideoLoadSuccess(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT); | ||
} | ||
|
||
@Override | ||
public void onRequestFailure(TJPlacement placement, TJError error) { | ||
MoPubLog.d("Tapjoy rewarded video request failed"); | ||
MoPubRewardedVideoManager.onRewardedVideoLoadFailure(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT, MoPubErrorCode.NETWORK_NO_FILL); | ||
} | ||
|
||
@Override | ||
public void onContentShow(TJPlacement placement) { | ||
MoPubLog.d("Tapjoy rewarded video content shown"); | ||
MoPubRewardedVideoManager.onRewardedVideoStarted(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT); | ||
} | ||
|
||
@Override | ||
public void onContentDismiss(TJPlacement placement) { | ||
MoPubLog.d("Tapjoy rewarded video content dismissed"); | ||
MoPubRewardedVideoManager.onRewardedVideoClosed(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT); | ||
} | ||
|
||
@Override | ||
public void onPurchaseRequest(TJPlacement placement, TJActionRequest request, | ||
String productId) { | ||
} | ||
|
||
@Override | ||
public void onRewardRequest(TJPlacement placement, TJActionRequest request, String itemId, | ||
int quantity) { | ||
} | ||
} | ||
|
||
public static final class TapjoyMediationSettings implements MediationSettings { | ||
public TapjoyMediationSettings() { | ||
|
||
} | ||
} | ||
|
||
} |
Oops, something went wrong.