GoooBet v1.0版本的 MD5 值为:ff9748f16167bfd7735b669c0a9931c5
以下内容为反编译后的 MoPubCustomEventNative.java 源代码,内容仅作参考
package com.mopub.nativeads;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import com.mopub.common.DataKeys;
import com.mopub.common.logging.MoPubLog;
import com.mopub.common.util.Numbers;
import com.mopub.nativeads.CustomEventNative;
import com.mopub.nativeads.NativeImageHelper;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONObject;
public class MoPubCustomEventNative extends CustomEventNative {
public static final String ADAPTER_NAME = MoPubCustomEventNative.class.getSimpleName();
private MoPubStaticNativeAd moPubStaticNativeAd;
@Override
public void loadNativeAd(Context context, CustomEventNative.CustomEventNativeListener customEventNativeListener, Map<String, Object> map, Map<String, String> map2) {
MoPubLog.log(MoPubLog.AdapterLogEvent.LOAD_ATTEMPTED, ADAPTER_NAME);
MoPubStaticNativeAd moPubStaticNativeAd = this.moPubStaticNativeAd;
if (moPubStaticNativeAd == null || moPubStaticNativeAd.isInvalidated()) {
Object obj = map.get(DataKeys.JSON_BODY_KEY);
if (!(obj instanceof JSONObject)) {
MoPubLog.log(MoPubLog.AdapterLogEvent.LOAD_FAILED, ADAPTER_NAME, Integer.valueOf(NativeErrorCode.INVALID_RESPONSE.getIntCode()), NativeErrorCode.INVALID_RESPONSE);
customEventNativeListener.onNativeAdFailed(NativeErrorCode.INVALID_RESPONSE);
return;
}
this.moPubStaticNativeAd = new MoPubStaticNativeAd(context, (JSONObject) obj, new ImpressionTracker(context), new NativeClickHandler(context), customEventNativeListener);
if (map2.containsKey(DataKeys.IMPRESSION_MIN_VISIBLE_PERCENT)) {
try {
this.moPubStaticNativeAd.setImpressionMinPercentageViewed(Integer.parseInt(map2.get(DataKeys.IMPRESSION_MIN_VISIBLE_PERCENT)));
} catch (NumberFormatException unused) {
MoPubLog.log(MoPubLog.AdapterLogEvent.CUSTOM, ADAPTER_NAME, "Unable to format min visible percent: " + map2.get(DataKeys.IMPRESSION_MIN_VISIBLE_PERCENT));
}
}
if (map2.containsKey(DataKeys.IMPRESSION_VISIBLE_MS)) {
try {
this.moPubStaticNativeAd.setImpressionMinTimeViewed(Integer.parseInt(map2.get(DataKeys.IMPRESSION_VISIBLE_MS)));
} catch (NumberFormatException unused2) {
MoPubLog.log(MoPubLog.AdapterLogEvent.CUSTOM, ADAPTER_NAME, "Unable to format min time: " + map2.get(DataKeys.IMPRESSION_VISIBLE_MS));
}
}
if (map2.containsKey(DataKeys.IMPRESSION_MIN_VISIBLE_PX)) {
try {
this.moPubStaticNativeAd.setImpressionMinVisiblePx(Integer.valueOf(Integer.parseInt(map2.get(DataKeys.IMPRESSION_MIN_VISIBLE_PX))));
} catch (NumberFormatException unused3) {
MoPubLog.log(MoPubLog.AdapterLogEvent.CUSTOM, ADAPTER_NAME, "Unable to format min visible px: " + map2.get(DataKeys.IMPRESSION_MIN_VISIBLE_PX));
}
}
try {
this.moPubStaticNativeAd.loadAd();
MoPubLog.log(MoPubLog.AdapterLogEvent.LOAD_SUCCESS, ADAPTER_NAME);
} catch (IllegalArgumentException unused4) {
MoPubLog.log(MoPubLog.AdapterLogEvent.LOAD_FAILED, ADAPTER_NAME, Integer.valueOf(NativeErrorCode.UNSPECIFIED.getIntCode()), NativeErrorCode.UNSPECIFIED);
customEventNativeListener.onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
}
}
}
@Override
public void onInvalidate() {
MoPubStaticNativeAd moPubStaticNativeAd = this.moPubStaticNativeAd;
if (moPubStaticNativeAd == null) {
return;
}
moPubStaticNativeAd.invalidate();
}
static class MoPubStaticNativeAd extends StaticNativeAd {
static final String PRIVACY_INFORMATION_CLICKTHROUGH_URL = "https://www.mopub.com/optout";
private final Context mContext;
private final CustomEventNative.CustomEventNativeListener mCustomEventNativeListener;
private final ImpressionTracker mImpressionTracker;
private final JSONObject mJsonObject;
private final NativeClickHandler mNativeClickHandler;
public enum Parameter {
IMPRESSION_TRACKER("imptracker", true),
CLICK_TRACKER("clktracker", true),
TITLE("title", false),
TEXT("text", false),
MAIN_IMAGE("mainimage", false),
ICON_IMAGE("iconimage", false),
CLICK_DESTINATION("clk", false),
FALLBACK("fallback", false),
CALL_TO_ACTION("ctatext", false),
STAR_RATING("starrating", false),
PRIVACY_INFORMATION_ICON_IMAGE_URL("privacyicon", false),
PRIVACY_INFORMATION_ICON_CLICKTHROUGH_URL("privacyclkurl", false),
SPONSORED("sponsored", false);
static final Set<String> requiredKeys = new HashSet();
final String name;
final boolean required;
static {
for (Parameter parameter : values()) {
if (parameter.required) {
requiredKeys.add(parameter.name);
}
}
}
Parameter(String str, boolean z) {
this.name = str;
this.required = z;
}
static Parameter from(String str) {
for (Parameter parameter : values()) {
if (parameter.name.equals(str)) {
return parameter;
}
}
return null;
}
}
MoPubStaticNativeAd(Context context, JSONObject jSONObject, ImpressionTracker impressionTracker, NativeClickHandler nativeClickHandler, CustomEventNative.CustomEventNativeListener customEventNativeListener) {
this.mJsonObject = jSONObject;
this.mContext = context.getApplicationContext();
this.mImpressionTracker = impressionTracker;
this.mNativeClickHandler = nativeClickHandler;
this.mCustomEventNativeListener = customEventNativeListener;
}
void loadAd() throws IllegalArgumentException {
if (!containsRequiredKeys(this.mJsonObject)) {
throw new IllegalArgumentException("JSONObject did not contain required keys.");
}
Iterator<String> keys = this.mJsonObject.keys();
while (keys.hasNext()) {
String next = keys.next();
Parameter from = Parameter.from(next);
if (from != null) {
try {
addInstanceVariable(from, this.mJsonObject.opt(next));
} catch (ClassCastException unused) {
throw new IllegalArgumentException("JSONObject key (" + next + ") contained unexpected value.");
}
} else {
addExtra(next, this.mJsonObject.opt(next));
}
}
if (TextUtils.isEmpty(getPrivacyInformationIconClickThroughUrl())) {
setPrivacyInformationIconClickThroughUrl(PRIVACY_INFORMATION_CLICKTHROUGH_URL);
}
NativeImageHelper.preCacheImages(this.mContext, getAllImageUrls(), new NativeImageHelper.ImageListener() {
@Override
public void onImagesCached() {
if (MoPubStaticNativeAd.this.isInvalidated()) {
return;
}
MoPubStaticNativeAd.this.mCustomEventNativeListener.onNativeAdLoaded(MoPubStaticNativeAd.this);
}
@Override
public void onImagesFailedToCache(NativeErrorCode nativeErrorCode) {
if (MoPubStaticNativeAd.this.isInvalidated()) {
return;
}
MoPubStaticNativeAd.this.mCustomEventNativeListener.onNativeAdFailed(nativeErrorCode);
}
});
}
private boolean containsRequiredKeys(JSONObject jSONObject) {
HashSet hashSet = new HashSet();
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
hashSet.add(keys.next());
}
return hashSet.containsAll(Parameter.requiredKeys);
}
private void addInstanceVariable(Parameter parameter, Object obj) throws ClassCastException {
try {
switch (AnonymousClass1.$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[parameter.ordinal()]) {
case 1:
setMainImageUrl((String) obj);
return;
case 2:
setIconImageUrl((String) obj);
return;
case 3:
addImpressionTrackers(obj);
return;
case 4:
setClickDestinationUrl((String) obj);
return;
case 5:
parseClickTrackers(obj);
return;
case 6:
setCallToAction((String) obj);
return;
case 7:
setTitle((String) obj);
return;
case 8:
setText((String) obj);
return;
case 9:
setStarRating(Numbers.parseDouble(obj));
return;
case 10:
setPrivacyInformationIconImageUrl((String) obj);
return;
case 11:
setPrivacyInformationIconClickThroughUrl((String) obj);
return;
case 12:
setSponsored((String) obj);
break;
}
MoPubLog.log(MoPubLog.AdapterLogEvent.CUSTOM, MoPubCustomEventNative.ADAPTER_NAME, "Unable to add JSON key to internal mapping: " + parameter.name);
} catch (ClassCastException e) {
if (!parameter.required) {
MoPubLog.log(MoPubLog.AdapterLogEvent.CUSTOM, MoPubCustomEventNative.ADAPTER_NAME, "Ignoring class cast exception for optional key: " + parameter.name);
return;
}
throw e;
}
}
private void parseClickTrackers(Object obj) {
if (obj instanceof JSONArray) {
addClickTrackers(obj);
} else {
addClickTracker((String) obj);
}
}
private boolean isImageKey(String str) {
return str != null && str.toLowerCase(Locale.US).endsWith("image");
}
List<String> getExtrasImageUrls() {
ArrayList arrayList = new ArrayList(getExtras().size());
for (Map.Entry<String, Object> entry : getExtras().entrySet()) {
if (isImageKey(entry.getKey()) && (entry.getValue() instanceof String)) {
arrayList.add((String) entry.getValue());
}
}
return arrayList;
}
List<String> getAllImageUrls() {
ArrayList arrayList = new ArrayList();
if (!TextUtils.isEmpty(getMainImageUrl())) {
arrayList.add(getMainImageUrl());
}
if (!TextUtils.isEmpty(getIconImageUrl())) {
arrayList.add(getIconImageUrl());
}
if (!TextUtils.isEmpty(getPrivacyInformationIconImageUrl())) {
arrayList.add(getPrivacyInformationIconImageUrl());
}
arrayList.addAll(getExtrasImageUrls());
return arrayList;
}
@Override
public void prepare(View view) {
this.mImpressionTracker.addView(view, this);
this.mNativeClickHandler.setOnClickListener(view, this);
}
@Override
public void clear(View view) {
this.mImpressionTracker.removeView(view);
this.mNativeClickHandler.clearOnClickListener(view);
}
@Override
public void destroy() {
this.mImpressionTracker.destroy();
super.destroy();
}
@Override
public void recordImpression(View view) {
notifyAdImpressed();
}
@Override
public void handleClick(View view) {
MoPubLog.log(MoPubLog.AdapterLogEvent.CLICKED, MoPubCustomEventNative.ADAPTER_NAME);
notifyAdClicked();
this.mNativeClickHandler.openClickDestinationUrl(getClickDestinationUrl(), view);
}
}
public static class AnonymousClass1 {
static final int[] $SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter;
static {
int[] iArr = new int[MoPubStaticNativeAd.Parameter.values().length];
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter = iArr;
try {
iArr[MoPubStaticNativeAd.Parameter.MAIN_IMAGE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.ICON_IMAGE.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.IMPRESSION_TRACKER.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.CLICK_DESTINATION.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.CLICK_TRACKER.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.CALL_TO_ACTION.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.TITLE.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.TEXT.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.STAR_RATING.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.PRIVACY_INFORMATION_ICON_IMAGE_URL.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.PRIVACY_INFORMATION_ICON_CLICKTHROUGH_URL.ordinal()] = 11;
} catch (NoSuchFieldError unused11) {
}
try {
$SwitchMap$com$mopub$nativeads$MoPubCustomEventNative$MoPubStaticNativeAd$Parameter[MoPubStaticNativeAd.Parameter.SPONSORED.ordinal()] = 12;
} catch (NoSuchFieldError unused12) {
}
}
}
}