13Poker by gametower unlimited gems v0.4版本的 MD5 值为:51324fc0f195c34821074948ab266846
以下内容为反编译后的 MMLayout.java 源代码,内容仅作参考
package com.millennialmedia.android;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.webkit.WebView;
import android.widget.RelativeLayout;
import com.millennialmedia.android.BridgeMMMedia;
import com.millennialmedia.android.BridgeMMMicrophone;
import com.millennialmedia.android.InlineVideoView;
import com.millennialmedia.android.MMSDK;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
public abstract class MMLayout extends RelativeLayout implements MMAd, InlineVideoView.TransparentFix {
static final String BOTTOM_CENTER = "bottom-center";
static final String BOTTOM_LEFT = "bottom-left";
static final String BOTTOM_RIGHT = "bottom-right";
static final String CENTER = "center";
private static final int CLOSE_AREA_SIZE = 50;
public static final String KEY_HEIGHT = "height";
public static final String KEY_WIDTH = "width";
static final String TOP_CENTER = "top-center";
static final String TOP_LEFT = "top-left";
static final String TOP_RIGHT = "top-right";
private static boolean appInit;
MMAdImpl adImpl;
View blackView;
View closeAreaView;
private GestureDetector diagnosticDetector;
String goalId;
RelativeLayout inlineVideoLayout;
InlineVideoView inlineVideoView;
boolean isResizing;
public MMLayout(Context context) {
super(context);
initLayout(context);
}
@Deprecated
public MMLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initLayout(context);
}
protected void finalize() throws Throwable {
if (getId() == -1) {
this.adImpl.isFinishing = true;
MMSDK.Log.d("finalize() for " + this.adImpl);
MMAdImplController.removeAdViewController(this.adImpl);
}
}
protected final void initLayout(Context context) {
try {
MMSDK.Log.i("Initializing MMLayout.");
MMSDK.checkPermissions(context);
MMSDK.checkActivity(context);
} catch (Exception e) {
MMSDK.Log.e("There was an exception initializing the MMAdView. %s", e.getMessage());
e.printStackTrace();
}
this.diagnosticDetector = new GestureDetector(context.getApplicationContext(), new LayoutGestureListener(this));
if (!appInit) {
MMSDK.Log.d("********** Millennial Device Id *****************");
MMSDK.Log.d(MMSDK.getMMdid(context));
MMSDK.Log.d("Use the above identifier to register this device and receive test ads. Test devices can be registered and administered through your account at http://mmedia.com.");
MMSDK.Log.d("*************************************************");
AdCache.cleanCache(context);
appInit = true;
}
}
public static class LayoutGestureListener extends GestureDetector.SimpleOnGestureListener {
WeakReference<MMLayout> layoutRef;
public LayoutGestureListener(MMLayout layout) {
this.layoutRef = new WeakReference<>(layout);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (e1 == null || e2 == null) {
return false;
}
int dx = (int) (e2.getX() - e1.getX());
if (Math.abs(dx) <= 200 || Math.abs(velocityX) <= Math.abs(velocityY)) {
return false;
}
if (velocityX > 0.0f) {
if (MMSDK.logLevel == 0) {
MMSDK.Log.i("Enabling debug and verbose logging.");
MMSDK.logLevel = 3;
} else {
MMSDK.Log.i("Disabling debug and verbose logging.");
MMSDK.logLevel = 0;
}
} else {
MMLayout layout = this.layoutRef.get();
if (layout != null) {
MMSDK.printDiagnostics(layout.adImpl);
}
}
return true;
}
}
void setMediaPlaybackRequiresUserGesture(boolean requiresGesture) {
try {
Method method = WebView.class.getMethod("setMediaPlaybackRequiresUserGesture", Boolean.TYPE);
method.invoke(this, Boolean.valueOf(requiresGesture));
} catch (Exception e) {
}
}
@Override
@Deprecated
public void onWindowFocusChanged(boolean windowInFocus) {
Activity activity;
super.onWindowFocusChanged(windowInFocus);
if (windowInFocus) {
if (this.inlineVideoView != null) {
this.inlineVideoView.resumeVideo();
}
} else if (this.inlineVideoView != null) {
this.inlineVideoView.pauseVideo();
}
MMSDK.Log.d("Window Focus Changed. For %s, Window in focus?: %b Controllers: %s", this.adImpl, Boolean.valueOf(windowInFocus), MMAdImplController.controllersToString());
if (this.adImpl != null && this.adImpl.controller != null && this.adImpl.controller.webView != null) {
if (windowInFocus) {
this.adImpl.controller.webView.onResumeWebView();
this.adImpl.controller.webView.setMraidViewableVisible();
} else {
BridgeMMSpeechkit.releaseSpeechKit();
this.adImpl.controller.webView.setMraidViewableHidden();
this.adImpl.controller.webView.onPauseWebView();
}
}
if (!windowInFocus && (getContext() instanceof Activity) && ((activity = (Activity) getContext()) == null || (activity.isFinishing() && this.adImpl != null))) {
this.adImpl.isFinishing = true;
MMSDK.Log.d("Window Focus Changed.removing " + this.adImpl);
if (this.adImpl.controller != null && this.adImpl.controller.webView != null) {
this.adImpl.controller.webView.setMraidHidden();
}
MMAdImplController.removeAdViewController(this.adImpl);
}
BridgeMMMedia.Audio audio = BridgeMMMedia.Audio.sharedAudio(getContext());
if (audio != null) {
synchronized (this) {
audio.stop();
}
}
BridgeMMMicrophone.Recorder.getInstance().stopRecording();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return this.diagnosticDetector.onTouchEvent(event) || !isClickable() || super.onTouchEvent(event);
}
@Override
protected Parcelable onSaveInstanceState() {
super.onSaveInstanceState();
MMSDK.Log.d("onSaveInstanceState saving - " + this.adImpl + " id=" + getId());
Bundle bundle = new Bundle();
bundle.putParcelable("super", super.onSaveInstanceState());
bundle.putLong("MMAdImplId", this.adImpl.internalId);
bundle.putLong("MMAdImplLinkedId", this.adImpl.linkForExpansionId);
if (this.inlineVideoView != null) {
if (this.inlineVideoView.isPlaying()) {
this.inlineVideoView.inlineParams.currentPosition = this.inlineVideoView.getCurrentPosition();
}
bundle.putString("inlineVideoViewGson", this.inlineVideoView.getGsonState());
}
return bundle;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
MMSDK.Log.d("onDetachedFromWindow for" + this.adImpl);
if (!this.isResizing) {
MMAdImplController.removeAdViewController(this.adImpl);
}
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
Bundle bundle = (Bundle) state;
long tempId = this.adImpl.internalId;
this.adImpl.internalId = bundle.getLong("MMAdImplId");
this.adImpl.linkForExpansionId = bundle.getLong("MMAdImplLinkedId");
MMSDK.Log.d("onRestoreInstanceState replacing adImpl-" + tempId + " with " + this.adImpl + " id=" + getId());
String gsonInline = bundle.getString("inlineVideoViewGson");
if (gsonInline != null) {
initInlineVideo(InlineVideoView.InlineParams.getInlineParams(gsonInline));
}
super.onRestoreInstanceState(bundle.getParcelable("super"));
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (!isInEditMode()) {
MMSDK.Log.d("onAttachedToWindow for " + this.adImpl);
if (getId() == -1) {
MMSDK.Log.w("MMAd missing id from getId(). Performance will be affected for configuration changes.");
}
if (!this.isResizing) {
MMAdImplController.assignAdViewController(this.adImpl);
}
if (this.inlineVideoLayout != null) {
this.inlineVideoLayout.bringToFront();
}
if (this.adImpl != null && this.adImpl.controller != null && this.adImpl.controller.webView != null) {
this.adImpl.controller.webView.enableSendingSize();
}
}
}
public void removeCloseTouchDelegate() {
if (this.closeAreaView != null && this.closeAreaView.getParent() != null && (this.closeAreaView.getParent() instanceof ViewGroup)) {
((ViewGroup) this.closeAreaView.getParent()).removeView(this.closeAreaView);
this.closeAreaView = null;
}
}
public void setCloseArea(final String position) {
post(new Runnable() {
@Override
public void run() {
MMLayout.this.internalSetCloseArea(position);
}
});
}
public void internalSetCloseArea(String position) {
if (this.closeAreaView == null) {
this.closeAreaView = new View(getContext());
float density = getContext().getResources().getDisplayMetrics().density;
RelativeLayout.LayoutParams closeParams = new RelativeLayout.LayoutParams((int) (50.0f * density), (int) (50.0f * density));
if ("top-right".equals(position)) {
closeParams.addRule(11);
} else if ("top-center".equals(position)) {
closeParams.addRule(14);
} else if ("bottom-left".equals(position)) {
closeParams.addRule(12);
} else if ("bottom-center".equals(position)) {
closeParams.addRule(12);
closeParams.addRule(14);
} else if ("bottom-right".equals(position)) {
closeParams.addRule(12);
closeParams.addRule(11);
} else if ("center".equals(position)) {
closeParams.addRule(13);
}
this.closeAreaView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MMLayout.this.closeAreaTouched();
}
});
addView(this.closeAreaView, closeParams);
}
}
public void closeAreaTouched() {
}
public void loadUrl(String url) {
if (MMSDK.isConnected(getContext())) {
if (this.adImpl.controller != null) {
this.adImpl.controller.loadUrl(url);
return;
}
return;
}
MMSDK.Log.e("No network available, can't load overlay.");
}
public void loadWebContent(String content, String adUrl) {
if (MMSDK.isConnected(getContext())) {
if (this.adImpl.controller != null) {
this.adImpl.controller.loadWebContent(content, adUrl);
return;
}
return;
}
MMSDK.Log.e("No network available, can't load overlay.");
}
public class MMLayoutMMAdImpl extends MMAdImpl {
public MMLayoutMMAdImpl(Context context) {
super(context);
this.adProperties = new LayoutAdProperties(getContext());
}
@Override
public MMLayout getCallingAd() {
return MMLayout.this;
}
@Override
public void setClickable(boolean clickable) {
MMLayout.this.setClickable(clickable);
}
@Override
public void removeView(MMWebView mmWebView) {
MMLayout.this.removeView(mmWebView);
}
@Override
public void addView(MMWebView webView, RelativeLayout.LayoutParams webLayoutParams) {
MMSDK.Log.w("MMLayout adding view (" + webView + ") to " + this);
MMLayout.this.addView(webView, webLayoutParams);
}
@Override
public int getId() {
return MMLayout.this.getId();
}
}
class LayoutAdProperties extends AdProperties {
LayoutAdProperties(Context context) {
super(context);
}
@Override
String getAdDpiIndependentHeight() {
float density = MMSDK.getDensity(getContext());
int height = (int) (MMLayout.this.getHeight() / density);
return String.valueOf(height);
}
@Override
String getAdDpiIndependentWidth() {
float density = MMSDK.getDensity(getContext());
int width = (int) (MMLayout.this.getWidth() / density);
return String.valueOf(width);
}
}
public void setApid(String apid) {
this.adImpl.setApid(apid);
}
public String getApid() {
return this.adImpl.getApid();
}
public void setListener(RequestListener listener) {
this.adImpl.setListener(listener);
}
public RequestListener getListener() {
return this.adImpl.getListener();
}
public void setIgnoresDensityScaling(boolean ignoresDensityScaling) {
this.adImpl.setIgnoresDensityScaling(ignoresDensityScaling);
}
public boolean getIgnoresDensityScaling() {
return this.adImpl.getIgnoresDensityScaling();
}
public void setMMRequest(MMRequest request) {
this.adImpl.setMMRequest(request);
}
public MMRequest getMMRequest() {
return this.adImpl.getMMRequest();
}
public void repositionVideoLayout() {
}
public void fullScreenVideoLayout() {
}
public void removeVideo() {
if (this.inlineVideoView != null) {
this.inlineVideoView.removeVideo();
this.inlineVideoView = null;
}
}
public void playVideo() {
if (this.inlineVideoView != null) {
this.inlineVideoView.playVideo();
}
}
public boolean adjustVideo(final InlineVideoView.InlineParams params) {
MMSDK.runOnUiThread(new Runnable() {
@Override
public void run() {
if (MMLayout.this.inlineVideoView != null) {
MMLayout.this.inlineVideoView.adjustVideo(params);
}
}
});
return false;
}
public void stopVideo() {
if (this.inlineVideoView != null) {
this.inlineVideoView.stopVideo();
}
}
public void pauseVideo() {
if (this.inlineVideoView != null) {
this.inlineVideoView.pauseVideo();
}
}
public void resumeVideo() {
if (this.inlineVideoView != null) {
this.inlineVideoView.resumeVideo();
}
}
public void setVideoSource(String streamVideoURI) {
if (this.inlineVideoView != null) {
this.inlineVideoView.setVideoSource(streamVideoURI);
}
}
public void initInlineVideo(InlineVideoView.InlineParams params) {
if (this.inlineVideoView != null) {
ViewGroup vg = (ViewGroup) this.inlineVideoView.getParent();
if (vg != null) {
vg.removeView(this.inlineVideoView);
}
if (this.inlineVideoView.isPlaying()) {
this.inlineVideoView.stopPlayback();
}
this.inlineVideoView = null;
}
this.inlineVideoView = new InlineVideoView(this);
this.inlineVideoView.initInlineVideo(params);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(-2, -2);
lp.addRule(13, -1);
this.inlineVideoView.setLayoutParams(lp);
addInlineVideo();
}
public void addInlineVideo() {
if (this.inlineVideoLayout != null && this.inlineVideoLayout.getParent() != null) {
((ViewGroup) this.inlineVideoLayout.getParent()).removeView(this.inlineVideoLayout);
}
this.inlineVideoLayout = new RelativeLayout(getContext());
this.inlineVideoLayout.setId(892934232);
if (this.inlineVideoView.getParent() != null) {
((ViewGroup) this.inlineVideoView.getParent()).removeView(this.inlineVideoView);
}
this.inlineVideoLayout.addView(this.inlineVideoView);
if (this.blackView != null) {
if (this.blackView.getParent() == null) {
this.inlineVideoLayout.addView(this.blackView);
}
this.blackView.bringToFront();
}
addView(this.inlineVideoLayout, this.inlineVideoView.getCustomLayoutParams());
}
public void addBlackView() {
initInlineVideoTransparentFix();
if (this.blackView != null) {
this.blackView.setVisibility(0);
}
}
public void removeBlackView() {
if (this.blackView != null) {
this.blackView.setVisibility(4);
}
}
private void initInlineVideoTransparentFix() {
ViewParent parent;
if (this.blackView != null && (parent = this.blackView.getParent()) != null && (parent instanceof ViewGroup)) {
((ViewGroup) parent).removeView(this.blackView);
this.blackView = null;
}
this.blackView = new View(getContext());
this.blackView.setBackgroundColor(-16777216);
RelativeLayout.LayoutParams blackViewParams = new RelativeLayout.LayoutParams(-1, -1);
this.blackView.setLayoutParams(blackViewParams);
if (this.inlineVideoLayout != null && this.blackView.getParent() == null) {
this.inlineVideoLayout.addView(this.blackView);
}
}
public boolean isVideoPlayingStreaming() {
return this.inlineVideoView != null && this.inlineVideoView.isPlayingStreaming();
}
}