package com.ss.android.ugc.aweme.comment.adapter;

import X.0CH;
import X.0CM;
import X.0HH;
import X.2Pr;
import X.2ce;
import X.2te;
import X.2th;
import X.7he;
import X.A6Q;
import X.BT2;
import X.C0521A6b;
import X.C0522A6c;
import X.C1850Ais;
import X.C1853Aiv;
import X.C1855Aix;
import X.C1857Aiz;
import X.C1859Aj1;
import X.C1864Aj6;
import X.C1871AjD;
import X.C1876AjI;
import X.C1878AjK;
import X.C1880AjM;
import X.C3053B5l;
import X.C4348Bi4;
import X.Crj;
import X.E3l;
import X.E3n;
import X.E4U;
import X.M12;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.powerlist.PowerCell;
import com.bytedance.lighten.loader.SmartImageView;
import com.bytedance.router.SmartRoute;
import com.bytedance.router.SmartRouter;
import com.ss.android.ugc.aweme.comment.viewmodel.LikeListVM;
import com.ss.android.ugc.aweme.friends.model.MutualStruct;
import com.ss.android.ugc.aweme.friends.model.MutualUser;
import com.ss.android.ugc.aweme.profile.model.MatchedFriendStruct;
import com.ss.android.ugc.aweme.profile.model.User;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import kotlin.h.b.n;
import org.json.JSONObject;

public final class LikeCell extends PowerCell<C0521A6b> {
    public static final C1876AjI LIZ = new C1876AjI((byte) 0);
    public final Crj LIZIZ = 7he.LIZ(C1871AjD.LIZ);
    public final Crj LJIIIZ = 7he.LIZ(new A6Q(this));
    public final Crj LJIIJ = 7he.LIZ(new C1855Aix(this));
    public final Crj LJIIJJI = 7he.LIZ(new C1853Aiv(this));
    public final Crj LJIIL = 7he.LIZ(new C1859Aj1(this));
    public final Crj LJIILIIL = 7he.LIZ(new C1857Aiz(this));
    public final Crj LJIILJJIL = 7he.LIZ(new C1864Aj6(this));
    public final 0CM<Boolean> LJIILL = new C1850Ais(this);

    static {
        Covode.recordClassIndex(56701);
    }

    private final LikeListVM LIZLLL() {
        return (LikeListVM) this.LJIIIZ.getValue();
    }

    private final SmartImageView LJ() {
        return (SmartImageView) this.LJIIJ.getValue();
    }

    private final BT2 LJFF() {
        return (BT2) this.LJIIL.getValue();
    }

    public final C1880AjM LIZ() {
        return (C1880AjM) this.LJIILIIL.getValue();
    }

    public final void bF_() {
        LikeCell.super.bF_();
        LIZLLL().LJIIIIZZ().removeObserver(this.LJIILL);
    }

    public final void LIZIZ() {
        User user;
        C0521A6b a6b = this.LIZLLL;
        if (a6b != null && (user = a6b.LIZ) != null && !LIZLLL().LJII().contains(user.getUid()) && LIZ(E3n.SHOW)) {
            Set<String> LJII = LIZLLL().LJII();
            String uid = user.getUid();
            n.LIZIZ(uid, "");
            LJII.add(uid);
        }
    }

    public final void bE_() {
        LikeCell.super.bE_();
        2ce<Boolean> LJIIIIZZ = LIZLLL().LJIIIIZZ();
        View view = this.itemView;
        n.LIZIZ(view, "");
        0CH context = view.getContext();
        Objects.requireNonNull(context, "null cannot be cast to non-null type androidx.lifecycle.LifecycleOwner");
        LJIIIIZZ.observe(context, this.LJIILL);
        if (n.LIZ(LIZLLL().LJIIIIZZ().getValue(), true)) {
            LIZIZ();
        }
        C0521A6b a6b = this.LIZLLL;
        if (a6b != null && a6b.LIZJ) {
            this.itemView.postDelayed(new C0522A6c(this), 150);
        }
    }

