package com.ss.android.ugc.aweme.social.widget.card.permission;

import X.0HH;
import X.4ZZ;
import X.7he;
import X.C0295Crj;
import X.C1481DaP;
import X.C1970DiI;
import X.C1971DiJ;
import X.C1972DiK;
import X.C1973DiL;
import X.C1975DiN;
import X.C1983DiV;
import X.CbG;
import X.M12;
import X.Qeg;
import android.graphics.Rect;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.powerlist.PowerCell;
import com.ss.android.ugc.aweme.social.widget.card.rec.vm.SocialCardVM;
import java.util.Objects;
import kotlin.h.b.n;

public abstract class PermissionCell<T extends C1983DiV> extends PowerCell<T> implements ViewTreeObserver.OnGlobalLayoutListener {
    public SocialCardVM LIZ;
    public final C0295Crj LIZIZ = 7he.LIZ(new C1973DiL(this));
    public T LJIIIZ;
    public final boolean LJIIJ;
    public final C0295Crj LJIIJJI = 7he.LIZ(new C1971DiJ(this));
    public View LJIIL;

    static {
        Covode.recordClassIndex(114775);
    }

    public final SocialCardVM LIZ() {
        return (SocialCardVM) this.LJIIJJI.getValue();
    }

    public void LIZ(4ZZ r1) {
        M12.LIZ(r1);
    }

    public void LIZ(CbG cbG) {
        M12.LIZ(cbG);
    }

    public void LIZ(Qeg qeg) {
        M12.LIZ(qeg);
    }

    public abstract int LIZIZ();

    public void LIZIZ(Qeg qeg) {
        M12.LIZ(qeg);
    }

    public void LIZIZ(ViewGroup viewGroup) {
        M12.LIZ(viewGroup);
    }

    public void onGlobalLayout() {
        View view = this.LJIIL;
        if (view == null) {
            n.LIZ("");
        }
        if (view.getGlobalVisibleRect(new Rect())) {
            SocialCardVM LIZ2 = LIZ();
            T t = this.LJIIIZ;
            if (t == null) {
                n.LIZ("");
            }
            LIZ2.LIZ((C1481DaP) t);
            View view2 = this.LJIIL;
            if (view2 == null) {
                n.LIZ("");
            }
            view2.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    }

    /* access modifiers changed from: private */
    public void LIZ(T t) {
        M12.LIZ(t);
        this.LJIIIZ = t;
    }

    public static final /* synthetic */ C1983DiV LIZ(PermissionCell permissionCell) {
        T t = permissionCell.LJIIIZ;
        if (t == null) {
            n.LIZ("");
        }
        return t;
    }

    public final void LIZIZ(Object obj) {
        M12.LIZ(obj);
        LIZ((C1983DiV) obj);
    }

    public final View LIZ(ViewGroup viewGroup) {
        M12.LIZ(viewGroup);
        View LIZ2 = 0HH.LIZ(LayoutInflater.from(viewGroup.getContext()), LIZIZ(), viewGroup, false);
        n.LIZIZ(LIZ2, "");
        this.LJIIL = LIZ2;
        if (LIZ2 == null) {
            n.LIZ("");
        }
        4ZZ findViewById = LIZ2.findViewById(2131368421);
        Qeg findViewById2 = LIZ2.findViewById(2131368429);
        Qeg findViewById3 = LIZ2.findViewById(2131368417);
        CbG findViewById4 = LIZ2.findViewById(2131368418);
        4ZZ findViewById5 = LIZ2.findViewById(2131368416);
        Objects.requireNonNull(LIZ2, "null cannot be cast to non-null type android.view.ViewGroup");
        ViewGroup viewGroup2 = (ViewGroup) LIZ2;
        LIZIZ(viewGroup2);
        n.LIZIZ(findViewById, "");
        LIZ(findViewById);
        n.LIZIZ(findViewById2, "");
        LIZ(findViewById2);
        n.LIZIZ(findViewById3, "");
        LIZIZ(findViewById3);
        if (findViewById5 != null) {
            M12.LIZ(findViewById5);
        }
        n.LIZIZ(findViewById4, "");
        LIZ(findViewById4);
        viewGroup2.getViewTreeObserver().addOnGlobalLayoutListener(this);
        LIZ2.setOnClickListener(new C1970DiI(this));
        if (this.LJIIJ) {
            LIZ2.setOnLongClickListener(new C1972DiK(this, LIZ2));
            if (findViewById5 != null) {
                findViewById5.setVisibility(8);
            }
        } else if (findViewById5 != null) {
            findViewById5.setOnClickListener(new C1975DiN(this));
        }
        View view = this.LJIIL;
        if (view == null) {
            n.LIZ("");
        }
        return view;
    }
}
