导航菜单

页面标题

页面副标题

CallApp v2.226 - InterstitialAdActivity.java 源代码

正在查看: CallApp v2.226 应用的 InterstitialAdActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.smaato.sdk.interstitial.view;

import android.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.j0;
import androidx.core.view.m1;
import com.smaato.sdk.core.AndroidsInjector;
import com.smaato.sdk.core.log.LogDomain;
import com.smaato.sdk.core.log.Logger;
import com.smaato.sdk.core.mvvm.view.SmaatoSdkViewDelegate;
import com.smaato.sdk.core.mvvm.view.ViewDelegateStorage;
import com.smaato.sdk.core.ui.AdContentView;
import com.smaato.sdk.core.util.Objects;
import com.smaato.sdk.core.util.diinjection.Inject;
import com.smaato.sdk.core.util.fi.Consumer;
import java.lang.ref.WeakReference;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;

public class InterstitialAdActivity extends Activity {
    protected static final String KEY_BACKGROUND_COLOR = "KEY_BACKGROUND_COLOR";
    protected static final String KEY_IS_SPLASH = "KEY_IS_SPLASH";
    protected static final String KEY_VIEWDELEGATE_UUID = "KEY_PRESENTER_UUID";
    private static final long SPLASH_DELAY_CLOSE_AD_MS = 5000;
    private static final long SPLASH_DELAY_SHOW_CLOSE_BUTTON_MS = 3000;

    @Nullable
    private ImageButton closeButton;
    private FrameLayout contentHolder;
    private WeakReference<TextView> countDownText;
    protected InterstitialAdBaseDelegate interstitialAdBaseDelegate;
    private boolean isBackButtonEnabled;
    private boolean isSplash;

    @Inject
    private Logger logger;

    @Nullable
    @Inject
    private ViewDelegateStorage viewDelegateStorage;
    private UUID viewModelUuid;
    private boolean splashTimersAreStarted = false;
    private final TimerTask showCloseButtonTask = new a();
    private final TimerTask closeAdTask = new b();
    private final Consumer<Boolean> closeButtonVisibilityChanger = new com.smaato.sdk.interstitial.view.b(this, 1);
    private final Consumer<Boolean> backButtonEnabledChanger = new com.smaato.sdk.interstitial.view.b(this, 2);
    private final Consumer<Long> countDownTextChanger = new com.smaato.sdk.interstitial.view.b(this, 3);
    private final Consumer<Boolean> countDownTextVisibilityChanger = new com.smaato.sdk.interstitial.view.b(this, 4);

    public class a extends TimerTask {
        public static final int b = 0;

        public a() {
        }

        @Override
        public final void run() {
            InterstitialAdActivity.this.runOnUiThread(new e(this, 1));
        }
    }

    public class b extends TimerTask {
        public b() {
        }

        @Override
        public final void run() {
            InterstitialAdActivity.this.runOnUiThread(new e(this, 2));
        }
    }

    public class c implements ViewTreeObserver.OnGlobalLayoutListener {
        public final AdContentView a;

        public c(AdContentView adContentView) {
            this.a = adContentView;
        }

        @Override
        public final void onGlobalLayout() {
            InterstitialAdActivity interstitialAdActivity = InterstitialAdActivity.this;
            interstitialAdActivity.contentHolder.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            FrameLayout frameLayout = interstitialAdActivity.contentHolder;
            AdContentView adContentView = this.a;
            float defineScaleFactor = interstitialAdActivity.defineScaleFactor(frameLayout, adContentView);
            if (Float.isNaN(defineScaleFactor) || Float.isInfinite(defineScaleFactor)) {
                defineScaleFactor = 1.0f;
            }
            adContentView.setScaleX(defineScaleFactor);
            adContentView.setScaleY(defineScaleFactor);
        }
    }

