导航菜单

页面标题

页面副标题

OLX India v19.42.007 - VastInterstitialActivity.java 源代码

正在查看: OLX India v19.42.007 应用的 VastInterstitialActivity.java JAVA 源代码文件

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


package net.pubnative.lite.sdk.interstitial.activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import net.pubnative.lite.sdk.HyBid;
import net.pubnative.lite.sdk.analytics.Reporting;
import net.pubnative.lite.sdk.analytics.ReportingEvent;
import net.pubnative.lite.sdk.interstitial.HyBidInterstitialBroadcastReceiver;
import net.pubnative.lite.sdk.interstitial.activity.VastInterstitialActivity;
import net.pubnative.lite.sdk.models.IntegrationType;
import net.pubnative.lite.sdk.presenter.AdPresenter;
import net.pubnative.lite.sdk.utils.AdEndCardManager;
import net.pubnative.lite.sdk.utils.AdTracker;
import net.pubnative.lite.sdk.utils.Logger;
import net.pubnative.lite.sdk.views.CloseableContainer;
import net.pubnative.lite.sdk.vpaid.AdCloseButtonListener;
import net.pubnative.lite.sdk.vpaid.CloseButtonListener;
import net.pubnative.lite.sdk.vpaid.PlayerInfo;
import net.pubnative.lite.sdk.vpaid.VastActivityInteractor;
import net.pubnative.lite.sdk.vpaid.VideoAd;
import net.pubnative.lite.sdk.vpaid.VideoAdCacheItem;
import net.pubnative.lite.sdk.vpaid.VideoAdListener;
import net.pubnative.lite.sdk.vpaid.VideoAdView;

public class VastInterstitialActivity extends HyBidInterstitialActivity implements AdPresenter.ImpressionListener, AdCloseButtonListener {
    private static final String TAG = "VastInterstitialActivity";
    private AdTracker mCustomCTAEndcardTracker;
    private AdTracker mCustomCTATracker;
    private VideoAdView mVideoPlayer;
    VastActivityInteractor vastActivityInteractor;
    private boolean mReady = false;
    private boolean mHasEndCard = false;
    private final VideoAdListener mVideoAdListener = new AnonymousClass1();
    private final CloseButtonListener mCloseButtonListener = new CloseButtonListener() {
        @Override
        public final void onCloseButtonVisible() {
            VastInterstitialActivity.this.lambda$new$1();
        }
    };

    class AnonymousClass1 extends VideoAdListener {
        AnonymousClass1() {
        }

        public void lambda$onAdDidReachEnd$0() {
            VastInterstitialActivity.this.showInterstitialCloseButton();
        }

        @Override
        public void onAdClicked() {
            VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.CLICK);
        }

        @Override
        public void onAdCustomEndCardFound() {
            VastInterstitialActivity.this.mHasEndCard = true;
        }

