导航菜单

页面标题

页面副标题

FileWipe Pro v3.0.0 - InterNativeActivity.java 源代码

正在查看: FileWipe Pro v3.0.0 应用的 InterNativeActivity.java JAVA 源代码文件

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


package com.tradplus.ads.mgr.interstitial.views;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Outline;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.google.android.gms.internal.measurement.a1;
import com.tradplus.ads.base.GlobalTradPlus;
import com.tradplus.ads.base.adapter.TPBaseAdapter;
import com.tradplus.ads.base.bean.TPBaseAd;
import com.tradplus.ads.base.common.TPTaskManager;
import com.tradplus.ads.base.util.AppKeyManager;
import com.tradplus.ads.base.util.PrivacyDataInfo;
import com.tradplus.ads.common.util.CustomLogUtils;
import com.tradplus.ads.common.util.DeviceUtils;
import com.tradplus.ads.common.util.ResourceUtils;
import com.tradplus.ads.core.cache.AdCache;
import com.tradplus.ads.core.track.LoadLifecycleCallback;
import com.tradplus.ads.core.track.ShowAdListener;
import com.tradplus.ads.mgr.interstitial.InterNativeMgr;
import com.tradplus.ads.mgr.nativead.TPNativeAdRenderImpl;
import com.tradplus.ads.open.R;
import com.tradplus.ads.open.nativead.TPNativeAdRender;
import java.util.Map;

public class InterNativeActivity extends Activity {
    private ViewGroup a;
    private int b;
    private int c;
    private String d;

    public class a extends ViewOutlineProvider {
        final Context a;

        public a(Context context) {
            this.a = context;
        }

