导航菜单

页面标题

页面副标题

Fancy Optimizer v4.6.3 - TJAdUnitActivity.java 源代码

正在查看: Fancy Optimizer v4.6.3 应用的 TJAdUnitActivity.java JAVA 源代码文件

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


package com.tapjoy;

import android.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.VideoView;
import com.ironsource.mediationsdk.logger.IronSourceError;
import com.tapjoy.TJAdUnitConstants;
import com.tapjoy.TapjoyErrorMessage;
import com.tapjoy.internal.fo;
import com.tapjoy.internal.gd;
import com.tapjoy.internal.hk;
import java.util.HashMap;

public class TJAdUnitActivity extends Activity implements View.OnClickListener {
    private static TJAdUnitActivity c;
    TJAdUnit a;
    private TJPlacementData d;
    private TJCloseButton g;
    private ProgressBar h;
    private final Handler b = new Handler(Looper.getMainLooper());
    private TJAdUnitSaveStateData e = new TJAdUnitSaveStateData();
    private RelativeLayout f = null;
    private boolean i = false;
    private boolean j = false;
    private boolean k = false;

    public class AnonymousClass3 implements DialogInterface.OnClickListener {
        public AnonymousClass3() {
        }

        @Override
        public final void onClick(DialogInterface dialogInterface, int i) {
            TJAdUnitActivity.this.handleClose();
            dialogInterface.cancel();
        }
    }

    private void b() {
        c = null;
        this.j = true;
        TJAdUnit tJAdUnit = this.a;
        if (tJAdUnit != null) {
            tJAdUnit.destroy();
        }
        TJPlacementData tJPlacementData = this.d;
        if (tJPlacementData != null) {
            if (tJPlacementData.getContentViewId() != null) {
                TapjoyConnectCore.viewDidClose(this.d.getContentViewId());
            }
            TJCorePlacement a = TJPlacementManager.a(this.d.getKey());
            if (a != null) {
                if (gd.c) {
                    HashMap hashMap = new HashMap();
                    hashMap.put("sdkCloseBtn", String.valueOf(this.k));
                    this.a.getTjBeacon().a(TapjoyConstants.TJC_FULLSCREEN_AD_DISMISS_URL, hashMap);
                }
                a.d();
            }
        }
    }

    public void handleClose() {
        handleClose(false);
    }

    @Override
    public void onBackPressed() {
        handleClose();
    }