    public final void LIZJ() {
        String str;
        C0521A6b a6b = this.LIZLLL;
        if (a6b != null) {
            User user = a6b.LIZ;
            C3053B5l b5l = new C3053B5l();
            b5l.LJFF(a6b.LIZIZ.LIZIZ);
            b5l.LJIILL(a6b.LIZIZ.LIZJ);
            b5l.LIZ("click_head");
            b5l.LJJJLIIL = "like_list";
            b5l.LJJJLL = "like_list";
            b5l.LJ = a6b.LIZIZ.LIZ;
            b5l.LJJJJZ = C1878AjK.LIZ.LIZ(user.getFollowStatus(), user.getFollowerStatus());
            b5l.LJJJJZI = "post";
            b5l.LJFF();
            LIZ(E3n.ENTER_PROFILE);
            if (LIZ(user)) {
                try {
                    MatchedFriendStruct matchedFriendStruct = user.getMatchedFriendStruct();
                    JSONObject jSONObject = new JSONObject();
                    jSONObject.put("scene_type", E4U.CARD);
                    jSONObject.put("position", "like_list");
                    String recType = user.getRecType();
                    if (recType == null) {
                        recType = "";
                    }
                    jSONObject.put("rec_type", recType);
                    String relationType = matchedFriendStruct.getRelationType();
                    if (relationType == null) {
                        relationType = "";
                    }
                    jSONObject.put("relation_type", relationType);
                    jSONObject.put("to_user_id", user.getUid());
                    String requestId = user.getRequestId();
                    if (requestId == null) {
                        requestId = "";
                    }
                    jSONObject.put("req_id", requestId);
                    C4348Bi4.LIZ(jSONObject, user.getSocialInfo());
                    str = jSONObject.toString();
                    n.LIZIZ(str, "");
                    try {
                        2te.constructor-impl(2Pr.LIZ);
                    } catch (Throwable th) {
                        th = th;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    str = "";
                    2te.constructor-impl(2th.LIZ(th));
                    View view = this.itemView;
                    n.LIZIZ(view, "");
                    Context context = view.getContext();
                    SmartRoute buildRoute = SmartRouter.buildRoute(context, "aweme://user/profile/" + user.getUid());
                    buildRoute.withParam("sec_user_id", user.getSecUid());
                    buildRoute.withParam("event_keys", str);
                    buildRoute.open();
                }
            } else {
                str = "";
            }
            View view2 = this.itemView;
            n.LIZIZ(view2, "");
            Context context2 = view2.getContext();
            SmartRoute buildRoute2 = SmartRouter.buildRoute(context2, "aweme://user/profile/" + user.getUid());
            buildRoute2.withParam("sec_user_id", user.getSecUid());
            buildRoute2.withParam("event_keys", str);
            buildRoute2.open();
        }
    }

    public final View LIZ(ViewGroup viewGroup) {
        M12.LIZ(viewGroup);
        View LIZ2 = 0HH.LIZ(LayoutInflater.from(viewGroup.getContext()), 2131558808, viewGroup, false);
        n.LIZIZ(LIZ2, "");
        return LIZ2;
    }

    private final boolean LIZ(User user) {
        List<MutualUser> list;
        String recommendReason;
        MatchedFriendStruct matchedFriendStruct = user.getMatchedFriendStruct();
        if (matchedFriendStruct != null) {
            MutualStruct mMutualStruct = matchedFriendStruct.getMMutualStruct();
            if (mMutualStruct != null) {
                list = mMutualStruct.getUserList();
            } else {
                list = null;
            }
            if ((list == null || list.isEmpty()) && ((recommendReason = matchedFriendStruct.getRecommendReason()) == null || recommendReason.length() == 0)) {
                return false;
            }
            return true;
        }
        return false;
    }

    public final boolean LIZ(E3n e3n) {
        C0521A6b a6b = this.LIZLLL;
        if (a6b == null || !LIZ(a6b.LIZ)) {
            return false;
        }
        a6b.LIZ.getMatchedFriendStruct();
        E3l e3l = new E3l();
        e3l.LIZ(a6b.LIZIZ.LIZJ);
        e3l.LIZIZ = e3n;
        e3l.LJIJI(a6b.LIZIZ.LIZ);
        e3l.LJJJJZI = "post";
        e3l.LIZ(a6b.LIZ);
        e3l.LIZ = E4U.CARD;
        e3l.LJIILLIIL("like_list");
        e3l.LJFF();
        return true;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:13:0x008b, code lost:
        if (r6 != null) goto L_0x008d;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final /* synthetic */ void LIZ(X.DaP r8) {
        /*
            r7 = this;
            X.A6b r8 = (X.C0521A6b) r8
            X.M12.LIZ(r8)
            com.ss.android.ugc.aweme.comment.adapter.LikeCell.super.LIZ(r8)
            com.ss.android.ugc.aweme.profile.model.User r3 = r8.LIZ
            com.ss.android.ugc.aweme.base.model.UrlModel r0 = r3.getAvatarThumb()
            X.B9H r0 = X.3EX.LIZ(r0)
            X.QJt r2 = X.QHW.LIZ(r0)
            java.lang.String r0 = "LikeCell"
            r2.LIZ(r0)
            com.bytedance.lighten.loader.SmartImageView r0 = r7.LJ()
            r2.LJJIIZ = r0
            X.JIy r0 = new X.JIy
            r0.<init>()
            r1 = 1
            r0.LIZ = r1
            X.JIz r0 = r0.LIZ()
            r2.LJIL = r0
            r2.LIZJ = r1
            r2.LIZJ()
            com.bytedance.lighten.loader.SmartImageView r1 = r7.LJ()
            X.Aj3 r0 = new X.Aj3
            r0.<init>(r7)
            r1.setOnClickListener(r0)
            android.view.View r1 = r7.itemView
            X.Aj4 r0 = new X.Aj4
            r0.<init>(r7)
            r1.setOnClickListener(r0)
            java.lang.String r1 = r3.getUserDisplayName()
            r5 = 0
            if (r1 == 0) goto L_0x0057
            int r0 = r1.length()
            if (r0 != 0) goto L_0x0062
        L_0x0057:
            X.A6g r0 = r8.LIZIZ
            java.lang.String r0 = r0.LIZJ
            java.lang.String r1 = X.C02279ut.LIZ((com.ss.android.ugc.aweme.profile.model.User) r3, (java.lang.String) r0)
            r3.setUserDisplayName(r1)
        L_0x0062:
            X.Crj r0 = r7.LJIIJJI
            java.lang.Object r0 = r0.getValue()
            X.Qeg r0 = (X.Qeg) r0
            java.lang.String r4 = ""
            kotlin.h.b.n.LIZIZ(r0, r4)
            r0.setText(r1)
            com.ss.android.ugc.aweme.profile.model.MatchedFriendStruct r6 = r3.getMatchedFriendStruct()
            r0 = 0
            if (r6 == 0) goto L_0x0099
            com.ss.android.ugc.aweme.friends.model.MutualStruct r0 = r6.getMMutualStruct()
            if (r0 == 0) goto L_0x008d
            java.util.List r0 = r0.getUserList()
            if (r0 == 0) goto L_0x008b
            boolean r0 = r0.isEmpty()
            if (r0 == 0) goto L_0x00fc
        L_0x008b:
            if (r6 == 0) goto L_0x0099
        L_0x008d:
            java.lang.String r0 = r6.getRecommendReason()
            if (r0 == 0) goto L_0x0099
            int r0 = r0.length()
            if (r0 != 0) goto L_0x00db
        L_0x0099:
            X.BT2 r1 = r7.LJFF()
            kotlin.h.b.n.LIZIZ(r1, r4)
            r0 = 8
            r1.setVisibility(r0)
        L_0x00a5:
            X.BT2 r2 = r7.LJFF()
            android.view.View r0 = r7.itemView
            kotlin.h.b.n.LIZIZ(r0, r4)
            android.content.res.Resources r1 = r0.getResources()
            r0 = 2131099758(0x7f06006e, float:1.7811878E38)
            int r0 = r1.getColor(r0)
            r2.setTextColor(r0)
            X.AjM r1 = r7.LIZ()
            X.Crj r0 = r7.LIZIZ
            java.lang.Object r0 = r0.getValue()
            java.lang.Boolean r0 = (java.lang.Boolean) r0
            boolean r0 = r0.booleanValue()
            r1.setShouldShowMessageText(r0)
            X.Crj r0 = r7.LJIILJJIL
            java.lang.Object r0 = r0.getValue()
            X.EIT r0 = (X.EIT) r0
            r0.LIZ(r3)
            return
        L_0x00db:
            X.BT2 r0 = r7.LJFF()
            r0.LIZ()
            X.BT2 r0 = r7.LJFF()
            X.Qeg r1 = r0.getTvDesc()
            java.lang.String r0 = r6.getRecommendReason()
            r1.setText(r0)
            X.BT2 r0 = r7.LJFF()
            kotlin.h.b.n.LIZIZ(r0, r4)
            r0.setVisibility(r5)
            goto L_0x00a5
        L_0x00fc:
            X.BT2 r2 = r7.LJFF()
            com.ss.android.ugc.aweme.friends.model.MutualStruct r1 = r6.getMMutualStruct()
            r0 = 4
            r2.LIZ((com.ss.android.ugc.aweme.friends.model.MutualStruct) r1, (int) r0)
            X.BT2 r0 = r7.LJFF()
            kotlin.h.b.n.LIZIZ(r0, r4)
            r0.setVisibility(r5)
            goto L_0x00a5
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.comment.adapter.LikeCell.LIZ(X.DaP):void");
    }
}