        @Override
        public void getOutline(View view, Outline outline) {
            outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), DeviceUtils.dip2px(this.a, 16.0f));
        }
    }

    public class b implements Runnable {
        final View a;
        final LoadLifecycleCallback b;
        final TPBaseAdapter c;
        final String d;

        public class a implements View.OnClickListener {
            public a() {
            }

            @Override
            public void onClick(View view) {
                b bVar = b.this;
                LoadLifecycleCallback loadLifecycleCallback = bVar.b;
                if (loadLifecycleCallback != null) {
                    loadLifecycleCallback.videoEnd(bVar.c, bVar.d);
                }
                InterNativeActivity.this.finish();
            }
        }

        public b(View view, LoadLifecycleCallback loadLifecycleCallback, TPBaseAdapter tPBaseAdapter, String str) {
            this.a = view;
            this.b = loadLifecycleCallback;
            this.c = tPBaseAdapter;
            this.d = str;
        }

        @Override
        public void run() {
            View view = this.a;
            if (view != null) {
                view.setVisibility(0);
                this.a.setOnClickListener(new a());
            } else {
                LoadLifecycleCallback loadLifecycleCallback = this.b;
                if (loadLifecycleCallback != null) {
                    loadLifecycleCallback.videoEnd(this.c, this.d);
                }
                InterNativeActivity.this.finish();
            }
        }
    }

    public class c extends ViewOutlineProvider {
        final Context a;

        public c(Context context) {
            this.a = context;
        }

        @Override
        public void getOutline(View view, Outline outline) {
            outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), DeviceUtils.dip2px(this.a, 8.0f));
        }
    }

    private int a() {
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        int i = displayMetrics.widthPixels;
        this.b = i;
        int i2 = displayMetrics.heightPixels;
        this.c = i2;
        if (i > i2) {
            setRequestedOrientation(6);
            return 2;
        }
        setRequestedOrientation(1);
        return 1;
    }

    private void b() {
        try {
            getWindow().getDecorView().setSystemUiVisibility(4102);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    private void c() {
        TPNativeAdRender b2;
        ViewGroup viewGroup;
        ViewGroup viewGroup2;
        char c2;
        View inflate;
        Context context = GlobalTradPlus.getInstance().getContext();
        int a2 = a();
        this.d = getIntent().getStringExtra("adUnitId");
        InterNativeInfo adUnitId = InterNativeMgr.getInstance().getAdUnitId(this.d);
        if (adUnitId == null) {
            finish();
            return;
        }
        AdCache adCache = adUnitId.getAdCache();
        if (adCache == null) {
            finish();
            return;
        }
        TPBaseAdapter adapter = adUnitId.getAdapter();
        String adSceneId = adUnitId.getAdSceneId();
        int fullScreen = adUnitId.getFullScreen();
        LoadLifecycleCallback callback = adUnitId.getCallback();
        TPBaseAd adObj = adCache.getAdObj();
        adObj.setAdShowListener(new ShowAdListener(callback, adapter, adSceneId));
        try {
            b2 = com.tradplus.ads.mgr.interstitial.views.a.a().b();
            viewGroup = null;
            if (b2 != null) {
                viewGroup2 = b2.createAdLayoutView();
                if (viewGroup2 == null) {
                    viewGroup2 = null;
                }
                c2 = 0;
            } else {
                LayoutInflater layoutInflater = (LayoutInflater) getSystemService("layout_inflater");
                if (fullScreen != 1) {
                    if (a2 == 1) {
                        inflate = layoutInflater.inflate(ResourceUtils.getLayoutIdByName(this, "tp_internative_half_ad"), (ViewGroup) null);
                        c2 = 1;
                    } else {
                        inflate = layoutInflater.inflate(ResourceUtils.getLayoutIdByName(this, "tp_internative_landscape_half_ad"), (ViewGroup) null);
                        c2 = 2;
                    }
                    viewGroup2 = (ViewGroup) inflate;
                    c(context, viewGroup2);
                } else {
                    ViewGroup viewGroup3 = (ViewGroup) layoutInflater.inflate(a2 == 1 ? ResourceUtils.getLayoutIdByName(this, "tp_internative_full_ad") : ResourceUtils.getLayoutIdByName(this, "tp_internative_landscape_full_ad"), (ViewGroup) null);
                    Map<String, Object> networkhashMap = adapter.getNetworkhashMap();
                    if (networkhashMap != null && networkhashMap.containsKey(AppKeyManager.NATIVE_NEED_HEIGHT)) {
                        Object obj = networkhashMap.get(AppKeyManager.NATIVE_NEED_HEIGHT);
                        if ((obj instanceof Boolean) && ((Boolean) obj).booleanValue()) {
                            a(context, viewGroup3);
                        }
                    }
                    viewGroup2 = viewGroup3;
                    c2 = 0;
                }
                b(context, viewGroup2);
                b2 = null;
            }
            ViewGroup viewGroup4 = (ViewGroup) (c2 == 1 ? findViewById(ResourceUtils.getViewIdByName(this, "tp_ad_container_half")) : c2 == 2 ? findViewById(ResourceUtils.getViewIdByName(this, "tp_ad_container_half_landscape")) : findViewById(ResourceUtils.getViewIdByName(this, "tp_ad_container")));
            this.a = viewGroup4;
            viewGroup4.setVisibility(0);
            adObj.beforeRender(this.a);
        } catch (Throwable th) {
            th.printStackTrace();
            CustomLogUtils.getInstance().log(CustomLogUtils.TradPlusLog.SHOW_ACTION, this.d + " layout inflate exception :" + th.getMessage());
        }
        if (viewGroup2 == null) {
            CustomLogUtils.getInstance().log(CustomLogUtils.TradPlusLog.SHOW_ACTION, this.d + " layoutView is null");
            finish();
            return;
        }
        View findViewById = viewGroup2.findViewById(ResourceUtils.getViewIdByName(context, "tp_icon_close"));
        if (b2 == null) {
            b2 = new TPNativeAdRenderImpl(this, viewGroup2);
        }
        try {
            if (adObj.getNativeAdType() == 0) {
                viewGroup = b2.renderAdView(adObj.getTPNativeView());
                a(adObj, viewGroup, b2);
            }
        } catch (Throwable th2) {
            th2.printStackTrace();
        }
        if (viewGroup == null) {
            callback.showAdEnd(adCache, adSceneId, "102", "layout view is null");
            a1.v(new StringBuilder(), this.d, " layout view is null", CustomLogUtils.getInstance(), CustomLogUtils.TradPlusLog.SHOW_ACTION);
            finish();
            return;
        }
        this.a.removeAllViews();
        if (viewGroup.getParent() != null) {
            ((ViewGroup) viewGroup.getParent()).removeView(viewGroup);
        }
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
        layoutParams.gravity = 17;
        ViewGroup customAdContainer = adObj.getCustomAdContainer();
        if (customAdContainer != null) {
            if (customAdContainer.getParent() != null) {
                ((ViewGroup) customAdContainer.getParent()).removeView(customAdContainer);
            }
            customAdContainer.addView(viewGroup, layoutParams);
            this.a.addView(customAdContainer);
        } else {
            this.a.addView(viewGroup, layoutParams);
        }
        adObj.registerClickAfterRender(this.a, b2.getClickViews());
        if (findViewById == null) {
            findViewById = new ImageView(context);
            findViewById.setBackgroundResource(R.drawable.tp_internative_icon_close);
            RelativeLayout relativeLayout = new RelativeLayout(context);
            RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(DeviceUtils.dip2px(context, 30.0f), DeviceUtils.dip2px(context, 30.0f));
            layoutParams2.addRule(10);
            layoutParams2.addRule(11);
            layoutParams2.rightMargin = 16;
            layoutParams2.topMargin = 16;
            relativeLayout.addView(findViewById, layoutParams2);
            if (this.a != null) {
                findViewById.setVisibility(4);
                this.a.addView(relativeLayout);
            }
        }
        a(findViewById, callback, adapter, adSceneId);
    }

    public static void start(String str) {
        Intent intent = new Intent(GlobalTradPlus.getInstance().getContext(), (Class<?>) InterNativeActivity.class);
        intent.putExtra("adUnitId", str);
        intent.addFlags(268435456);
        GlobalTradPlus.getInstance().getContext().startActivity(intent);
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(ResourceUtils.getLayoutIdByName(this, "tp_native_interstitial_layout"));
        b();
        c();
    }

    @Override
    public void onDestroy() {
        ViewGroup viewGroup = this.a;
        if (viewGroup != null) {
            viewGroup.removeAllViews();
        }
        InterNativeMgr.getInstance().unRegister(this.d);
        super.onDestroy();
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (4 == i) {
            return true;
        }
        return super.onKeyDown(i, keyEvent);
    }

    private void a(TPBaseAd tPBaseAd, View view, TPNativeAdRender tPNativeAdRender) {
        if (tPNativeAdRender.getCallToActionView() != null) {
            tPNativeAdRender.getCallToActionView().setTag(TPBaseAd.NATIVE_AD_TAG_CALLTOACTION);
        }
        if (tPNativeAdRender.getIconView() != null) {
            tPNativeAdRender.getIconView().setTag(TPBaseAd.NATIVE_AD_TAG_ICON);
        }
        if (tPNativeAdRender.getImageView() != null) {
            tPNativeAdRender.getImageView().setTag(TPBaseAd.NATIVE_AD_TAG_IMAGE);
        }
        if (tPNativeAdRender.getTitleView() != null) {
            tPNativeAdRender.getTitleView().setTag(TPBaseAd.NATIVE_AD_TAG_TITLE);
        }
        if (tPNativeAdRender.getSubTitleView() != null) {
            tPNativeAdRender.getSubTitleView().setTag(TPBaseAd.NATIVE_AD_TAG_SUBTITLE);
        }
        if (tPNativeAdRender.getAdChoicesContainer() != null) {
            tPNativeAdRender.getAdChoicesContainer().setTag(TPBaseAd.NATIVE_AD_TAG_ADCHOICES);
        }
        if (tPNativeAdRender.getAdChoiceView() != null) {
            tPNativeAdRender.getAdChoiceView().setTag(TPBaseAd.NATIVE_AD_TAG_ADCHOICES_IMAGE);
        }
        if (view != null) {
            tPBaseAd.registerClickView((ViewGroup) view, tPNativeAdRender.getClickViews());
        }
    }

    private void b(Context context, ViewGroup viewGroup) {
        try {
            View findViewById = viewGroup.findViewById(ResourceUtils.getViewIdByName(context, "tp_native_icon_image"));
            if (PrivacyDataInfo.getInstance().getOSVersion() < 21 || findViewById == null) {
                return;
            }
            findViewById.setOutlineProvider(new c(context));
            findViewById.setClipToOutline(true);
        } catch (Throwable th) {
            th.printStackTrace();
            a1.v(new StringBuilder(), this.d, " layout inflate exception", CustomLogUtils.getInstance(), CustomLogUtils.TradPlusLog.SHOW_ACTION);
        }
    }

    private void a(View view, LoadLifecycleCallback loadLifecycleCallback, TPBaseAdapter tPBaseAdapter, String str) {
        TPTaskManager.getInstance().runOnMainThreadDelayed(new b(view, loadLifecycleCallback, tPBaseAdapter, str), 3000L);
    }

    private void a(Context context, ViewGroup viewGroup) {
        try {
            viewGroup.findViewById(ResourceUtils.getViewIdByName(context, "tp_mopub_native_main_image")).setLayoutParams(new ViewGroup.LayoutParams(-1, DeviceUtils.dip2px(context, 220.0f)));
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    private void c(Context context, ViewGroup viewGroup) {
        try {
            View findViewById = viewGroup.findViewById(ResourceUtils.getViewIdByName(context, "tp_ad_layout_ly"));
            if (PrivacyDataInfo.getInstance().getOSVersion() < 21 || findViewById == null) {
                return;
            }
            findViewById.setOutlineProvider(new a(context));
            findViewById.setClipToOutline(true);
        } catch (Throwable th) {
            th.printStackTrace();
            a1.v(new StringBuilder(), this.d, " layout inflate exception", CustomLogUtils.getInstance(), CustomLogUtils.TradPlusLog.SHOW_ACTION);
        }
    }
}