Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorАлександр Зацепин <az@mapswithme.com>2017-10-02 15:42:41 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2017-10-04 10:56:41 +0300
commit029aff3e8f868fa39055718cad7fe1210817428d (patch)
tree3a26c912ab73a59c98c5d63f27e400643558b943 /android/src/com/mopub
parentac6f8677b38d60499031e2dcf3296c453e163852 (diff)
[android] Update Facebook native ads sdk and MopUb sdk
Diffstat (limited to 'android/src/com/mopub')
-rw-r--r--android/src/com/mopub/nativeads/FacebookNative.java37
1 files changed, 26 insertions, 11 deletions
diff --git a/android/src/com/mopub/nativeads/FacebookNative.java b/android/src/com/mopub/nativeads/FacebookNative.java
index 3898abe89b..930e0d2d78 100644
--- a/android/src/com/mopub/nativeads/FacebookNative.java
+++ b/android/src/com/mopub/nativeads/FacebookNative.java
@@ -2,11 +2,11 @@ package com.mopub.nativeads;
import android.content.Context;
import android.view.View;
+import android.view.ViewGroup;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.AdListener;
-import com.facebook.ads.ImpressionListener;
import com.facebook.ads.MediaView;
import com.facebook.ads.NativeAd;
import com.facebook.ads.NativeAd.Rating;
@@ -21,10 +21,12 @@ import java.util.Map;
import static com.mopub.nativeads.NativeImageHelper.preCacheImages;
/**
- * Tested with Facebook SDK 4.15.0. FacebookAdRenderer is also necessary in order to show video ads.
+ * FacebookAdRenderer is also necessary in order to show video ads.
* Video ads will only be shown if VIDEO_ENABLED is set to true or a server configuration
* "video_enabled" flag is set to true. The server configuration will override the local
* configuration.
+ * Please reference the Supported Mediation Partner page at http://bit.ly/2mqsuFH for the
+ * latest version and ad format certifications.
*/
public class FacebookNative extends CustomEventNative {
private static final String PLACEMENT_ID_KEY = "placement_id";
@@ -126,7 +128,24 @@ public class FacebookNative extends CustomEventNative {
return (placementId != null && placementId.length() > 0);
}
- static class FacebookStaticNativeAd extends StaticNativeAd implements AdListener, ImpressionListener {
+ private static void registerChildViewsForInteraction(final View view, final NativeAd nativeAd) {
+ if (nativeAd == null) {
+ return;
+ }
+
+ if (view instanceof ViewGroup && ((ViewGroup) view).getChildCount() > 0) {
+ final ViewGroup vg = (ViewGroup) view;
+ final List<View> clickableViews = new ArrayList<>();
+ for (int i = 0; i < vg.getChildCount(); i++) {
+ clickableViews.add(vg.getChildAt(i));
+ }
+ nativeAd.registerViewForInteraction(view, clickableViews);
+ } else {
+ nativeAd.registerViewForInteraction(view);
+ }
+ }
+
+ static class FacebookStaticNativeAd extends StaticNativeAd implements AdListener {
private static final String SOCIAL_CONTEXT_FOR_AD = "socialContextForAd";
private final Context mContext;
@@ -143,7 +162,6 @@ public class FacebookNative extends CustomEventNative {
void loadAd() {
mNativeAd.setAdListener(this);
- mNativeAd.setImpressionListener(this);
mNativeAd.loadAd();
}
@@ -221,7 +239,6 @@ public class FacebookNative extends CustomEventNative {
notifyAdClicked();
}
- // ImpressionListener
@Override
public void onLoggingImpression(final Ad ad) {
notifyAdImpressed();
@@ -230,7 +247,7 @@ public class FacebookNative extends CustomEventNative {
// BaseForwardingNativeAd
@Override
public void prepare(final View view) {
- mNativeAd.registerViewForInteraction(view);
+ registerChildViewsForInteraction(view, mNativeAd);
}
@Override
@@ -253,7 +270,7 @@ public class FacebookNative extends CustomEventNative {
}
- static class FacebookVideoEnabledNativeAd extends BaseNativeAd implements AdListener, ImpressionListener {
+ static class FacebookVideoEnabledNativeAd extends BaseNativeAd implements AdListener {
private static final String SOCIAL_CONTEXT_FOR_AD = "socialContextForAd";
static final double MIN_STAR_RATING = 0;
@@ -278,7 +295,6 @@ public class FacebookNative extends CustomEventNative {
void loadAd() {
mNativeAd.setAdListener(this);
- mNativeAd.setImpressionListener(this);
mNativeAd.loadAd();
}
@@ -407,7 +423,6 @@ public class FacebookNative extends CustomEventNative {
notifyAdClicked();
}
- // ImpressionListener
@Override
public void onLoggingImpression(final Ad ad) {
notifyAdImpressed();
@@ -416,7 +431,7 @@ public class FacebookNative extends CustomEventNative {
// BaseForwardingNativeAd
@Override
public void prepare(final View view) {
- mNativeAd.registerViewForInteraction(view);
+ registerChildViewsForInteraction(view, mNativeAd);
}
@Override
@@ -450,7 +465,7 @@ public class FacebookNative extends CustomEventNative {
return new HashMap<String, Object>(mExtras);
}
- final public void addExtra( final String key, final Object value) {
+ final public void addExtra(final String key, final Object value) {
if (!Preconditions.NoThrow.checkNotNull(key, "addExtra key is not allowed to be null")) {
return;
}