翰林优商.apk(点击下载) / ZjNativeAdContainer.java


package com.zj.zjsdk.ad.natives;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.zj.zjsdk.a.a.b;

public class ZjNativeAdContainer extends FrameLayout {
    private ViewGroup a;
    private Context b;

    public ZjNativeAdContainer(Context context) {
        super(context);
    }

    public ZjNativeAdContainer(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.b = context;
        a();
    }

    public ZjNativeAdContainer(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    public ZjNativeAdContainer(Context context, AttributeSet attributeSet, int i, int i2) {
        super(context, attributeSet, i, i2);
    }

    private void a() {
        b bVar = new b(this.b);
        ViewGroup a2 = bVar.a();
        this.a = a2;
        super.addView(a2, bVar.b());
    }

    private boolean a(View view) {
        try {
            return Class.forName("com.qq.e.ads.nativ.widget.NativeAdContainer").isInstance(view);
        } catch (Throwable unused) {
            return false;
        }
    }

    @Override // android.view.ViewGroup
    public void addView(View view, ViewGroup.LayoutParams layoutParams) {
        if (a(view)) {
            super.addView(view, layoutParams);
            return;
        }
        ViewGroup viewGroup = this.a;
        if (viewGroup != null) {
            viewGroup.addView(view, layoutParams);
        }
    }

    public ViewGroup getContainer() {
        return this.a;
    }

    public void removeView(View view) {
        super.removeView(view);
        if (a(view)) {
            super.removeView(view);
            return;
        }
        ViewGroup viewGroup = this.a;
        if (viewGroup != null) {
            viewGroup.removeView(view);
        }
    }

    public void updateViewLayout(View view, ViewGroup.LayoutParams layoutParams) {
        if (a(view)) {
            super.updateViewLayout(view, layoutParams);
            return;
        }
        ViewGroup viewGroup = this.a;
        if (viewGroup != null) {
            viewGroup.updateViewLayout(view, layoutParams);
        }
    }
}