Snaptube v4.40.0.4401610版本的 MD5 值为:ca2b95dcff63007195db02a6c93091b9

以下内容为反编译后的 NativeAd.java 源代码,内容仅作参考


package com.appnext.nativeads;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.appnext.core.Ad;
import com.appnext.core.AppnextAd;
import com.appnext.core.AppnextError;
import com.appnext.core.b;
import com.appnext.core.f;
import com.appnext.core.j;
import com.appnext.core.o;
import com.appnext.core.q;
import com.appnext.nativeads.MediaView;
import com.appnext.nativeads.NativeAdRequest;
import com.appnext.nativeads.NativeAdView;
import io.fabric.sdk.android.services.events.EventsFilesManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
public class NativeAd {
    private Handler handler;
    private NativeAdObject mI;
    private NativeAdData mJ;
    private NativeAdListener mK;
    private NativeAdView mL;
    private MediaView mM;
    private q mN;
    private List<View> mO;
    private NativeAdView.a mP;
    private NativeAdRequest.CreativeType mQ;
    private boolean eW = false;
    private int mR = 1;
    private int mS = 0;

    public @interface b {
    }

    public @interface c {
    }

    public NativeAd(Context context, String str) {
        this.mI = g(context, str);
        com.appnext.nativeads.b.cQ().a(null);
        this.mP = new NativeAdView.a() {
            @Override
            public void h(int i) {
                f.W("percent " + i);
                if (i > 50 && !NativeAd.this.eW && NativeAd.this.handler != null) {
                    NativeAd.this.handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            if (NativeAd.this.mL != null && NativeAd.this.mL.getVisiblePercent(NativeAd.this.mL) > 50 && !NativeAd.this.eW) {
                                NativeAd.this.as();
                            }
                        }
                    }, Integer.parseInt(com.appnext.nativeads.b.cQ().get("postpone_impression_sec")) * 1000);
                }
            }
        };
        this.mN = new q(context, new q.a() {
            @Override
            public void K(String str2) {
            }

            @Override
            public Ad cL() {
                return NativeAd.this.mI;
            }

            @Override
            public AppnextAd cM() {
                return NativeAd.this.mJ;
            }

            @Override
            public o cN() {
                return com.appnext.nativeads.b.cQ();
            }
        });
        this.mO = new ArrayList();
        this.handler = new Handler();
    }

    public void loadAd(NativeAdRequest nativeAdRequest) {
        if (this.handler != null) {
            final NativeAdRequest nativeAdRequest2 = new NativeAdRequest(nativeAdRequest);
            this.mI.setCategories(nativeAdRequest2.getCategories());
            this.mI.setPostback(nativeAdRequest2.getPostback());
            this.mI.setMinVideoLength(nativeAdRequest2.getMinVideoLength());
            this.mI.setMaxVideoLength(nativeAdRequest2.getMaxVideoLength());
            this.mQ = nativeAdRequest2.getCreativeType();
            K("caching_" + nativeAdRequest2.getCachingPolicy());
            com.appnext.nativeads.c.cR().a(this.mI.getContext(), this.mI, this.mI.getPlacementID(), new b.a() {
                @Override
                public <T> void a(T t) {
                    if (NativeAd.this.handler != null) {
                        NativeAd.this.eW = false;
                        if (nativeAdRequest2.getVideoLength() == NativeAdRequest.VideoLength.DEFAULT) {
                            nativeAdRequest2.setVideoLength(NativeAdRequest.VideoLength.fromInt(Integer.parseInt(com.appnext.nativeads.b.cQ().get("default_video_length"))));
                        }
                        if (nativeAdRequest2.getVideoQuality() == NativeAdRequest.VideoQuality.DEFAULT) {
                            nativeAdRequest2.setVideoQuality(NativeAdRequest.VideoQuality.fromInt(Integer.parseInt(com.appnext.nativeads.b.cQ().get("default_video_quality"))));
                        }
                        AppnextAd appnextAd = null;
                        try {
                            appnextAd = com.appnext.nativeads.c.cR().a(NativeAd.this.mI.getContext(), NativeAd.this.mI, nativeAdRequest2);
                        } catch (Throwable th) {
                        }
                        if (appnextAd == null) {
                            if (NativeAd.this.mK != null) {
                                NativeAd.this.K("error_no_ads");
                                NativeAd.this.mK.onError(NativeAd.this, new AppnextError(AppnextError.NO_ADS));
                                return;
                            }
                            return;
                        }
                        NativeAd.this.mJ = new NativeAdData(appnextAd);
                        try {
                            String a2 = com.appnext.nativeads.c.cR().a(nativeAdRequest2, NativeAd.this.mJ);
                            if (!a2.equals("")) {
                                NativeAd.this.mJ.aY(a2);
                            } else {
                                f.W("empty video");
                            }
                        } catch (Throwable th2) {
                            th2.printStackTrace();
                        }
                        if (NativeAd.this.mM != null) {
                            NativeAd.this.mM.a(NativeAd.this, NativeAd.this.mJ, NativeAd.this.a(NativeAd.this.mQ));
                        }
                        if (NativeAd.this.mL != null) {
                            NativeAd.this.mL.a(NativeAd.this, NativeAd.this.mJ, NativeAd.this.mP);
                        }
                        if (NativeAd.this.mK != null) {
                            NativeAd.this.mK.onAdLoaded(NativeAd.this);
                        }
                    }
                }

                @Override
                public void error(String str) {
                    if (NativeAd.this.mK != null) {
                        if (str == null || str.equals(AppnextError.NO_ADS) || str.equals(AppnextError.INTERNAL_ERROR)) {
                            NativeAd.this.K("error_no_ads");
                            NativeAd.this.mK.onError(NativeAd.this, new AppnextError(AppnextError.NO_ADS));
                            return;
                        }
                        NativeAd.this.K("error_" + str.toLowerCase().replace(" ", EventsFilesManager.ROLL_OVER_FILE_NAME_SEPARATOR));
                        NativeAd.this.mK.onError(NativeAd.this, new AppnextError(str));
                    }
                }
            }, nativeAdRequest2);
        }
    }

    public MediaView.MediaType a(NativeAdRequest.CreativeType creativeType) {
        return creativeType == NativeAdRequest.CreativeType.STATIC_ONLY ? MediaView.MediaType.STATIC : MediaView.MediaType.VIDEO;
    }

    protected NativeAdObject g(Context context, String str) {
        return new NativeAdObject(context, str);
    }

    public boolean isLoaded() {
        return (this.mJ == null || this.mI == null || !this.mI.isAdLoaded()) ? false : true;
    }

    public void setAdListener(NativeAdListener nativeAdListener) {
        this.mK = nativeAdListener;
    }

    public String getCategories() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getCategories();
    }

    public String getAdDescription() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getAdDescription();
    }

    public String getAdTitle() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getAdTitle();
    }

    public String getCTAText() {
        if (this.mJ == null) {
            return null;
        }
        if (f.c(this.mI.getContext(), this.mJ.getAdPackage())) {
            return "Open";
        }
        return this.mJ.getButtonText();
    }

    public String getIconURL() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getImageURL();
    }

    public String getWideImageURL() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getWideImageURL();
    }

    public String getVideoUrl() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getSelectedVideo();
    }

    public String getBannerID() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getBannerID();
    }

    public String getCountry() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getCountry();
    }

    public String getSupportedVersion() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getSupportedVersion();
    }

    public String getStoreRating() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getStoreRating();
    }

    public String getStoreDownloads() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getStoreDownloads();
    }

    public String getAppSize() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getAppSize();
    }

    public String getAppPackageName() {
        if (this.mJ == null) {
            return null;
        }
        return this.mJ.getAdPackage();
    }

    public float getECPM() {
        if (this.mJ == null) {
            return 0.0f;
        }
        return this.mJ.getECPM();
    }

    public float getPPR() {
        if (this.mJ == null) {
            return 0.0f;
        }
        return this.mJ.getPPR();
    }

    public void setMediaView(MediaView mediaView) {
        this.mM = mediaView;
        if (this.mJ != null && mediaView != null) {
            mediaView.a(this, this.mJ, a(this.mQ));
        }
    }

    public MediaView getMediaView() {
        return this.mM;
    }

    public void setNativeAdView(NativeAdView nativeAdView) {
        this.mL = nativeAdView;
        if (this.mJ != null) {
            this.mL.a(this, this.mJ, this.mP);
        }
    }

    public void as() {
        if (this.mJ != null) {
            this.eW = true;
            K("impression_event");
            this.mN.d(this.mJ);
            j.cD().q(this.mJ.getBannerID(), this.mI.getPlacementID());
            j.cD().c(Integer.parseInt(com.appnext.nativeads.b.cQ().get("banner_expiration_time")));
            if (Boolean.parseBoolean(com.appnext.nativeads.b.cQ().get("pview"))) {
                this.handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        NativeAd.this.mN.a(NativeAd.this.mJ, NativeAd.this.mJ.getAppURL(), null);
                    }
                }, Integer.parseInt(com.appnext.nativeads.b.cQ().get("postpone_vta_sec")) * 1000);
            }
            if (this.mK != null) {
                this.mK.adImpression(this);
            }
            if (Boolean.parseBoolean(com.appnext.nativeads.b.cQ().get("fq_control")) && this.mI != null && this.mI.fq_status) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            f.a("https://www.fqtag.com/pixel.cgi?org=TkBXEI5C3FBIr4zXwnmK&p=" + NativeAd.this.mI.getPlacementID() + "&a=" + NativeAd.this.mJ.getBannerID() + "&cmp=" + NativeAd.this.mJ.getCampaignID() + "&fmt=banner&dmn=" + NativeAd.this.mJ.getAdPackage() + "&ad=&rt=displayImg&gid=" + f.v(NativeAd.this.mI.getContext()) + "&aid=&applng=" + Locale.getDefault().toString() + "&app=" + NativeAd.this.mI.getContext().getPackageName() + "&c1=100&c2=" + NativeAd.this.mI.getTID() + "&c3=" + NativeAd.this.mI.getAUID() + "&c4=" + NativeAd.this.mI.getVID() + "&sl=1&fq=1", (HashMap<String, String>) null);
                        } catch (Throwable th) {
                            f.c(th);
                        }
                    }
                }).start();
            }
        }
    }

    public NativeAdView getNativeAdView() {
        return this.mL;
    }

    public void registerClickableViews(View view) {
        ArrayList<View> arrayList = new ArrayList<>();
        a(arrayList, view);
        registerClickableViews(arrayList);
    }

    public void registerClickableViews(List<View> list) {
        if (list == null) {
            throw new IllegalArgumentException("List cannot be null");
        }
        if (list.size() == 0) {
            throw new IllegalArgumentException("List cannot be empty");
        }
        a aVar = new a();
        for (View view : list) {
            if (!(view instanceof PrivacyIcon) && !(view instanceof com.appnext.b.a) && !(view instanceof MediaView.a)) {
                this.mO.add(view);
                view.setOnClickListener(aVar);
            }
        }
    }

    private void a(ArrayList<View> arrayList, View view) {
        if (!(view instanceof PrivacyIcon) && !(view instanceof com.appnext.b.a)) {
            arrayList.add(view);
            if (view instanceof ViewGroup) {
                ViewGroup viewGroup = (ViewGroup) view;
                for (int i = 0; i < viewGroup.getChildCount(); i++) {
                    a(arrayList, viewGroup.getChildAt(i));
                }
            }
        }
    }

    public void downloadAndDisplayImage(final ImageView imageView, final String str) {
        if (this.handler != null) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        Bitmap aL = f.aL(str);
                        if (aL != null) {
                            final BitmapDrawable bitmapDrawable = new BitmapDrawable(NativeAd.this.mI.getContext().getResources(), aL);
                            new Handler(Looper.getMainLooper()).post(new Runnable() {
                                @Override
                                public void run() {
                                    try {
                                        imageView.setImageDrawable(bitmapDrawable);
                                    } catch (Throwable th) {
                                    }
                                }
                            });
                        }
                    } catch (Throwable th) {
                    }
                }
            }).start();
        }
    }

    public void destroy() {
        try {
            for (View view : this.mO) {
                view.setOnClickListener(null);
            }
            if (this.mO != null) {
                this.mO.clear();
            }
            if (this.mN != null) {
                this.mN.destroy();
            }
            if (this.mI != null) {
                this.mI.destroy();
            }
            if (this.mM != null) {
                this.mM.destroy();
            }
            this.handler.removeCallbacksAndMessages(null);
            this.handler = null;
            this.mP = null;
            this.mM = null;
            this.mK = null;
            this.mJ = null;
            this.mL = null;
        } catch (Exception e) {
        }
    }

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

        @Override
        public void onClick(View view) {
            if (NativeAd.this.mJ != null) {
                if (NativeAd.this.mK != null) {
                    NativeAd.this.mK.onAdClicked(NativeAd.this);
                }
                NativeAd.this.K("click_event");
                if (!NativeAd.this.eW) {
                    NativeAd.this.as();
                }
                NativeAd.this.mN.a(NativeAd.this.mJ, NativeAd.this.mJ.getAppURL(), NativeAd.this.mI.getPlacementID(), null);
            }
        }
    }

    public void setPrivacyPolicyPosition(@c int i) {
        this.mR = i;
    }

    @c
    public int getPrivacyPolicyPosition() {
        return this.mR;
    }

    public void setPrivacyPolicyColor(@b int i) {
        this.mS = i;
    }

    @b
    public int getPrivacyPolicyColor() {
        return this.mS;
    }

    public void K(String str) {
        try {
            f.a(this.mI.getContext(), this.mI.getTID(), this.mI.getVID(), this.mI.getAUID(), this.mI.getPlacementID(), str, "pub_control", this.mJ != null ? this.mJ.getBannerID() : "", this.mJ != null ? this.mJ.getCampaignID() : "");
        } catch (Throwable th) {
        }
    }

    public void i() {
        if ((Thread.currentThread().getStackTrace()[3].getFileName() + Thread.currentThread().getStackTrace()[3].getMethodName()).hashCode() == -391887959 && !this.eW) {
            as();
        }
    }
}