    @Override
    public void onClick(View view) {
        handleClose();
    }

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        TJAdUnit tJAdUnit = this.a;
        if (tJAdUnit != null) {
            tJAdUnit.notifyOrientationChanged();
        }
    }

    @Override
    public void onCreate(Bundle bundle) {
        TapjoyLog.d("TJAdUnitActivity", "TJAdUnitActivity onCreate: ".concat(String.valueOf(bundle)));
        super.onCreate(bundle);
        c = this;
        if (bundle != null) {
            TJAdUnitSaveStateData tJAdUnitSaveStateData = (TJAdUnitSaveStateData) bundle.getSerializable("ad_unit_bundle");
            this.e = tJAdUnitSaveStateData;
            if (tJAdUnitSaveStateData != null && tJAdUnitSaveStateData.isVideoComplete) {
                TapjoyLog.d("TJAdUnitActivity", "finishing TJAdUnitActivity");
                finish();
                return;
            }
        }
        Bundle extras = getIntent().getExtras();
        if (extras == null || extras.getSerializable(TJAdUnitConstants.EXTRA_TJ_PLACEMENT_DATA) == null) {
            TapjoyLog.e("TJAdUnitActivity", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Failed to launch AdUnit Activity"));
            finish();
            return;
        }
        TJPlacementData tJPlacementData = (TJPlacementData) extras.getSerializable(TJAdUnitConstants.EXTRA_TJ_PLACEMENT_DATA);
        this.d = tJPlacementData;
        if (tJPlacementData.getContentViewId() != null) {
            TapjoyConnectCore.viewWillOpen(this.d.getContentViewId(), 1);
        }
        if (TJPlacementManager.a(this.d.getKey()) != null) {
            this.a = TJPlacementManager.a(this.d.getKey()).getAdUnit();
        } else {
            this.a = new TJAdUnit();
            this.a.setAdContentTracker(new fo(this.d.getPlacementName(), this.d.getPlacementType()));
        }
        if (!this.a.hasCalledLoad()) {
            TapjoyLog.d("TJAdUnitActivity", "No content loaded for ad unit -- loading now");
            this.a.load(this.d, false, this);
        }
        this.a.setAdUnitActivity(this);
        requestWindowFeature(1);
        getWindow().setFlags(IronSourceError.ERROR_RV_LOAD_FAILED_NO_CANDIDATES, IronSourceError.ERROR_RV_LOAD_FAILED_NO_CANDIDATES);
        getWindow().setFlags(16777216, 16777216);
        getWindow().setBackgroundDrawable(new ColorDrawable(0));
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
        RelativeLayout relativeLayout = new RelativeLayout(this);
        this.f = relativeLayout;
        relativeLayout.setLayoutParams(layoutParams);
        this.f.setBackgroundColor(0);
        try {
            TJWebView backgroundWebView = this.a.getBackgroundWebView();
            backgroundWebView.setLayoutParams(layoutParams);
            if (backgroundWebView.getParent() != null) {
                ((ViewGroup) backgroundWebView.getParent()).removeView(backgroundWebView);
            }
            TJWebView webView = this.a.getWebView();
            webView.setLayoutParams(layoutParams);
            if (webView.getParent() != null) {
                ((ViewGroup) webView.getParent()).removeView(webView);
            }
            this.f.addView(backgroundWebView);
            VideoView videoView = this.a.getVideoView();
            RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-1, -1);
            if (videoView.getParent() != null) {
                ((ViewGroup) videoView.getParent()).removeView(videoView);
            }
            LinearLayout linearLayout = new LinearLayout(this);
            linearLayout.setGravity(17);
            linearLayout.addView(videoView, new LinearLayout.LayoutParams(-1, -1));
            this.f.addView(linearLayout, layoutParams2);
            this.f.addView(webView);
            this.h = new ProgressBar(this, null, R.attr.progressBarStyleLarge);
            if (this.d.hasProgressSpinner()) {
                setProgressSpinnerVisibility(true);
            } else {
                setProgressSpinnerVisibility(false);
            }
            RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(-2, -2);
            layoutParams3.addRule(13);
            this.h.setLayoutParams(layoutParams3);
            this.f.addView(this.h);
            TJCloseButton tJCloseButton = new TJCloseButton(this);
            this.g = tJCloseButton;
            tJCloseButton.setOnClickListener(this);
            this.f.addView(this.g);
            setContentView(this.f);
            TJAdUnit tJAdUnit = this.a;
            tJAdUnit.setOrientation(tJAdUnit.getTargetOrientation());
            this.a.setVisible(true);
        } catch (Exception e) {
            TapjoyLog.e("TJAdUnitActivity", e.getMessage());
        }
        TJCorePlacement a = TJPlacementManager.a(this.d.getKey());
        if (a != null) {
            TapjoyLog.i(TJCorePlacement.a, "Content shown for placement " + a.c.getPlacementName());
            a.f.b();
            TJPlacement a2 = a.a("SHOW");
            if (a2 != null && a2.getListener() != null) {
                a2.getListener().onContentShow(a2);
            }
            if (this.a.getSdkBeacon() != null) {
                this.a.getSdkBeacon().a();
            }
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        TJPlacementData tJPlacementData = this.d;
        if ((tJPlacementData == null || tJPlacementData.shouldHandleDismissOnPause()) && this.j) {
            return;
        }
        b();
    }

    @Override
    public void onPause() {
        TJPlacementData tJPlacementData;
        super.onPause();
        TapjoyLog.d("TJAdUnitActivity", "onPause");
        TJAdUnit tJAdUnit = this.a;
        if (tJAdUnit != null) {
            tJAdUnit.pause();
        } else {
            finish();
        }
        if (isFinishing() && (tJPlacementData = this.d) != null && tJPlacementData.shouldHandleDismissOnPause()) {
            TapjoyLog.d("TJAdUnitActivity", "is Finishing");
            b();
        }
    }

    @Override
    public void onResume() {
        TapjoyLog.d("TJAdUnitActivity", "onResume");
        super.onResume();
        TJAdUnit tJAdUnit = this.a;
        if (tJAdUnit != null) {
            if (tJAdUnit.isLockedOrientation()) {
                setRequestedOrientation(this.a.getLockedOrientation());
            }
            this.a.resume(this.e);
        }
    }

    @Override
    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        TapjoyLog.d("TJAdUnitActivity", "onSaveInstanceState");
        TJAdUnit tJAdUnit = this.a;
        if (tJAdUnit != null) {
            this.e.seekTime = tJAdUnit.getVideoSeekTime();
            this.e.isVideoComplete = this.a.isVideoComplete();
            this.e.isVideoMuted = this.a.isMuted();
            bundle.putSerializable("ad_unit_bundle", this.e);
        }
    }

    @Override
    public void onStart() {
        super.onStart();
        TapjoyLog.d("TJAdUnitActivity", "onStart");
        if (hk.a().m) {
            this.i = true;
            hk.a().a(this);
        }
    }

    @Override
    public void onStop() {
        if (this.i) {
            this.i = false;
            hk.a().b(this);
        }
        super.onStop();
        TapjoyLog.d("TJAdUnitActivity", "onStop");
    }

    public void setCloseButtonClickable(boolean z) {
        this.g.setClickableRequested(z);
    }

    public void setCloseButtonVisibility(boolean z) {
        if (z) {
            this.g.setVisibility(0);
        } else {
            this.g.setVisibility(4);
        }
    }

    public void setProgressSpinnerVisibility(boolean z) {
        if (z) {
            this.h.setVisibility(0);
        } else {
            this.h.setVisibility(4);
        }
    }

    public void setSdkCloseButtonClicked(boolean z) {
        this.k = z;
    }

    public void showErrorDialog() {
        if (isFinishing()) {
            return;
        }
        new AlertDialog.Builder(this, R.style.Theme.Material.Light.Dialog.Alert).setMessage("An error occured. Please try again later.").setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                TJAdUnitActivity.this.handleClose();
                dialogInterface.cancel();
            }
        }).create().show();
    }

    public static void a() {
        TJAdUnitActivity tJAdUnitActivity = c;
        if (tJAdUnitActivity != null) {
            tJAdUnitActivity.handleClose(true);
        }
    }

    public void handleClose(boolean z) {
        TJAdUnit tJAdUnit = this.a;
        if (tJAdUnit == null) {
            finish();
        } else {
            if (tJAdUnit.getCloseRequested()) {
                return;
            }
            TapjoyLog.d("TJAdUnitActivity", TJAdUnitConstants.String.CLOSE_REQUESTED);
            this.a.closeRequested(z);
            this.b.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    if (TJAdUnitActivity.this.a.getCloseRequested()) {
                        TapjoyLog.d("TJAdUnitActivity", "Did not receive callback from content. Closing ad.");
                        TJAdUnitActivity.this.finish();
                    }
                }
            }, 1000L);
        }
    }
}