        @Override
        public void onAdDidReachEnd() {
            VastInterstitialActivity.this.mReady = false;
            if (!VastInterstitialActivity.this.mHasEndCard) {
                new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        VastInterstitialActivity.AnonymousClass1.this.lambda$onAdDidReachEnd$0();
                    }
                }, 100L);
                VastInterstitialActivity.this.mIsSkippable = Boolean.TRUE;
            }
            VastInterstitialActivity vastInterstitialActivity = VastInterstitialActivity.this;
            vastInterstitialActivity.mIsVideoFinished = true;
            if (vastInterstitialActivity.getBroadcastSender() != null) {
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.VIDEO_FINISH);
            }
        }

        @Override
        public void onAdDismissed() {
            onAdDismissed(-1);
        }

        @Override
        public void onAdLoadFail(PlayerInfo playerInfo) {
            VastInterstitialActivity.this.setProgressBarInvisible();
            if (VastInterstitialActivity.this.getBroadcastSender() != null) {
                Bundle bundle = new Bundle();
                bundle.putInt("pn_video_progress", 0);
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.ERROR);
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.VIDEO_ERROR, bundle);
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.DISMISS);
            }
            VastInterstitialActivity vastInterstitialActivity = VastInterstitialActivity.this;
            vastInterstitialActivity.mIsFinishing = true;
            vastInterstitialActivity.finish();
        }

        @Override
        public void onAdLoadSuccess() {
            if (VastInterstitialActivity.this.mReady) {
                return;
            }
            VastInterstitialActivity.this.mReady = true;
            VastInterstitialActivity.this.setProgressBarInvisible();
            VastInterstitialActivity.this.mVideoAd.show();
        }

        @Override
        public synchronized void onAdSkipped() {
            VastInterstitialActivity vastInterstitialActivity = VastInterstitialActivity.this;
            vastInterstitialActivity.mIsVideoFinished = true;
            if (vastInterstitialActivity.getBroadcastSender() != null) {
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.VIDEO_SKIP);
            }
        }

        @Override
        public void onAdStarted() {
            if (VastInterstitialActivity.this.getBroadcastSender() != null) {
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.VIDEO_START);
            }
        }

        @Override
        public void onCustomCTACLick(boolean z) {
            String str = z ? "custom_cta_endcard_click" : "custom_cta_click";
            if (VastInterstitialActivity.this.mCustomCTAClickTrackedEvents.contains(str)) {
                return;
            }
            if (HyBid.getReportingController() != null && HyBid.isReportingEnabled().booleanValue()) {
                ReportingEvent reportingEvent = new ReportingEvent();
                reportingEvent.setEventType(str);
                reportingEvent.setAdFormat(Reporting.AdFormat.FULLSCREEN);
                reportingEvent.setCreativeType("video");
                reportingEvent.setPlatform("android");
                reportingEvent.setSdkVersion(HyBid.getSDKVersionInfo(IntegrationType.STANDALONE));
                if (VastInterstitialActivity.this.getAd() != null) {
                    reportingEvent.setImpId(VastInterstitialActivity.this.getAd().getSessionId());
                    reportingEvent.setCampaignId(VastInterstitialActivity.this.getAd().getCampaignId());
                    reportingEvent.setConfigId(VastInterstitialActivity.this.getAd().getConfigId());
                }
                reportingEvent.setTimestamp(System.currentTimeMillis());
                HyBid.getReportingController().reportEvent(reportingEvent);
            }
            if (str.equals("custom_cta_endcard_click")) {
                if (VastInterstitialActivity.this.mCustomCTAEndcardTracker != null) {
                    VastInterstitialActivity.this.mCustomCTAEndcardTracker.trackClick();
                }
            } else if (VastInterstitialActivity.this.mCustomCTATracker != null) {
                VastInterstitialActivity.this.mCustomCTATracker.trackClick();
            }
            VastInterstitialActivity.this.mCustomCTAClickTrackedEvents.add(str);
        }

        @Override
        public void onCustomCTALoadFail() {
            Logger.e("onCustomCTALoadFail", "CTA Failed to load");
        }

        @Override
        public void onCustomCTAShow() {
            if (VastInterstitialActivity.this.mCustomCTAImpressionTracked.booleanValue()) {
                return;
            }
            if (HyBid.getReportingController() != null && HyBid.isReportingEnabled().booleanValue()) {
                ReportingEvent reportingEvent = new ReportingEvent();
                reportingEvent.setEventType("custom_cta_show");
                reportingEvent.setAdFormat(Reporting.AdFormat.FULLSCREEN);
                reportingEvent.setCreativeType("video");
                reportingEvent.setPlatform("android");
                reportingEvent.setSdkVersion(HyBid.getSDKVersionInfo(IntegrationType.STANDALONE));
                if (VastInterstitialActivity.this.getAd() != null) {
                    reportingEvent.setImpId(VastInterstitialActivity.this.getAd().getSessionId());
                    reportingEvent.setCampaignId(VastInterstitialActivity.this.getAd().getCampaignId());
                    reportingEvent.setConfigId(VastInterstitialActivity.this.getAd().getConfigId());
                }
                reportingEvent.setTimestamp(System.currentTimeMillis());
                HyBid.getReportingController().reportEvent(reportingEvent);
            }
            if (VastInterstitialActivity.this.mCustomCTATracker != null) {
                VastInterstitialActivity.this.mCustomCTATracker.trackImpression();
            }
            VastInterstitialActivity.this.mCustomCTAImpressionTracked = Boolean.TRUE;
        }

        @Override
        public void onCustomEndCardClick(String str) {
            if (VastInterstitialActivity.this.mCustomEndCardClickTracked.booleanValue()) {
                return;
            }
            if (VastInterstitialActivity.this.getBroadcastSender() != null) {
                Bundle bundle = new Bundle();
                bundle.putString(Reporting.Key.END_CARD_TYPE, str);
                bundle.putString("click", str);
                bundle.putString(Reporting.Key.CLICK_SOURCE_TYPE, Reporting.Key.CLICK_SOURCE_TYPE_END_CARD);
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.CUSTOM_END_CARD_CLICK, bundle);
            }
            VastInterstitialActivity.this.mCustomEndCardClickTracked = Boolean.TRUE;
        }

        @Override
        public void onCustomEndCardShow(String str) {
            if (VastInterstitialActivity.this.mCustomEndCardImpressionTracked.booleanValue()) {
                return;
            }
            if (VastInterstitialActivity.this.getBroadcastSender() != null) {
                Bundle bundle = new Bundle();
                bundle.putString(Reporting.Key.END_CARD_TYPE, str);
                bundle.putString(Reporting.Key.CLICK_SOURCE_TYPE, Reporting.Key.CLICK_SOURCE_TYPE_END_CARD);
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.CUSTOM_END_CARD_SHOW, bundle);
            }
            VastInterstitialActivity.this.mCustomEndCardImpressionTracked = Boolean.TRUE;
        }

        @Override
        public void onDefaultEndCardClick(String str) {
            if (VastInterstitialActivity.this.mDefaultEndCardClickTracked.booleanValue()) {
                return;
            }
            if (VastInterstitialActivity.this.getBroadcastSender() != null) {
                Bundle bundle = new Bundle();
                bundle.putString(Reporting.Key.END_CARD_TYPE, str);
                bundle.putString(Reporting.Key.CLICK_SOURCE_TYPE, Reporting.Key.CLICK_SOURCE_TYPE_END_CARD);
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.DEFAULT_END_CARD_CLICK, bundle);
            }
            VastInterstitialActivity.this.mDefaultEndCardClickTracked = Boolean.TRUE;
        }

        @Override
        public void onDefaultEndCardShow(String str) {
            if (VastInterstitialActivity.this.mDefaultEndCardImpressionTracked.booleanValue()) {
                return;
            }
            if (VastInterstitialActivity.this.getBroadcastSender() != null) {
                Bundle bundle = new Bundle();
                bundle.putString(Reporting.Key.END_CARD_TYPE, str);
                bundle.putString(Reporting.Key.CLICK_SOURCE_TYPE, Reporting.Key.CLICK_SOURCE_TYPE_END_CARD);
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.DEFAULT_END_CARD_SHOW, bundle);
            }
            VastInterstitialActivity.this.mDefaultEndCardImpressionTracked = Boolean.TRUE;
        }

        @Override
        public void onEndCardClosed(Boolean bool) {
            if (bool.booleanValue() && VastInterstitialActivity.this.mCustomEndCardCloseTracked.booleanValue()) {
                return;
            }
            if (bool.booleanValue() || !VastInterstitialActivity.this.mDefaultEndCardCloseTracked.booleanValue()) {
                if (bool.booleanValue()) {
                    VastInterstitialActivity.this.mCustomEndCardCloseTracked = Boolean.TRUE;
                } else {
                    VastInterstitialActivity.this.mDefaultEndCardCloseTracked = Boolean.TRUE;
                }
                if (HyBid.getReportingController() == null || !HyBid.isReportingEnabled().booleanValue()) {
                    return;
                }
                ReportingEvent reportingEvent = new ReportingEvent();
                reportingEvent.setTimestamp(System.currentTimeMillis());
                if (VastInterstitialActivity.this.mDefaultEndCardCloseTracked.booleanValue()) {
                    reportingEvent.setEventType(Reporting.EventType.DEFAULT_ENDCARD_CLOSE);
                    reportingEvent.setCustomString(Reporting.Key.END_CARD_TYPE, "default");
                } else {
                    reportingEvent.setEventType(Reporting.EventType.CUSTOM_ENDCARD_CLOSE);
                    reportingEvent.setCustomString(Reporting.Key.END_CARD_TYPE, Reporting.Key.END_CARD_TYPE_CUSTOM);
                }
                HyBid.getReportingController().reportEvent(reportingEvent);
            }
        }

        @Override
        public void onEndCardLoadFail(Boolean bool) {
            if (VastInterstitialActivity.this.mLoadEndCardFailTracked.booleanValue()) {
                return;
            }
            if (VastInterstitialActivity.this.getBroadcastSender() != null) {
                Bundle bundle = new Bundle();
                bundle.putBoolean(Reporting.Key.IS_CUSTOM_END_CARD, bool.booleanValue());
                VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.END_CARD_LOAD_FAILURE, bundle);
            }
            VastInterstitialActivity.this.mLoadEndCardFailTracked = Boolean.TRUE;
        }

        @Override
        public synchronized void onEndCardLoadSuccess(Boolean bool) {
            if (bool.booleanValue() && VastInterstitialActivity.this.mLoadCustomEndCardTracked.booleanValue()) {
                return;
            }
            if (bool.booleanValue() || !VastInterstitialActivity.this.mLoadDefaultEndCardTracked.booleanValue()) {
                if (VastInterstitialActivity.this.getBroadcastSender() != null) {
                    if (bool.booleanValue()) {
                        VastInterstitialActivity.this.hideContentInfo();
                        VastInterstitialActivity.this.mLoadCustomEndCardTracked = Boolean.TRUE;
                    } else {
                        VastInterstitialActivity.this.mLoadDefaultEndCardTracked = Boolean.TRUE;
                    }
                    Bundle bundle = new Bundle();
                    bundle.putBoolean(Reporting.Key.IS_CUSTOM_END_CARD, bool.booleanValue());
                    VastInterstitialActivity.this.getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.END_CARD_LOAD_SUCCESS, bundle);
                }
            }
        }

        @Override
        public void onEndCardSkipped(Boolean bool) {
            if (bool.booleanValue() && VastInterstitialActivity.this.mCustomEndCardSkipTracked.booleanValue()) {
                return;
            }
            if (bool.booleanValue() || !VastInterstitialActivity.this.mDefaultEndCardSkipTracked.booleanValue()) {
                if (!bool.booleanValue()) {
                    VastInterstitialActivity.this.mDefaultEndCardSkipTracked = Boolean.TRUE;
                }
                if (HyBid.getReportingController() == null || !HyBid.isReportingEnabled().booleanValue()) {
                    return;
                }
                ReportingEvent reportingEvent = new ReportingEvent();
                reportingEvent.setTimestamp(System.currentTimeMillis());
                if (VastInterstitialActivity.this.mDefaultEndCardSkipTracked.booleanValue()) {
                    reportingEvent.setEventType(Reporting.EventType.DEFAULT_ENDCARD_SKIP);
                    reportingEvent.setCustomString(Reporting.Key.END_CARD_TYPE, "default");
                }
                HyBid.getReportingController().reportEvent(reportingEvent);
            }
        }

        @Override
        public void onAdDismissed(int i) {
            VastInterstitialActivity vastInterstitialActivity = VastInterstitialActivity.this;
            if (vastInterstitialActivity.mIsSkippable.booleanValue()) {
                i = 100;
            }
            vastInterstitialActivity.dismissVideo(i);
            VastInterstitialActivity.this.dismiss();
        }
    }

    public void dismissVideo(int i) {
        if (getBroadcastSender() != null) {
            Bundle bundle = new Bundle();
            bundle.putInt("pn_video_progress", i);
            getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.VIDEO_DISMISS, bundle);
        }
    }

    private void initiateCustomCTAAdTrackers() {
        if (getAd() != null) {
            this.mCustomCTATracker = new AdTracker(getAd().getBeacons("custom_cta_show"), getAd().getBeacons("custom_cta_click"), false);
            this.mCustomCTAEndcardTracker = new AdTracker(null, getAd().getBeacons("custom_cta_endcard_click"), false);
        }
    }

    public void lambda$new$1() {
        this.mIsVideoFinished = true;
        Boolean bool = Boolean.TRUE;
        this.mIsSkippable = bool;
        this.mIsBackEnabled = bool;
    }

    public void lambda$onCreate$0() {
        this.mVideoAd.load(this.mIntegrationType);
    }

    @Override
    public View getAdView() {
        if (getAd() == null) {
            return null;
        }
        VideoAdView videoAdView = new VideoAdView(this);
        this.mVideoPlayer = videoAdView;
        return videoAdView;
    }

    @Override
    public void hideButton() {
        CloseableContainer closeableContainer = getCloseableContainer();
        if (closeableContainer != null) {
            closeableContainer.setCloseVisible(true);
        }
    }

    @Override
    protected void onCreate(Bundle bundle) {
        if (getResources().getConfiguration().orientation == 2) {
            setRequestedOrientation(0);
        }
        if (getResources().getConfiguration().orientation == 1) {
            setRequestedOrientation(1);
        }
        setIsVast(Boolean.TRUE);
        super.onCreate(bundle);
        VastActivityInteractor vastActivityInteractor = VastActivityInteractor.getInstance();
        this.vastActivityInteractor = vastActivityInteractor;
        vastActivityInteractor.activityStarted();
        initiateCustomCTAAdTrackers();
        try {
            hideInterstitialCloseButton();
            if (getAd() == null) {
                if (getBroadcastSender() != null) {
                    Bundle bundle2 = new Bundle();
                    bundle2.putInt("pn_video_progress", 0);
                    getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.ERROR);
                    getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.VIDEO_ERROR, bundle2);
                    getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.DISMISS);
                }
                this.mIsFinishing = true;
                finish();
                return;
            }
            int intExtra = getIntent().getIntExtra("extra_pn_skip_offset", -1);
            this.mIsSkippable = Boolean.valueOf(intExtra == 0);
            VideoAd videoAd = new VideoAd(this, getAd(), true, true, this, this);
            this.mVideoAd = videoAd;
            videoAd.useMobileNetworkForCaching(true);
            this.mVideoAd.bindView(this.mVideoPlayer);
            this.mVideoAd.setAdListener(this.mVideoAdListener);
            this.mVideoAd.setAdCloseButtonListener(this.mCloseButtonListener);
            setProgressBarVisible();
            VideoAdCacheItem remove = HyBid.getVideoAdCache().remove(getZoneId());
            if (remove != null) {
                if (remove.getAdParams() != null) {
                    remove.getAdParams().setPublisherSkipSeconds(intExtra);
                    if (remove.getEndCardData() != null && !TextUtils.isEmpty(remove.getEndCardData().getContent())) {
                        this.mHasEndCard = AdEndCardManager.isEndCardEnabled(getAd()).booleanValue();
                    } else if (getAd().isEndCardEnabled() != null && getAd().isEndCardEnabled().booleanValue() && getAd().isCustomEndCardEnabled() != null && getAd().isCustomEndCardEnabled().booleanValue() && getAd().hasCustomEndCard()) {
                        this.mHasEndCard = true;
                    }
                    if (remove.getAdParams().getAdIcon() != null) {
                        setupContentInfo(remove.getAdParams().getAdIcon());
                    } else {
                        setupContentInfo();
                    }
                }
                this.mVideoAd.setVideoCacheItem(remove);
            } else {
                setupContentInfo();
            }
            this.mVideoPlayer.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VastInterstitialActivity.this.lambda$onCreate$0();
                }
            }, 1000L);
        } catch (Exception e) {
            Logger.e(TAG, e.getMessage());
            if (getBroadcastSender() != null) {
                Bundle bundle3 = new Bundle();
                bundle3.putInt("pn_video_progress", 0);
                getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.ERROR);
                getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.VIDEO_ERROR, bundle3);
                getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.DISMISS);
            }
            this.mIsFinishing = true;
            finish();
        }
    }

    @Override
    protected void onDestroy() {
        this.vastActivityInteractor.activityDestroyed();
        VideoAd videoAd = this.mVideoAd;
        if (videoAd != null) {
            videoAd.destroy();
            this.mReady = false;
        }
        super.onDestroy();
    }

    @Override
    public void onImpression() {
        if (getBroadcastSender() != null) {
            getBroadcastSender().sendBroadcast(HyBidInterstitialBroadcastReceiver.Action.SHOW);
        }
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4) {
            return super.onKeyDown(i, keyEvent);
        }
        if (!this.mIsBackEnabled.booleanValue()) {
            return false;
        }
        dismiss();
        return true;
    }

    @Override
    protected void onPause() {
        if (!this.mIsFinishing) {
            this.vastActivityInteractor.activityPaused();
            pauseAd();
        }
        super.onPause();
    }

    @Override
    protected void onResume() {
        this.vastActivityInteractor.activityResumed();
        super.onResume();
        resumeAd();
    }

    @Override
    protected void pauseAd() {
        if (this.mReady && this.mVideoAd.isAdStarted()) {
            this.mVideoAd.pause();
        }
        if (this.mIsVideoFinished) {
            this.mVideoAd.pauseEndCardCloseButtonTimer();
        }
    }

    @Override
    protected void resumeAd() {
        if (this.mIsFeedbackFormOpen) {
            return;
        }
        if (this.mReady) {
            if (this.mVideoAd.isAdStarted()) {
                this.mVideoAd.resume();
            } else {
                setProgressBarInvisible();
                this.mVideoAd.show();
            }
        }
        if (this.mIsVideoFinished) {
            this.mVideoAd.resumeEndCardCloseButtonTimer();
        }
    }

    @Override
    protected boolean shouldShowContentInfo() {
        return true;
    }

    @Override
    public void showButton() {
        showInterstitialCloseButton();
    }
}