13Poker by gametower unlimited gems v0.4版本的 MD5 值为:51324fc0f195c34821074948ab266846
以下内容为反编译后的 AdView.java 源代码,内容仅作参考
package com.adsdk.sdk.mraid;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.location.Location;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import com.adfonic.android.view.task.UrlOpenerTask;
import com.adsdk.sdk.BannerAd;
import com.adsdk.sdk.Const;
import com.adsdk.sdk.banner.InAppWebView;
import com.adsdk.sdk.mraid.MoPubView;
import com.flurry.android.AdCreative;
import com.xbtsol.jynvrt161024.IVastConstant;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TimeZone;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
public class AdView extends WebView {
public static final String AD_ORIENTATION_BOTH = "b";
public static final String AD_ORIENTATION_LANDSCAPE_ONLY = "l";
public static final String AD_ORIENTATION_PORTRAIT_ONLY = "p";
public static final String DEVICE_ORIENTATION_LANDSCAPE = "l";
public static final String DEVICE_ORIENTATION_PORTRAIT = "p";
public static final String DEVICE_ORIENTATION_SQUARE = "s";
public static final String DEVICE_ORIENTATION_UNKNOWN = "u";
public static final String EXTRA_AD_CLICK_DATA = "com.mopub.intent.extra.AD_CLICK_DATA";
private static final int MINIMUM_REFRESH_TIME_MILLISECONDS = 10000;
private static final FrameLayout.LayoutParams WRAP_AND_CENTER_LAYOUT_PARAMS = new FrameLayout.LayoutParams(-2, -2, 17);
private String mAdOrientation;
private String mAdUnitId;
private boolean mAutorefreshEnabled;
private String mClickthroughUrl;
private String mFailUrl;
private final Handler mHandler;
private int mHeight;
private String mImpressionUrl;
private boolean mIsDestroyed;
private boolean mIsLoading;
private String mKeywords;
private Location mLocation;
protected MoPubView mMoPubView;
private String mRedirectUrl;
private Handler mRefreshHandler;
private Runnable mRefreshRunnable;
private int mRefreshTimeMilliseconds;
private BannerAd mResponse;
private String mResponseString;
private String mUrl;
private String mUserAgent;
private int mWidth;
public AdView(Context context, MoPubView view, BannerAd response) {
super(context.getApplicationContext());
this.mRefreshTimeMilliseconds = 60000;
this.mHandler = new Handler();
this.mRefreshHandler = new Handler();
this.mRefreshRunnable = new Runnable() {
@Override
public void run() {
AdView.this.loadAd();
}
};
this.mResponse = response;
this.mMoPubView = view;
this.mAutorefreshEnabled = true;
this.mUserAgent = getSettings().getUserAgentString();
disableScrollingAndZoom();
getSettings().setJavaScriptEnabled(true);
getSettings().setPluginsEnabled(true);
setBackgroundColor(0);
setWebViewClient(new AdWebViewClient(this, null));
addMoPubUriJavascriptInterface();
}
private void disableScrollingAndZoom() {
setHorizontalScrollBarEnabled(false);
setHorizontalScrollbarOverlay(false);
setVerticalScrollBarEnabled(false);
setVerticalScrollbarOverlay(false);
getSettings().setSupportZoom(false);
}
private void addMoPubUriJavascriptInterface() {
addJavascriptInterface(new Object() {
public boolean fireFinishLoad() {
AdView.this.postHandlerRunnable(new Runnable() {
@Override
public void run() {
AdView.this.adDidLoad();
}
});
return true;
}
}, "mopubUriInterface");
}
public void postHandlerRunnable(Runnable r) {
this.mHandler.post(r);
}
private class AdWebViewClient extends WebViewClient {
private AdWebViewClient() {
}
AdWebViewClient(AdView adView, AdWebViewClient adWebViewClient) {
this();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
AdView adView = (AdView) view;
if (url.startsWith("mopub://")) {
Uri uri = Uri.parse(url);
String host = uri.getHost();
if (!host.equals("finishLoad")) {
if (!host.equals(IVastConstant.EVENT_CLOSE)) {
if (host.equals("failLoad")) {
adView.loadFailUrl();
} else if (host.equals(AdCreative.kFormatCustom)) {
adView.handleCustomIntentFromUri(uri);
}
} else {
adView.adDidClose();
}
} else {
adView.adDidLoad();
}
} else if (url.startsWith("tel:") || url.startsWith("voicemail:") || url.startsWith("sms:") || url.startsWith("mailto:") || url.startsWith("geo:") || url.startsWith("google.streetview:")) {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
intent.addFlags(268435456);
try {
AdView.this.getContext().startActivity(intent);
AdView.this.registerClick();
} catch (ActivityNotFoundException e) {
Log.w("MoPub", "Could not handle intent with URI: " + url + ". Is this intent unsupported on your phone?");
}
} else {
if (url.startsWith(UrlOpenerTask.MARKET_SEARCH)) {
Intent intent2 = new Intent("android.intent.action.VIEW", Uri.parse(url));
PackageManager packageManager = AdView.this.getContext().getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent2, 0);
boolean isIntentSafe = activities.size() > 0;
if (!isIntentSafe) {
Log.w("MoPub", "Could not handle market action: " + url + ". Perhaps you're running in the emulator, which does not have the Android Market?");
}
}
String url2 = urlWithClickTrackingRedirect(adView, url);
Log.d("MoPub", "Ad clicked. Click URL: " + url2);
AdView.this.mMoPubView.adClicked();
AdView.this.showBrowserForUrl(url2);
}
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
AdView adView = (AdView) view;
String redirectUrl = adView.getRedirectUrl();
if (redirectUrl != null && url.startsWith(redirectUrl)) {
String url2 = urlWithClickTrackingRedirect(adView, url);
view.stopLoading();
AdView.this.showBrowserForUrl(url2);
}
}
private String urlWithClickTrackingRedirect(AdView adView, String url) {
String clickthroughUrl = adView.getClickthroughUrl();
if (clickthroughUrl != null) {
String encodedUrl = Uri.encode(url);
return String.valueOf(clickthroughUrl) + "&r=" + encodedUrl;
}
return url;
}
}
public void loadAd() {
HashMap<String, String> paramsHash = new HashMap<>();
paramsHash.put("X-Adtype", "mraid");
paramsHash.put("X-Nativeparams", this.mResponse.getText());
MoPubView mpv = this.mMoPubView;
mpv.loadNativeSDK(paramsHash);
}
private boolean isNetworkAvailable() {
Context context = getContext();
int result = context.checkCallingPermission("android.permission.ACCESS_NETWORK_STATE");
if (result == -1) {
return true;
}
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService("connectivity");
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
return networkInfo != null && networkInfo.isConnected();
}
private Location getLastKnownLocation() {
Location result;
MoPubView.LocationAwareness locationAwareness = this.mMoPubView.getLocationAwareness();
int locationPrecision = this.mMoPubView.getLocationPrecision();
if (locationAwareness == MoPubView.LocationAwareness.LOCATION_AWARENESS_DISABLED) {
return null;
}
LocationManager lm = (LocationManager) getContext().getSystemService("location");
Location gpsLocation = null;
try {
gpsLocation = lm.getLastKnownLocation("gps");
} catch (IllegalArgumentException e) {
Log.d("MoPub", "Failed to retrieve GPS location: device has no GPS provider.");
} catch (SecurityException e2) {
Log.d("MoPub", "Failed to retrieve GPS location: access appears to be disabled.");
}
Location networkLocation = null;
try {
networkLocation = lm.getLastKnownLocation("network");
} catch (IllegalArgumentException e3) {
Log.d("MoPub", "Failed to retrieve network location: device has no network provider.");
} catch (SecurityException e4) {
Log.d("MoPub", "Failed to retrieve network location: access appears to be disabled.");
}
if (gpsLocation == null && networkLocation == null) {
return null;
}
if (gpsLocation != null && networkLocation != null) {
result = gpsLocation.getTime() > networkLocation.getTime() ? gpsLocation : networkLocation;
} else {
result = gpsLocation != null ? gpsLocation : networkLocation;
}
if (locationAwareness == MoPubView.LocationAwareness.LOCATION_AWARENESS_TRUNCATED) {
double lat = result.getLatitude();
double truncatedLat = BigDecimal.valueOf(lat).setScale(locationPrecision, 5).doubleValue();
result.setLatitude(truncatedLat);
double lon = result.getLongitude();
double truncatedLon = BigDecimal.valueOf(lon).setScale(locationPrecision, 5).doubleValue();
result.setLongitude(truncatedLon);
}
return result;
}
private String getTimeZoneOffsetString() {
SimpleDateFormat format = new SimpleDateFormat("Z");
format.setTimeZone(TimeZone.getDefault());
return format.format(new Date());
}
protected void configureAdViewUsingHeadersFromHttpResponse(HttpResponse response) {
Header ntHeader = response.getFirstHeader("X-Networktype");
if (ntHeader != null) {
Log.i("MoPub", "Fetching ad network type: " + ntHeader.getValue());
}
Header rdHeader = response.getFirstHeader("X-Launchpage");
if (rdHeader != null) {
this.mRedirectUrl = rdHeader.getValue();
} else {
this.mRedirectUrl = null;
}
Header ctHeader = response.getFirstHeader("X-Clickthrough");
if (ctHeader != null) {
this.mClickthroughUrl = ctHeader.getValue();
} else {
this.mClickthroughUrl = null;
}
Header flHeader = response.getFirstHeader("X-Failurl");
if (flHeader != null) {
this.mFailUrl = flHeader.getValue();
} else {
this.mFailUrl = null;
}
Header imHeader = response.getFirstHeader("X-Imptracker");
if (imHeader != null) {
this.mImpressionUrl = imHeader.getValue();
} else {
this.mImpressionUrl = null;
}
Header scHeader = response.getFirstHeader("X-Scrollable");
boolean enabled = scHeader != null ? scHeader.getValue().equals("1") : false;
setWebViewScrollingEnabled(enabled);
Header wHeader = response.getFirstHeader("X-Width");
Header hHeader = response.getFirstHeader("X-Height");
if (wHeader != null && hHeader != null) {
this.mWidth = Integer.parseInt(wHeader.getValue().trim());
this.mHeight = Integer.parseInt(hHeader.getValue().trim());
} else {
this.mWidth = 0;
this.mHeight = 0;
}
Header rtHeader = response.getFirstHeader("X-Refreshtime");
if (rtHeader != null) {
this.mRefreshTimeMilliseconds = Integer.valueOf(rtHeader.getValue()).intValue() * 1000;
if (this.mRefreshTimeMilliseconds < 10000) {
this.mRefreshTimeMilliseconds = 10000;
}
} else {
this.mRefreshTimeMilliseconds = 0;
}
Header orHeader = response.getFirstHeader("X-Orientation");
this.mAdOrientation = orHeader != null ? orHeader.getValue() : null;
}
private void setWebViewScrollingEnabled(boolean enabled) {
if (enabled) {
setOnTouchListener(null);
} else {
setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return event.getAction() == 2;
}
});
}
}
public void adDidLoad() {
Log.i("MoPub", "Ad successfully loaded.");
this.mIsLoading = false;
scheduleRefreshTimerIfEnabled();
setAdContentView(this, getHtmlAdLayoutParams());
this.mMoPubView.adLoaded();
}
public void setAdContentView(View view) {
setAdContentView(view, WRAP_AND_CENTER_LAYOUT_PARAMS);
}
private void setAdContentView(View view, FrameLayout.LayoutParams layoutParams) {
this.mMoPubView.removeAllViews();
this.mMoPubView.addView(view, layoutParams);
}
private void adDidFail() {
Log.i("MoPub", "Ad failed to load.");
this.mIsLoading = false;
scheduleRefreshTimerIfEnabled();
this.mMoPubView.adFailed();
}
public void adDidClose() {
this.mMoPubView.adClosed();
}
public void handleCustomIntentFromUri(Uri uri) {
registerClick();
String action = uri.getQueryParameter("fnc");
String adData = uri.getQueryParameter("data");
Intent customIntent = new Intent(action);
customIntent.addFlags(268435456);
if (adData != null) {
customIntent.putExtra(EXTRA_AD_CLICK_DATA, adData);
}
try {
getContext().startActivity(customIntent);
} catch (ActivityNotFoundException e) {
Log.w("MoPub", "Could not handle custom intent: " + action + ". Is your intent spelled correctly?");
}
}
public void showBrowserForUrl(String url) {
if (!isDestroyed()) {
url = (url == null || url.equals("")) ? "about:blank" : "about:blank";
Log.d("MoPub", "Final URI to show in browser: " + url);
Context context = getContext();
if (url.endsWith(".mp4")) {
Intent i = new Intent("android.intent.action.VIEW");
i.setDataAndType(Uri.parse(url), "video/mp4");
context.startActivity(i);
return;
}
Intent intent = new Intent(context, InAppWebView.class);
intent.putExtra(Const.REDIRECT_URI, url);
intent.addFlags(268435456);
try {
context.startActivity(intent);
} catch (ActivityNotFoundException e) {
String action = intent.getAction();
Log.w("MoPub", "Could not handle intent action: " + action + ". Perhaps you forgot to declare com.adsdk.sdk.mraid.MraidBrowser in your Android manifest file.");
getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse("about:blank")).addFlags(268435456));
}
}
}
public void customEventDidLoadAd() {
this.mIsLoading = false;
scheduleRefreshTimerIfEnabled();
}
public void customEventDidFailToLoadAd() {
loadFailUrl();
}
public void customEventActionWillBegin() {
registerClick();
}
protected boolean isDestroyed() {
return this.mIsDestroyed;
}
public void cleanup() {
if (!this.mIsDestroyed) {
setAutorefreshEnabled(false);
cancelRefreshTimer();
destroy();
this.mResponseString = null;
this.mMoPubView.removeView(this);
this.mMoPubView = null;
this.mIsDestroyed = true;
}
}
@Override
public void reload() {
Log.d("MoPub", "Reload ad: " + this.mUrl);
loadUrl(this.mUrl);
}
public void loadFailUrl() {
this.mIsLoading = false;
if (this.mFailUrl != null) {
Log.d("MoPub", "Loading failover url: " + this.mFailUrl);
loadUrl(this.mFailUrl);
return;
}
adDidFail();
}
public void registerClick() {
if (this.mClickthroughUrl != null) {
new Thread(new Runnable() {
@Override
public void run() {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(AdView.this.mClickthroughUrl);
httpget.addHeader("User-Agent", AdView.this.mUserAgent);
try {
try {
httpclient.execute(httpget);
httpclient.getConnectionManager().shutdown();
} catch (IOException e) {
Log.i("MoPub", "Click tracking failed: " + AdView.this.mClickthroughUrl);
httpclient.getConnectionManager().shutdown();
} catch (ClientProtocolException e2) {
Log.i("MoPub", "Click tracking failed: " + AdView.this.mClickthroughUrl);
httpclient.getConnectionManager().shutdown();
}
} catch (Throwable th) {
httpclient.getConnectionManager().shutdown();
throw th;
}
}
}).start();
}
}
public void adAppeared() {
loadUrl("javascript:webviewDidAppear();");
}
public void scheduleRefreshTimerIfEnabled() {
cancelRefreshTimer();
if (this.mAutorefreshEnabled && this.mRefreshTimeMilliseconds > 0) {
this.mRefreshHandler.postDelayed(this.mRefreshRunnable, this.mRefreshTimeMilliseconds);
}
}
protected void cancelRefreshTimer() {
this.mRefreshHandler.removeCallbacks(this.mRefreshRunnable);
}
protected int getRefreshTimeMilliseconds() {
return this.mRefreshTimeMilliseconds;
}
protected void setRefreshTimeMilliseconds(int refreshTimeMilliseconds) {
this.mRefreshTimeMilliseconds = refreshTimeMilliseconds;
}
private String addKeyword(String keywords, String addition) {
return (addition == null || addition.length() == 0) ? keywords : (keywords == null || keywords.length() == 0) ? addition : String.valueOf(keywords) + "," + addition;
}
public String getKeywords() {
return this.mKeywords;
}
public void setKeywords(String keywords) {
this.mKeywords = keywords;
}
public Location getLocation() {
return this.mLocation;
}
public void setLocation(Location location) {
this.mLocation = location;
}
public String getAdUnitId() {
return this.mAdUnitId;
}
public void setAdUnitId(String adUnitId) {
this.mAdUnitId = adUnitId;
}
public int getAdWidth() {
return this.mWidth;
}
public int getAdHeight() {
return this.mHeight;
}
public String getAdOrientation() {
return this.mAdOrientation;
}
public String getClickthroughUrl() {
return this.mClickthroughUrl;
}
public void setClickthroughUrl(String url) {
this.mClickthroughUrl = url;
}
public String getRedirectUrl() {
return this.mRedirectUrl;
}
public String getResponseString() {
return this.mResponseString;
}
protected void setResponseString(String responseString) {
this.mResponseString = responseString;
}
protected void setIsLoading(boolean isLoading) {
this.mIsLoading = isLoading;
}
public void setAutorefreshEnabled(boolean enabled) {
this.mAutorefreshEnabled = enabled;
Log.d("MoPub", "Automatic refresh for " + this.mAdUnitId + " set to: " + enabled + ".");
if (this.mAutorefreshEnabled) {
scheduleRefreshTimerIfEnabled();
} else {
cancelRefreshTimer();
}
}
public boolean getAutorefreshEnabled() {
return this.mAutorefreshEnabled;
}
public void forceRefresh() {
this.mIsLoading = false;
loadAd();
}
private FrameLayout.LayoutParams getHtmlAdLayoutParams() {
if (this.mWidth <= 0 || this.mHeight <= 0) {
return WRAP_AND_CENTER_LAYOUT_PARAMS;
}
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
int scaledWidth = (int) TypedValue.applyDimension(1, this.mWidth, displayMetrics);
int scaledHeight = (int) TypedValue.applyDimension(1, this.mHeight, displayMetrics);
return new FrameLayout.LayoutParams(scaledWidth, scaledHeight, 17);
}
}