package com.fyber.inneractive.sdk.activities; import android.R; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; import androidx.core.view.accessibility.AccessibilityEventCompat; import com.fyber.inneractive.sdk.config.e0; import com.fyber.inneractive.sdk.config.enums.Orientation; import com.fyber.inneractive.sdk.config.g0; import com.fyber.inneractive.sdk.external.InneractiveAdSpot; import com.fyber.inneractive.sdk.external.InneractiveAdSpotManager; import com.fyber.inneractive.sdk.external.InneractiveUnitController; import com.fyber.inneractive.sdk.flow.r; import com.fyber.inneractive.sdk.flow.z; import com.fyber.inneractive.sdk.interfaces.c; import com.fyber.inneractive.sdk.network.t; import com.fyber.inneractive.sdk.ui.CloseButtonFlowManager; import com.fyber.inneractive.sdk.util.IAlog; import com.fyber.inneractive.sdk.util.p; /* loaded from: classes2.dex */ public class InneractiveFullscreenAdActivity extends InneractiveBaseActivity implements c.a { public static final String EXTRA_KEY_SPOT_ID = "spotId"; public ViewGroup b; public InneractiveAdSpot c; public com.fyber.inneractive.sdk.interfaces.c d; public CloseButtonFlowManager i; public int e = 0; public int f = 0; public int g = 0; public boolean h = false; protected final Runnable mHideNavigationBarTask = new a(); public interface FullScreenRendererProvider { com.fyber.inneractive.sdk.interfaces.c getFullscreenRenderer(); } public interface OnInneractiveFullscreenAdDestroyListener { void onActivityDestroyed(InneractiveFullscreenAdActivity inneractiveFullscreenAdActivity); } public class a implements Runnable { public a() { } @Override // java.lang.Runnable public final void run() { if (InneractiveFullscreenAdActivity.this.isFinishing()) { return; } InneractiveFullscreenAdActivity.this.hideNavigationBar(); } } public class b implements View.OnSystemUiVisibilityChangeListener { public b() { } @Override // android.view.View.OnSystemUiVisibilityChangeListener public final void onSystemUiVisibilityChange(int i) { if ((i & 2) == 0) { p.b.postDelayed(InneractiveFullscreenAdActivity.this.mHideNavigationBarTask, 3000L); } } } public void cancelHideNavigationBarTask() { getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(null); p.b.removeCallbacks(this.mHideNavigationBarTask); } @Override // com.fyber.inneractive.sdk.interfaces.c.a public void destroy() { if (isFinishing() || this.b == null) { return; } finish(); } @Override // com.fyber.inneractive.sdk.interfaces.c.a public ViewGroup getLayout() { return this.b; } /* JADX WARN: Multi-variable type inference failed */ public void initWindowFeatures(com.fyber.inneractive.sdk.interfaces.c cVar) { requestWindowFeature(1); getWindow().addFlags(1024); getWindow().addFlags(128); if (Build.VERSION.SDK_INT >= 28) { getWindow().addFlags(2); } if (cVar != 0 && (((r) cVar) instanceof com.fyber.inneractive.sdk.renderers.l)) { setTheme(R.style.Theme.NoTitleBar.Fullscreen); requestWindowFeature(AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL); requestWindowFeature(134217728); requestWindowFeature(Integer.MIN_VALUE); } hideNavigationBar(); g0 g0Var = ((e0) this.c.getAdContent().d).f; if (g0Var != null) { Orientation orientation = g0Var.e; setActivityOrientation(orientation.allowOrientationChange, orientation); } } @Override // android.app.Activity public void onBackPressed() { com.fyber.inneractive.sdk.interfaces.c cVar = this.d; if (cVar == null || !cVar.n()) { super.onBackPressed(); } } @Override // android.app.Activity, android.content.ComponentCallbacks public void onConfigurationChanged(Configuration configuration) { super.onConfigurationChanged(configuration); com.fyber.inneractive.sdk.interfaces.c cVar = this.d; if (cVar != null) { int i = configuration.orientation; if (i != this.e) { this.e = i; cVar.b(); return; } int i2 = this.f; int i3 = configuration.screenHeightDp; if (i2 == i3 && this.g == configuration.screenWidthDp) { return; } this.f = i3; this.g = configuration.screenWidthDp; cVar.b(); } } @Override // com.fyber.inneractive.sdk.activities.InneractiveBaseActivity, android.app.Activity public void onCreate(Bundle bundle) { String stringExtra = getIntent().getStringExtra("spotId"); InneractiveAdSpot inneractiveAdSpot = null; if (TextUtils.isEmpty(stringExtra)) { IAlog.f("%sSpot id must be provided as an extra before calling createActivity with InneractiveInterstitialAdActivty", IAlog.a(this)); } else { InneractiveAdSpot spot = InneractiveAdSpotManager.get().getSpot(stringExtra); if (spot == null) { IAlog.b("%sSpot id %s cannot be found in spot manager!", IAlog.a(this), stringExtra); } if (spot != null && spot.getAdContent() == null) { IAlog.a("%sSpot does not have a content. Cannot start activity", IAlog.a(this)); } if (spot != null && spot.getAdContent() != null) { inneractiveAdSpot = spot; } } this.c = inneractiveAdSpot; if (inneractiveAdSpot == null || inneractiveAdSpot.getAdContent() == null || this.c.getAdContent().d == null) { super.onCreate(bundle); finish(); return; } InneractiveUnitController selectedUnitController = this.c.getSelectedUnitController(); if (selectedUnitController == null || !(selectedUnitController instanceof FullScreenRendererProvider)) { IAlog.f("%sno appropriate unit controller found for full screen ad. Aborting", IAlog.a(this)); super.onCreate(bundle); finish(); return; } com.fyber.inneractive.sdk.interfaces.c fullscreenRenderer = ((FullScreenRendererProvider) selectedUnitController).getFullscreenRenderer(); this.d = fullscreenRenderer; initWindowFeatures(fullscreenRenderer); super.onCreate(bundle); IAlog.a("%sInterstitial for spot id %s created", IAlog.a(this), this.c.getLocalUniqueId()); this.e = getResources().getConfiguration().orientation; this.f = getResources().getConfiguration().screenHeightDp; this.g = getResources().getConfiguration().screenWidthDp; if (this.d == null) { IAlog.f("Interstitial Activity: Could not find an appropriate full screen ad renderer for content!", new Object[0]); finish(); return; } try { setContentView(com.fyber.inneractive.sdk.R.layout.ia_layout_fullscreen_activity); this.b = (ViewGroup) findViewById(com.fyber.inneractive.sdk.R.id.ia_ad_content); this.i = new CloseButtonFlowManager(this); ((z) this.d).initialize(this.c); try { this.d.a(this, this); this.c.getAdContent().e = true; } catch (Resources.NotFoundException e) { IAlog.f("Interstitial Activity: %s", e.getMessage()); finish(); } catch (InneractiveUnitController.AdDisplayError e2) { IAlog.f("Interstitial Activity: %s", e2.getMessage()); finish(); } } catch (Throwable th) { t.a(th, this.c.getAdContent().a, this.c.getAdContent().d()); finish(); } } @Override // android.app.Activity public void onPause() { super.onPause(); if (!isFinishing()) { com.fyber.inneractive.sdk.interfaces.c cVar = this.d; if (cVar != null) { cVar.v(); return; } return; } com.fyber.inneractive.sdk.interfaces.c cVar2 = this.d; if (cVar2 != null) { cVar2.r(); this.d.destroy(); this.d = null; } } @Override // android.app.Activity public void onResume() { super.onResume(); com.fyber.inneractive.sdk.interfaces.c cVar = this.d; if (cVar != null) { cVar.t(); } } @Override // android.app.Activity, android.view.Window.Callback public void onWindowFocusChanged(boolean z) { super.onWindowFocusChanged(z); if (!z) { com.fyber.inneractive.sdk.interfaces.c cVar = this.d; if (cVar != null) { cVar.v(); return; } return; } hideNavigationBar(); com.fyber.inneractive.sdk.interfaces.c cVar2 = this.d; if (cVar2 != null) { cVar2.t(); } } @Override // com.fyber.inneractive.sdk.interfaces.c.a public void setActivityOrientation(boolean z, Orientation orientation) { if (z && orientation.equals(Orientation.USER)) { setRequestedOrientation(13); return; } if (z && orientation.equals(Orientation.NONE)) { setRequestedOrientation(getRequestedOrientation()); return; } if (orientation.equals(Orientation.LANDSCAPE)) { setRequestedOrientation(6); return; } if (orientation.equals(Orientation.PORTRAIT)) { setRequestedOrientation(7); return; } int i = getResources().getConfiguration().orientation; if (i == 1) { setRequestedOrientation(7); } else if (i == 2) { setRequestedOrientation(6); } } @Override // com.fyber.inneractive.sdk.interfaces.c.a public void showCloseButton(boolean z, int i, int i2) { this.i.a(z, i, i2); } @Override // com.fyber.inneractive.sdk.interfaces.c.a public boolean wasDismissedByUser() { return this.h; } @Override // com.fyber.inneractive.sdk.interfaces.c.a public void disableCloseButton() { CloseButtonFlowManager closeButtonFlowManager = this.i; closeButtonFlowManager.c.setVisibility(8); closeButtonFlowManager.a.setVisibility(8); } @Override // com.fyber.inneractive.sdk.interfaces.c.a public void dismissAd(boolean z) { this.h = z; cancelHideNavigationBarTask(); com.fyber.inneractive.sdk.interfaces.c cVar = this.d; if (cVar != null) { cVar.c(z); } } @Override // com.fyber.inneractive.sdk.interfaces.c.a public View getCloseButton() { return this.i.e; } public void hideNavigationBar() { View decorView = getWindow().getDecorView(); if ((decorView.getSystemUiVisibility() & 2) == 0) { decorView.setSystemUiVisibility(2818); } decorView.setOnSystemUiVisibilityChangeListener(new b()); } @Override // com.fyber.inneractive.sdk.interfaces.c.a public boolean isCloseButtonDisplay() { return this.i.d.getVisibility() == 0; } @Override // com.fyber.inneractive.sdk.activities.InneractiveBaseActivity, android.app.Activity public void onDestroy() { ViewGroup viewGroup = this.b; if (viewGroup != null) { viewGroup.removeAllViews(); this.b = null; } InneractiveAdSpot inneractiveAdSpot = this.c; InneractiveUnitController selectedUnitController = inneractiveAdSpot == null ? null : inneractiveAdSpot.getSelectedUnitController(); if (selectedUnitController != null && (selectedUnitController instanceof OnInneractiveFullscreenAdDestroyListener)) { ((OnInneractiveFullscreenAdDestroyListener) selectedUnitController).onActivityDestroyed(this); } com.fyber.inneractive.sdk.interfaces.c cVar = this.d; if (cVar != null) { cVar.r(); this.d.destroy(); this.d = null; } super.onDestroy(); InneractiveAdSpot inneractiveAdSpot2 = this.c; if (inneractiveAdSpot2 != null) { inneractiveAdSpot2.destroy(); } } @Override // com.fyber.inneractive.sdk.interfaces.c.a public void secondEndCardWasDisplayed() { this.i.f = true; } @Override // com.fyber.inneractive.sdk.interfaces.c.a public void showCloseCountdown() { CloseButtonFlowManager closeButtonFlowManager = this.i; closeButtonFlowManager.b.setBackgroundResource(com.fyber.inneractive.sdk.R.drawable.ia_round_overlay_bg); closeButtonFlowManager.a.setVisibility(0); closeButtonFlowManager.b.setVisibility(0); closeButtonFlowManager.d.setVisibility(8); closeButtonFlowManager.c.setVisibility(8); } @Override // com.fyber.inneractive.sdk.interfaces.c.a public void updateCloseCountdown(int i) { CloseButtonFlowManager closeButtonFlowManager = this.i; if (i > 0) { closeButtonFlowManager.b.setText(Integer.toString(i)); } else { closeButtonFlowManager.getClass(); } } }