Idle Tower v2.48版本的 MD5 值为:56f20496f6a85726b376356ed2ecee23
以下内容为反编译后的 f.java 源代码,内容仅作参考
package com.applovin.impl.adview.activity.b;
import android.R;
import android.app.Activity;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.StrictMode;
import android.os.SystemClock;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import com.applovin.communicator.AppLovinCommunicator;
import com.applovin.communicator.AppLovinCommunicatorMessage;
import com.applovin.communicator.AppLovinCommunicatorSubscriber;
import com.applovin.impl.adview.AppLovinTouchToClickListener;
import com.applovin.impl.adview.AppLovinVideoView;
import com.applovin.impl.adview.h;
import com.applovin.impl.adview.k;
import com.applovin.impl.adview.n;
import com.applovin.impl.adview.u;
import com.applovin.impl.adview.w;
import com.applovin.impl.adview.x;
import com.applovin.impl.sdk.e.ac;
import com.applovin.impl.sdk.e.r;
import com.applovin.impl.sdk.o;
import com.applovin.impl.sdk.utils.AppLovinSdkExtraParameterKey;
import com.applovin.impl.sdk.utils.StringUtils;
import com.applovin.impl.sdk.utils.Utils;
import com.applovin.impl.sdk.utils.t;
import com.applovin.impl.sdk.utils.v;
import com.applovin.sdk.AppLovinAdClickListener;
import com.applovin.sdk.AppLovinAdDisplayListener;
import com.applovin.sdk.AppLovinAdVideoPlaybackListener;
import com.applovin.sdk.AppLovinSdkUtils;
import com.iab.omid.library.applovin.adsession.FriendlyObstructionPurpose;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
public class f extends com.applovin.impl.adview.activity.b.a implements AppLovinCommunicatorSubscriber {
protected h A;
protected final ImageView B;
protected w C;
protected final ProgressBar D;
protected ImageView E;
protected final k F;
protected boolean G;
protected long H;
protected boolean I;
private final com.applovin.impl.adview.activity.a.c J;
private MediaPlayer K;
private final b L;
private final a M;
private final Handler N;
private final boolean O;
private int P;
private int Q;
private boolean R;
private final AtomicBoolean S;
private final AtomicBoolean T;
private long U;
private long V;
protected final AppLovinVideoView x;
protected final com.applovin.impl.adview.a y;
protected final n z;
@Override
public String getCommunicatorId() {
return "FullscreenVideoAdPresenter";
}
public f(com.applovin.impl.sdk.ad.e eVar, Activity activity, Map<String, Object> map, o oVar, AppLovinAdClickListener appLovinAdClickListener, AppLovinAdDisplayListener appLovinAdDisplayListener, AppLovinAdVideoPlaybackListener appLovinAdVideoPlaybackListener) {
super(eVar, activity, map, oVar, appLovinAdClickListener, appLovinAdDisplayListener, appLovinAdVideoPlaybackListener);
this.J = new com.applovin.impl.adview.activity.a.c(this.f913a, this.e, this.b);
this.E = null;
this.L = new b();
this.M = new a();
Handler handler = new Handler(Looper.getMainLooper());
this.N = handler;
this.F = new k(handler, this.b);
this.O = this.f913a.f();
this.G = Utils.isVideoMutedInitially(this.b);
this.Q = -1;
this.S = new AtomicBoolean();
this.T = new AtomicBoolean();
this.U = -2L;
this.V = 0L;
if (!eVar.hasVideoUrl()) {
throw new IllegalStateException("Attempting to use fullscreen video ad presenter for non-video ad");
}
AppLovinVideoView appLovinVideoView = new AppLovinVideoView(activity);
this.x = appLovinVideoView;
appLovinVideoView.setOnPreparedListener(this.L);
this.x.setOnCompletionListener(this.L);
this.x.setOnErrorListener(this.L);
this.x.setOnTouchListener(new AppLovinTouchToClickListener(oVar, com.applovin.impl.sdk.c.b.aX, activity, this.L));
c cVar = new c();
if (eVar.r() >= 0) {
n nVar = new n(eVar.x(), activity);
this.z = nVar;
nVar.setVisibility(8);
this.z.setOnClickListener(cVar);
} else {
this.z = null;
}
if (a(this.G, oVar)) {
ImageView imageView = new ImageView(activity);
this.B = imageView;
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
this.B.setClickable(true);
this.B.setOnClickListener(cVar);
e(this.G);
} else {
this.B = null;
}
String C = eVar.C();
if (StringUtils.isValidString(C)) {
x xVar = new x(oVar);
xVar.a(new WeakReference<>(this.M));
w wVar = new w(xVar, activity);
this.C = wVar;
wVar.a(C);
} else {
this.C = null;
}
if (this.O) {
com.applovin.impl.adview.a aVar = new com.applovin.impl.adview.a(activity, ((Integer) oVar.a(com.applovin.impl.sdk.c.b.cU)).intValue(), R.attr.progressBarStyleLarge);
this.y = aVar;
aVar.setColor(Color.parseColor("#75FFFFFF"));
this.y.setBackgroundColor(Color.parseColor("#00000000"));
this.y.setVisibility(8);
AppLovinCommunicator.getInstance(activity).subscribe(this, "video_caching_failed");
} else {
this.y = null;
}
final int m = m();
boolean z = ((Boolean) oVar.a(com.applovin.impl.sdk.c.b.cE)).booleanValue() && m > 0;
if (this.A == null && z) {
this.A = new h(activity);
int I = eVar.I();
this.A.setTextColor(I);
this.A.setTextSize(((Integer) oVar.a(com.applovin.impl.sdk.c.b.cD)).intValue());
this.A.setFinishedStrokeColor(I);
this.A.setFinishedStrokeWidth(((Integer) oVar.a(com.applovin.impl.sdk.c.b.cC)).intValue());
this.A.setMax(m);
this.A.setProgress(m);
this.F.a("COUNTDOWN_CLOCK", TimeUnit.SECONDS.toMillis(1L), new k.a() {
@Override
public void a() {
if (f.this.A != null) {
long seconds = m - TimeUnit.MILLISECONDS.toSeconds(f.this.x.getCurrentPosition());
if (seconds <= 0) {
f.this.n = true;
} else if (f.this.C()) {
f.this.A.setProgress((int) seconds);
}
}
}
@Override
public boolean b() {
return f.this.C();
}
});
}
if (eVar.R()) {
ProgressBar progressBar = new ProgressBar(activity, null, R.attr.progressBarStyleHorizontal);
this.D = progressBar;
progressBar.setMax(10000);
this.D.setPadding(0, 0, 0, 0);
if (com.applovin.impl.sdk.utils.h.d()) {
this.D.setProgressTintList(ColorStateList.valueOf(eVar.S()));
}
this.F.a("PROGRESS_BAR", ((Long) oVar.a(com.applovin.impl.sdk.c.b.cR)).longValue(), new k.a() {
@Override
public void a() {
if (f.this.I) {
f.this.D.setVisibility(8);
} else {
f.this.D.setProgress((int) ((f.this.x.getCurrentPosition() / ((float) f.this.H)) * 10000.0f));
}
}
@Override
public boolean b() {
return !f.this.I;
}
});
return;
}
this.D = null;
}
@Override
public void d() {
a((ViewGroup) null);
}
@Override
public void a(ViewGroup viewGroup) {
String str;
this.J.a(this.B, this.z, this.C, this.y, this.D, this.A, this.x, this.f, this.g, this.E, viewGroup);
if (com.applovin.impl.sdk.utils.h.g() && (str = this.b.D().getExtraParameters().get(AppLovinSdkExtraParameterKey.AUDIO_FOCUS_REQUEST)) != null) {
this.x.setAudioFocusRequest(Integer.parseInt(str));
}
StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
a(!this.O);
this.x.setVideoURI(this.f913a.h());
StrictMode.setThreadPolicy(allowThreadDiskReads);
if (this.f913a.ap()) {
this.v.a(this.f913a, new Runnable() {
@Override
public void run() {
f.this.a(250L);
}
});
}
if (this.g != null) {
this.g.a();
}
this.x.start();
if (this.O) {
y();
}
this.f.renderAd(this.f913a);
this.d.b(this.O ? 1L : 0L);
if (this.z != null) {
this.b.N().a(new ac(this.b, new Runnable() {
@Override
public void run() {
f.this.E();
}
}), r.b.MAIN, this.f913a.s(), true);
}
super.b(this.G);
}
public void c(long j) {
this.H = j;
}
public void E() {
if (this.T.compareAndSet(false, true)) {
a(this.z, this.f913a.r(), new Runnable() {
@Override
public void run() {
f.this.U = -1L;
f.this.V = SystemClock.elapsedRealtime();
}
});
}
}
@Override
public void c(boolean z) {
super.c(z);
if (z) {
a(0L);
} else {
if (this.I) {
return;
}
e();
}
}
@Override
public void h() {
this.F.b();
this.N.removeCallbacksAndMessages(null);
n();
super.h();
}
@Override
public void k() {
com.applovin.impl.sdk.x xVar = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.c("AppLovinFullscreenActivity", "Destroying video components");
}
try {
if (((Boolean) this.b.a(com.applovin.impl.sdk.c.b.gu)).booleanValue()) {
com.applovin.impl.sdk.utils.w.a(this.C);
this.C = null;
}
if (this.O) {
AppLovinCommunicator.getInstance(this.e).unsubscribe(this, "video_caching_failed");
}
if (this.x != null) {
this.x.pause();
this.x.stopPlayback();
}
if (this.K != null) {
this.K.release();
}
} catch (Throwable th) {
Log.e("AppLovinFullscreenActivity", "Unable to destroy presenter", th);
}
super.k();
}
public void a(PointF pointF, boolean z) {
if (this.f913a.E()) {
com.applovin.impl.sdk.x xVar = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.b("AppLovinFullscreenActivity", "Clicking through video");
}
Uri k = this.f913a.k();
if (k != null) {
this.b.F().trackAndLaunchVideoClick(this.f913a, k, pointF, z, this, this.f != null ? this.f.getContext() : o.z());
com.applovin.impl.sdk.utils.n.a(this.s, this.f913a);
this.d.b();
this.p++;
return;
}
return;
}
F();
}
private void F() {
w wVar;
u D = this.f913a.D();
if (D == null || !D.e() || this.I || (wVar = this.C) == null) {
return;
}
final boolean z = wVar.getVisibility() == 4;
final long f = D.f();
AppLovinSdkUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
if (z) {
v.a(f.this.C, f, (Runnable) null);
} else {
v.b(f.this.C, f, null);
}
}
});
}
protected boolean C() {
return (this.n || this.I || !this.x.isPlaying()) ? false : true;
}
public void c() {
this.U = SystemClock.elapsedRealtime() - this.V;
com.applovin.impl.sdk.x xVar = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.b("AppLovinFullscreenActivity", "Skipping video with skip time: " + this.U + "ms");
}
this.d.f();
this.o++;
if (this.f913a.y()) {
h();
} else {
B();
}
}
@Override
public void e() {
com.applovin.impl.sdk.x xVar = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.b("AppLovinFullscreenActivity", "Pausing video");
}
this.Q = this.x.getCurrentPosition();
this.x.pause();
this.F.c();
com.applovin.impl.sdk.x xVar2 = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.b("AppLovinFullscreenActivity", "Paused video at position " + this.Q + "ms");
}
}
private void d(boolean z) {
this.P = D();
if (z) {
this.x.pause();
} else {
this.x.stopPlayback();
}
}
@Override
public void a(long j) {
a(new Runnable() {
@Override
public void run() {
f.this.G();
}
}, j);
}
public void G() {
if (this.I) {
com.applovin.impl.sdk.x xVar = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.d("AppLovinFullscreenActivity", "Skip video resume - postitial shown");
return;
}
return;
}
if (this.b.Z().isApplicationPaused()) {
com.applovin.impl.sdk.x xVar2 = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.d("AppLovinFullscreenActivity", "Skip video resume - app paused");
return;
}
return;
}
if (this.Q >= 0) {
com.applovin.impl.sdk.x xVar3 = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.b("AppLovinFullscreenActivity", "Resuming video at position " + this.Q + "ms for MediaPlayer: " + this.K);
}
this.x.seekTo(this.Q);
this.x.start();
this.F.a();
this.Q = -1;
a(new Runnable() {
@Override
public void run() {
if (f.this.y != null) {
f.this.y.a();
f.this.a(new Runnable() {
@Override
public void run() {
f.this.y.b();
}
}, 2000L);
}
}
}, 250L);
return;
}
com.applovin.impl.sdk.x xVar4 = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.b("AppLovinFullscreenActivity", "Invalid last video position");
}
}
public void y() {
AppLovinSdkUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
if (f.this.y != null) {
f.this.y.a();
}
}
});
}
public void z() {
AppLovinSdkUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
if (f.this.y != null) {
f.this.y.b();
}
}
});
}
public void c(String str) {
com.applovin.impl.sdk.x xVar = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.e("AppLovinFullscreenActivity", "Encountered media error: " + str + " for ad: " + this.f913a);
}
if (this.S.compareAndSet(false, true)) {
if (this.t instanceof com.applovin.impl.sdk.ad.h) {
((com.applovin.impl.sdk.ad.h) this.t).onAdDisplayFailed(str);
}
h();
}
}
@Override
public boolean s() {
return D() >= this.f913a.T();
}
public int D() {
long currentPosition = this.x.getCurrentPosition();
if (this.R) {
return 100;
}
if (currentPosition > 0) {
return (int) ((((float) currentPosition) / ((float) this.H)) * 100.0f);
}
return this.P;
}
@Override
protected boolean t() {
return u() && !s();
}
public void B() {
com.applovin.impl.sdk.x xVar = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.b("AppLovinFullscreenActivity", "Showing postitial...");
}
d(this.f913a.aO());
this.J.a(this.h, this.g, this.f);
a("javascript:al_onPoststitialShow(" + this.o + "," + this.p + ");", this.f913a.V());
if (this.h != null) {
if (this.f913a.t() >= 0) {
a(this.h, this.f913a.t(), new Runnable() {
@Override
public void run() {
f.this.k = SystemClock.elapsedRealtime();
}
});
} else {
this.h.setVisibility(0);
}
}
ArrayList arrayList = new ArrayList();
if (this.h != null) {
arrayList.add(new com.applovin.impl.sdk.a.d(this.h, FriendlyObstructionPurpose.CLOSE_AD, "close button"));
}
if (this.g != null && this.g.b()) {
arrayList.add(new com.applovin.impl.sdk.a.d(this.g, FriendlyObstructionPurpose.NOT_VISIBLE, this.g.getIdentifier()));
}
this.f913a.o().a(this.f, arrayList);
w();
this.I = true;
}
private static boolean a(boolean z, o oVar) {
if (!((Boolean) oVar.a(com.applovin.impl.sdk.c.b.cJ)).booleanValue()) {
return false;
}
if (!((Boolean) oVar.a(com.applovin.impl.sdk.c.b.cK)).booleanValue() || z) {
return true;
}
return ((Boolean) oVar.a(com.applovin.impl.sdk.c.b.cM)).booleanValue();
}
private void e(boolean z) {
if (com.applovin.impl.sdk.utils.h.d()) {
AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) this.e.getDrawable(z ? com.applovin.sdk.R.drawable.applovin_ic_unmute_to_mute : com.applovin.sdk.R.drawable.applovin_ic_mute_to_unmute);
if (animatedVectorDrawable != null) {
this.B.setScaleType(ImageView.ScaleType.FIT_XY);
this.B.setImageDrawable(animatedVectorDrawable);
animatedVectorDrawable.start();
return;
}
}
Uri aH = z ? this.f913a.aH() : this.f913a.aI();
StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
this.B.setImageURI(aH);
StrictMode.setThreadPolicy(allowThreadDiskReads);
}
public void A() {
if (this.K == null) {
return;
}
try {
float f = !this.G ? 0 : 1;
this.K.setVolume(f, f);
boolean z = this.G ? false : true;
this.G = z;
e(z);
a(this.G, 0L);
} catch (Throwable unused) {
}
}
@Override
public void a() {
com.applovin.impl.sdk.x xVar = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.b("AppLovinFullscreenActivity", "Continue video from prompt - will resume in onWindowFocusChanged(true) when alert dismisses");
}
}
@Override
public void b() {
com.applovin.impl.sdk.x xVar = this.c;
if (com.applovin.impl.sdk.x.a()) {
this.c.b("AppLovinFullscreenActivity", "Skipping video from prompt");
}
c();
}
@Override
protected void n() {
super.a(D(), this.O, s(), this.U);
}
@Override
protected void v() {
long ah;
long millis;
if (this.f913a.ag() >= 0 || this.f913a.ah() >= 0) {
if (this.f913a.ag() >= 0) {
ah = this.f913a.ag();
} else {
com.applovin.impl.sdk.ad.a aVar = (com.applovin.impl.sdk.ad.a) this.f913a;
long j = this.H;
long j2 = j > 0 ? 0 + j : 0L;
if (aVar.ai()) {
int l = (int) ((com.applovin.impl.sdk.ad.a) this.f913a).l();
if (l > 0) {
millis = TimeUnit.SECONDS.toMillis(l);
} else {
int t = (int) aVar.t();
if (t > 0) {
millis = TimeUnit.SECONDS.toMillis(t);
}
}
j2 += millis;
}
ah = (long) (j2 * (this.f913a.ah() / 100.0d));
}
b(ah);
}
}
@Override
public void x() {
super.x();
this.J.a(this.C);
this.J.a((View) this.z);
if (!u() || this.I) {
H();
}
}
public void H() {
this.J.a(this.i);
this.k = SystemClock.elapsedRealtime();
}
@Override
public void onMessageReceived(AppLovinCommunicatorMessage appLovinCommunicatorMessage) {
if ("video_caching_failed".equals(appLovinCommunicatorMessage.getTopic())) {
Bundle messageData = appLovinCommunicatorMessage.getMessageData();
long j = messageData.getLong("ad_id");
if (((Boolean) this.b.a(com.applovin.impl.sdk.c.b.gb)).booleanValue() && j == this.f913a.getAdIdNumber() && this.O) {
int i = messageData.getInt("load_response_code");
String string = messageData.getString("load_exception_message");
if ((string == null && i >= 200 && i < 300) || this.R || this.x.isPlaying()) {
return;
}
c("Video cache error during stream. ResponseCode=" + i + ", exception=" + string);
}
}
}
private class b implements MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, MediaPlayer.OnInfoListener, MediaPlayer.OnPreparedListener, AppLovinTouchToClickListener.OnClickListener {
private b() {
}
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
f.this.K = mediaPlayer;
mediaPlayer.setOnInfoListener(f.this.L);
mediaPlayer.setOnErrorListener(f.this.L);
float f = !f.this.G ? 1 : 0;
mediaPlayer.setVolume(f, f);
f.this.m = (int) TimeUnit.MILLISECONDS.toSeconds(mediaPlayer.getDuration());
f.this.c(mediaPlayer.getDuration());
f.this.v();
com.applovin.impl.sdk.x xVar = f.this.c;
if (com.applovin.impl.sdk.x.a()) {
f.this.c.b("AppLovinFullscreenActivity", "MediaPlayer prepared: " + f.this.K);
}
}
@Override
public boolean onInfo(MediaPlayer mediaPlayer, int i, int i2) {
com.applovin.impl.sdk.x xVar = f.this.c;
if (com.applovin.impl.sdk.x.a()) {
f.this.c.b("AppLovinFullscreenActivity", "MediaPlayer Info: (" + i + ", " + i2 + ")");
}
if (i == 701) {
f.this.y();
f.this.d.g();
return false;
}
if (i != 3) {
if (i != 702) {
return false;
}
f.this.z();
return false;
}
f.this.F.a();
if (f.this.z != null) {
f.this.E();
}
f.this.z();
if (!f.this.v.c()) {
return false;
}
f.this.e();
return false;
}
@Override
public boolean onError(MediaPlayer mediaPlayer, int i, int i2) {
f.this.c("Video view error (" + i + "," + i2 + ")");
f.this.x.start();
return true;
}
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
com.applovin.impl.sdk.x xVar = f.this.c;
if (com.applovin.impl.sdk.x.a()) {
f.this.c.b("AppLovinFullscreenActivity", "Video completed");
}
f.this.R = true;
if (!f.this.l) {
f.this.B();
} else if (f.this.u()) {
f.this.H();
}
}
@Override
public void onClick(View view, PointF pointF) {
f.this.a(pointF, false);
}
}
private class c implements View.OnClickListener {
private c() {
}
@Override
public void onClick(View view) {
if (view == f.this.z) {
if (f.this.t()) {
f.this.e();
f.this.q();
f.this.v.b();
return;
}
f.this.c();
return;
}
if (view == f.this.B) {
f.this.A();
return;
}
com.applovin.impl.sdk.x xVar = f.this.c;
if (com.applovin.impl.sdk.x.a()) {
f.this.c.e("AppLovinFullscreenActivity", "Unhandled click on widget: " + view);
}
}
}
private class a implements x.a {
private a() {
}
@Override
public void a(w wVar) {
com.applovin.impl.sdk.x xVar = f.this.c;
if (com.applovin.impl.sdk.x.a()) {
f.this.c.b("AppLovinFullscreenActivity", "Clicking through from video button...");
}
f.this.a(wVar.getAndClearLastClickLocation(), false);
}
@Override
public void b(w wVar) {
com.applovin.impl.sdk.x xVar = f.this.c;
if (com.applovin.impl.sdk.x.a()) {
f.this.c.b("AppLovinFullscreenActivity", "Closing ad from video button...");
}
f.this.h();
}
@Override
public void c(w wVar) {
com.applovin.impl.sdk.x xVar = f.this.c;
if (com.applovin.impl.sdk.x.a()) {
f.this.c.b("AppLovinFullscreenActivity", "Skipping video from video button...");
}
f.this.c();
}
@Override
public void d(w wVar) {
com.applovin.impl.sdk.x xVar = f.this.c;
if (com.applovin.impl.sdk.x.a()) {
f.this.c.b("AppLovinFullscreenActivity", "Attempting to install app from video button...");
}
f.this.a(wVar.getAndClearLastClickLocation(), true);
}
@Override
public void a(Uri uri, w wVar) {
com.applovin.impl.sdk.x xVar = f.this.c;
if (com.applovin.impl.sdk.x.a()) {
f.this.c.b("AppLovinFullscreenActivity", "Attempting to load a url from video button...");
}
t.a(uri, f.this.f.getController(), f.this.b);
}
}
}