导航菜单

页面标题

页面副标题

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

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

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


package net.pubnative.lite.sdk.rewarded.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.models.IntegrationType;
import net.pubnative.lite.sdk.presenter.AdPresenter;
import net.pubnative.lite.sdk.rewarded.HyBidRewardedBroadcastReceiver;
import net.pubnative.lite.sdk.rewarded.activity.VastRewardedActivity;
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 VastRewardedActivity extends HyBidRewardedActivity implements AdPresenter.ImpressionListener, AdCloseButtonListener {
    private static final String TAG = "VastRewardedActivity";
    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 mAdCloseButtonListener = new CloseButtonListener() {
        @Override
        public final void onCloseButtonVisible() {
            VastRewardedActivity.this.lambda$new$1();
        }
    };

    class AnonymousClass1 extends VideoAdListener {
        AnonymousClass1() {
        }

        public void lambda$onAdDidReachEnd$0() {
            VastRewardedActivity.this.showRewardedCloseButton();
        }

        @Override
        public void onAdClicked() {
            if (VastRewardedActivity.this.getBroadcastSender() != null) {
                VastRewardedActivity.this.getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.CLICK);
            }
        }

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

        @Override
        public void onAdDidReachEnd() {
            VastRewardedActivity.this.mReady = false;
            VastRewardedActivity vastRewardedActivity = VastRewardedActivity.this;
            vastRewardedActivity.mIsVideoFinished = true;
            if (!vastRewardedActivity.mHasEndCard) {
                new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        VastRewardedActivity.AnonymousClass1.this.lambda$onAdDidReachEnd$0();
                    }
                }, 600L);
            }
            if (VastRewardedActivity.this.getBroadcastSender() != null) {
                VastRewardedActivity.this.getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.VIDEO_FINISH);
            }
        }

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

        @Override
        public void onAdExpired() {
        }

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

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

        @Override
        public synchronized void onAdSkipped() {
            VastRewardedActivity vastRewardedActivity = VastRewardedActivity.this;
            vastRewardedActivity.mIsVideoFinished = true;
            if (vastRewardedActivity.getBroadcastSender() != null) {
                VastRewardedActivity.this.getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.VIDEO_SKIP);
            }
        }

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

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

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

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

        @Override
        public void onCustomEndCardClick(String str) {
            if (VastRewardedActivity.this.mCustomEndCardClickTracked.booleanValue()) {
                return;
            }
            if (VastRewardedActivity.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);
                VastRewardedActivity.this.getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.CUSTOM_END_CARD_CLICK, bundle);
            }
            VastRewardedActivity.this.mCustomEndCardClickTracked = Boolean.TRUE;
        }

        @Override
        public void onCustomEndCardShow(String str) {
            if (VastRewardedActivity.this.mCustomEndCardImpressionTracked.booleanValue()) {
                return;
            }
            if (VastRewardedActivity.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);
                VastRewardedActivity.this.getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.CUSTOM_END_CARD_SHOW, bundle);
            }
            VastRewardedActivity.this.mCustomEndCardImpressionTracked = Boolean.TRUE;
        }

        @Override
        public void onDefaultEndCardClick(String str) {
            if (VastRewardedActivity.this.mDefaultEndCardClickTracked.booleanValue()) {
                return;
            }
            if (VastRewardedActivity.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);
                VastRewardedActivity.this.getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.DEFAULT_END_CARD_CLICK, bundle);
            }
            VastRewardedActivity.this.mDefaultEndCardClickTracked = Boolean.TRUE;
        }

        @Override
        public void onDefaultEndCardShow(String str) {
            if (VastRewardedActivity.this.mDefaultEndCardImpressionTracked.booleanValue()) {
                return;
            }
            if (VastRewardedActivity.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);
                VastRewardedActivity.this.getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.DEFAULT_END_CARD_SHOW, bundle);
            }
            VastRewardedActivity.this.mDefaultEndCardImpressionTracked = Boolean.TRUE;
        }

        @Override
        public void onEndCardClosed(Boolean bool) {
            if (bool.booleanValue() && VastRewardedActivity.this.mCustomEndCardCloseTracked.booleanValue()) {
                return;
            }
            if (bool.booleanValue() || !VastRewardedActivity.this.mDefaultEndCardCloseTracked.booleanValue()) {
                if (bool.booleanValue()) {
                    VastRewardedActivity.this.mCustomEndCardCloseTracked = Boolean.TRUE;
                } else {
                    VastRewardedActivity.this.mDefaultEndCardCloseTracked = Boolean.TRUE;
                }
                if (HyBid.getReportingController() == null || !HyBid.isReportingEnabled().booleanValue()) {
                    return;
                }
                ReportingEvent reportingEvent = new ReportingEvent();
                reportingEvent.setTimestamp(System.currentTimeMillis());
                if (VastRewardedActivity.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 (VastRewardedActivity.this.mLoadEndCardFailTracked.booleanValue()) {
                return;
            }
            if (VastRewardedActivity.this.getBroadcastSender() != null) {
                Bundle bundle = new Bundle();
                bundle.putBoolean(Reporting.Key.IS_CUSTOM_END_CARD, bool.booleanValue());
                VastRewardedActivity.this.getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.END_CARD_LOAD_FAILURE, bundle);
            }
            VastRewardedActivity.this.mLoadEndCardFailTracked = Boolean.TRUE;
        }

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

        @Override
        public void onEndCardSkipped(Boolean bool) {
            if (bool.booleanValue() && VastRewardedActivity.this.mCustomEndCardSkipTracked.booleanValue()) {
                return;
            }
            if (bool.booleanValue() || !VastRewardedActivity.this.mDefaultEndCardSkipTracked.booleanValue()) {
                if (!bool.booleanValue()) {
                    VastRewardedActivity.this.mDefaultEndCardSkipTracked = Boolean.TRUE;
                }
                if (HyBid.getReportingController() == null || !HyBid.isReportingEnabled().booleanValue()) {
                    return;
                }
                ReportingEvent reportingEvent = new ReportingEvent();
                reportingEvent.setTimestamp(System.currentTimeMillis());
                if (VastRewardedActivity.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) {
            VastRewardedActivity.this.dismissVideo(i);
            VastRewardedActivity.this.dismiss();
        }
    }

    public void dismissVideo(int i) {
        if (getBroadcastSender() != null) {
            Bundle bundle = new Bundle();
            bundle.putInt("pn_video_progress", i);
            getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.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;
        this.mIsSkippable = true;
        this.mIsBackEnabled = true;
    }

    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 {
            if (getAd() == null) {
                if (getBroadcastSender() != null) {
                    Bundle bundle2 = new Bundle();
                    getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.ERROR);
                    bundle2.putInt("pn_video_progress", 0);
                    getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.VIDEO_ERROR, bundle2);
                }
                this.mIsFinishing = true;
                finish();
                return;
            }
            VideoAd videoAd = new VideoAd(this, getAd(), false, true, this, this);
            this.mVideoAd = videoAd;
            videoAd.setRewarded(true);
            this.mVideoAd.bindView(this.mVideoPlayer);
            this.mVideoAd.setAdListener(this.mVideoAdListener);
            this.mVideoAd.setAdCloseButtonListener(this.mAdCloseButtonListener);
            setProgressBarVisible();
            VideoAdCacheItem remove = HyBid.getVideoAdCache().remove(getZoneId());
            if (remove != null) {
                this.mVideoAd.setVideoCacheItem(remove);
                if (remove.getAdParams() == null || remove.getAdParams().getAdIcon() == null) {
                    setupContentInfo();
                } else {
                    setupContentInfo(remove.getAdParams().getAdIcon());
                }
            } else {
                setupContentInfo();
            }
            if (remove != null && 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;
            }
            this.mVideoPlayer.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VastRewardedActivity.this.lambda$onCreate$0();
                }
            }, 1000L);
        } catch (Exception e) {
            Logger.e(TAG, e.getMessage());
            if (getBroadcastSender() != null) {
                Bundle bundle3 = new Bundle();
                getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.ERROR);
                bundle3.putInt("pn_video_progress", 0);
                getBroadcastSender().sendBroadcast(HyBidRewardedBroadcastReceiver.Action.VIDEO_ERROR, bundle3);
            }
            this.mIsFinishing = true;
            finish();
        }
    }

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

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

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4) {
            return super.onKeyDown(i, keyEvent);
        }
        if (!this.mIsBackEnabled) {
            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() {
        showRewardedCloseButton();
    }
}