    private void adjustInsets() {
        try {
            if (Build.VERSION.SDK_INT >= 30) {
                getWindow().getDecorView().findViewById(R.id.content).setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
                    @Override
                    public final WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
                        WindowInsets lambda$adjustInsets$8;
                        lambda$adjustInsets$8 = InterstitialAdActivity.this.lambda$adjustInsets$8(view, windowInsets);
                        return lambda$adjustInsets$8;
                    }
                });
            }
        } catch (Exception e) {
            Logger logger = this.logger;
            if (logger != null) {
                logger.error(LogDomain.INTERSTITIAL, e, "error while setting view insets", new Object[0]);
            }
        }
    }

    @NonNull
    public static Intent createIntent(@NonNull Context context, @NonNull UUID uuid, int i, boolean z) {
        Objects.requireNonNull(context);
        Objects.requireNonNull(uuid);
        return new Intent(context, (Class<?>) InterstitialAdActivity.class).putExtra(KEY_VIEWDELEGATE_UUID, uuid).putExtra(KEY_BACKGROUND_COLOR, i).putExtra(KEY_IS_SPLASH, z);
    }

    public float defineScaleFactor(@NonNull FrameLayout frameLayout, @NonNull AdContentView adContentView) {
        return Math.min(frameLayout.getWidth() / adContentView.getWidth(), frameLayout.getHeight() / adContentView.getHeight());
    }

    private void initBackground() {
        findViewById(R.id.content).setBackgroundColor(getIntent().getIntExtra(KEY_BACKGROUND_COLOR, -16777216));
    }

    private void initCloseButton() {
        ImageButton imageButton = (ImageButton) findViewById(com.smaato.sdk.interstitial.R.id.smaato_sdk_interstitial_close);
        this.closeButton = imageButton;
        imageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                InterstitialAdActivity.this.lambda$initCloseButton$9(view);
            }
        });
        this.interstitialAdBaseDelegate.setCloseButtonSize(this.closeButton);
        this.interstitialAdBaseDelegate.setFriendlyObstructionView(this.closeButton);
        reSizeCloseButtonForSmallerResolutions();
    }

    private void initCloseButtonCountDown() {
        this.countDownText = new WeakReference<>((TextView) findViewById(com.smaato.sdk.interstitial.R.id.smaato_sdk_interstitial_countdown));
    }

    @NonNull
    private ProgressBar initProgressView() {
        return (ProgressBar) findViewById(com.smaato.sdk.video.R.id.smaato_sdk_video_video_progress);
    }

    public WindowInsets lambda$adjustInsets$8(View view, WindowInsets windowInsets) {
        try {
            view.setPadding(0, 0, 0, android.support.v4.media.session.h.B(j0.e(windowInsets, m1.v())));
            return windowInsets;
        } catch (Exception e) {
            Logger logger = this.logger;
            if (logger != null) {
                logger.error(LogDomain.INTERSTITIAL, e, "error while setting view insets using setOnApplyWindowInsetsListener", new Object[0]);
            }
            return windowInsets;
        }
    }

    public void lambda$initCloseButton$9(View view) {
        onCloseClicked();
    }

    public static void lambda$new$0(Boolean bool, ImageButton imageButton) {
        imageButton.setVisibility(bool.booleanValue() ? 0 : 8);
    }

    public void lambda$new$1(Boolean bool) {
        Objects.onNotNull(this.closeButton, new com.smaato.sdk.interstitial.view.a(bool, 0));
    }

    public void lambda$new$2(Boolean bool) {
        this.isBackButtonEnabled = bool.booleanValue();
    }

    public static void lambda$new$3(Long l, TextView textView) {
        textView.setText(String.valueOf(l));
    }

    public void lambda$new$4(Long l) {
        Objects.onNotNull(this.countDownText.get(), new g(l, 2));
    }

    public static void lambda$new$5(Boolean bool, TextView textView) {
        textView.setVisibility(bool.booleanValue() ? 0 : 8);
    }

    public void lambda$new$6(Boolean bool) {
        Objects.onNotNull(this.countDownText.get(), new com.smaato.sdk.interstitial.view.a(bool, 1));
    }

    public void lambda$onDestroy$7(ViewDelegateStorage viewDelegateStorage) {
        viewDelegateStorage.remove(this.viewModelUuid);
    }

    public void onCloseClicked() {
        Objects.onNotNull(this.interstitialAdBaseDelegate, new bp.b(20));
    }

    private void setAutomaticContentViewScaling(AdContentView adContentView) {
        this.contentHolder.getViewTreeObserver().addOnGlobalLayoutListener(new c(adContentView));
    }

    private void startSplashClosingTimers() {
        new Timer().schedule(this.showCloseButtonTask, SPLASH_DELAY_SHOW_CLOSE_BUTTON_MS);
        new Timer().schedule(this.closeAdTask, 5000L);
        this.splashTimersAreStarted = true;
    }

    public void initView(@Nullable AdContentView adContentView) {
        if (adContentView == null) {
            this.interstitialAdBaseDelegate.noContentViewFoundError();
            finish();
            return;
        }
        setContentView(com.smaato.sdk.interstitial.R.layout.smaato_sdk_interstitial_activity);
        adjustInsets();
        this.contentHolder = (FrameLayout) findViewById(com.smaato.sdk.interstitial.R.id.smaato_sdk_interstitial_content);
        if (adContentView.getParent() != null) {
            ((ViewGroup) adContentView.getParent()).removeView(adContentView);
        }
        this.contentHolder.addView(adContentView);
        initCloseButton();
        initCloseButtonCountDown();
        initBackground();
        setAutomaticContentViewScaling(adContentView);
        this.interstitialAdBaseDelegate.setProgressBar(initProgressView());
    }

    @Override
    public void onBackPressed() {
        if (this.isBackButtonEnabled) {
            onCloseClicked();
            super.onBackPressed();
        }
    }

    @Override
    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        AndroidsInjector.inject(this);
        if (this.viewDelegateStorage == null) {
            Logger logger = this.logger;
            if (logger != null) {
                logger.error(LogDomain.INTERSTITIAL, "SmaatoSdk is not initialized.", new Object[0]);
            }
            finish();
            return;
        }
        UUID uuid = (UUID) getIntent().getSerializableExtra(KEY_VIEWDELEGATE_UUID);
        this.viewModelUuid = uuid;
        SmaatoSdkViewDelegate smaatoSdkViewDelegate = this.viewDelegateStorage.get(uuid);
        if (smaatoSdkViewDelegate instanceof InterstitialAdBaseDelegate) {
            InterstitialAdBaseDelegate interstitialAdBaseDelegate = (InterstitialAdBaseDelegate) smaatoSdkViewDelegate;
            this.interstitialAdBaseDelegate = interstitialAdBaseDelegate;
            interstitialAdBaseDelegate.setCloseButtonVisibility(false);
            this.interstitialAdBaseDelegate.setCloseButtonVisibilityChanger(this.closeButtonVisibilityChanger);
            this.interstitialAdBaseDelegate.setBackButtonEnabledChanger(this.backButtonEnabledChanger);
            this.interstitialAdBaseDelegate.setActivityFinisher(new e(this, 0));
            this.interstitialAdBaseDelegate.setCountDownTimerTextChanger(this.countDownTextChanger);
            this.interstitialAdBaseDelegate.setCountDownTimerVisibilityChanger(this.countDownTextVisibilityChanger);
            this.interstitialAdBaseDelegate.startFailsafeCountDownTimer();
            initView(this.interstitialAdBaseDelegate.getAdContentView());
        } else {
            Logger logger2 = this.logger;
            if (logger2 != null) {
                logger2.error(LogDomain.INTERSTITIAL, "No InterstitialAdBaseDelegate available", new Object[0]);
            }
            finish();
        }
        this.isSplash = getIntent().getBooleanExtra(KEY_IS_SPLASH, false);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (isFinishing()) {
            Objects.onNotNull(this.interstitialAdBaseDelegate, new bp.b(21));
            Objects.onNotNull(this.viewDelegateStorage, new com.smaato.sdk.interstitial.view.b(this, 0));
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        Objects.onNotNull(this.interstitialAdBaseDelegate, new bp.b(22));
    }

    @Override
    public void onResume() {
        super.onResume();
        Objects.onNotNull(this.interstitialAdBaseDelegate, new bp.b(19));
        if (!this.isSplash || this.splashTimersAreStarted) {
            return;
        }
        startSplashClosingTimers();
    }

    public void reSizeCloseButtonForSmallerResolutions() {
        if (this.closeButton == null) {
            return;
        }
        DisplayMetrics displayMetrics = new DisplayMetrics();
        try {
            getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
            int i = displayMetrics.densityDpi;
            float scaleX = this.closeButton.getScaleX();
            float scaleY = this.closeButton.getScaleY();
            if (i <= 160) {
                this.closeButton.setScaleX(scaleX * 0.7f);
                this.closeButton.setScaleY(scaleY * 0.7f);
            } else if (i <= 240) {
                this.closeButton.setScaleX(scaleX * 0.65f);
                this.closeButton.setScaleY(scaleY * 0.65f);
            } else if (i <= 320) {
                this.closeButton.setScaleX(scaleX * 0.7f);
                this.closeButton.setScaleY(scaleY * 0.7f);
            }
        } catch (Exception e) {
            Logger logger = this.logger;
            if (logger != null) {
                logger.error(LogDomain.INTERSTITIAL, e, "error while getting display metrics", new Object[0]);
            }
        }
    }
}