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

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


package com.appnext.nativeads;

import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import com.appnext.core.f;
import java.util.Random;
public class NativeAdView extends FrameLayout {
    private NativeAdData mB;
    private a mP;
    private NativeAd mz;
    private PrivacyIcon nf;

    public interface a {
        void h(int i);
    }

    public NativeAdView(Context context) {
        super(context);
        super.setVisibility(4);
    }

    public NativeAdView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        super.setVisibility(4);
    }

    public NativeAdView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        super.setVisibility(4);
    }

    public NativeAdView(Context context, AttributeSet attributeSet, int i, int i2) {
        super(context, attributeSet, i, i2);
        super.setVisibility(4);
    }

    private void init() {
        if (this.mz != null && this.mB != null) {
            setVisibility(0);
            this.nf = new PrivacyIcon(getContext());
            int i = 3;
            switch (this.mz.getPrivacyPolicyPosition()) {
                case 0:
                    i = 51;
                    break;
                case 1:
                    i = 53;
                    break;
                case 2:
                    i = 83;
                    break;
                case 3:
                    i = 85;
                    break;
            }
            addView(this.nf, new FrameLayout.LayoutParams(-2, -2, i));
            this.nf.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (NativeAdView.this.mz != null) {
                        try {
                            Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.appnext.com/privacy_policy/index.html?z=" + new Random().nextInt(10) + NativeAdView.this.mB.getZoneID() + new Random().nextInt(10)));
                            intent.setFlags(268435456);
                            NativeAdView.this.getContext().startActivity(intent);
                        } catch (Throwable th) {
                        }
                    }
                }
            });
            this.nf.setImageResource(R.drawable.apnxt_na_i_icon);
            if (this.mz.getPrivacyPolicyColor() == 0) {
                this.nf.setBackgroundColor(Color.parseColor("#33ffffff"));
            } else {
                this.nf.setBackgroundColor(Color.parseColor("#33000000"));
            }
            this.nf.getLayoutParams().width = f.a(getContext(), 16.0f);
            this.nf.getLayoutParams().height = f.a(getContext(), 16.0f);
            int a2 = f.a(getContext(), 2.0f);
            ((FrameLayout.LayoutParams) this.nf.getLayoutParams()).setMargins(a2, a2, a2, a2);
            getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
                @Override
                public void onScrollChanged() {
                    NativeAdView.this.k(NativeAdView.this.getVisiblePercent(NativeAdView.this));
                }
            });
        }
    }

    @Override
    public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
        super.addView(view, i, layoutParams);
        super.bringChildToFront(this.nf);
    }

    @Override
    public void removeView(View view) {
        if (view != this.nf) {
            super.removeView(view);
        }
    }

    @Override
    public void removeAllViews() {
        super.removeAllViews();
        super.addView(this.nf);
    }

    @Override
    public void bringChildToFront(View view) {
        super.bringChildToFront(view);
        if (this.nf != view) {
            super.bringChildToFront(this.nf);
        }
    }

    @Override
    public void setVisibility(int i) {
        if (this.mz != null && this.mB != null) {
            super.setVisibility(i);
            k(getVisiblePercent(this));
        }
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        bringToFront();
    }

    public void a(NativeAd nativeAd, NativeAdData nativeAdData, a aVar) {
        this.mz = nativeAd;
        this.mB = nativeAdData;
        this.mP = aVar;
        init();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (this.mz != null && this.mB != null && this.mP != null) {
            k(getVisiblePercent(this));
        }
    }

    private boolean c(View view) {
        try {
            if (getParent() == null) {
                return false;
            }
            Rect rect = new Rect();
            ((ViewGroup) getParent()).getHitRect(rect);
            return view.getLocalVisibleRect(rect);
        } catch (Throwable th) {
            f.c(th);
            return false;
        }
    }

    public int getVisiblePercent(View view) {
        if (!c(this)) {
            return 0;
        }
        Rect rect = new Rect();
        view.getGlobalVisibleRect(rect);
        return (int) (((rect.height() * rect.width()) * 100.0d) / (view.getWidth() * view.getHeight()));
    }

    public void k(int i) {
        if (getWindowVisibility() != 8 && getWindowVisibility() != 4) {
            if (this.mP != null) {
                this.mP.h(i);
            }
            if (this.mz.getMediaView() != null) {
                this.mz.getMediaView().h(i);
            }
        }
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (this.mz != null && this.mB != null && this.mP != null) {
            k(getVisiblePercent(this));
        }
    }
}