package com.ss.android.ugc.aweme.im.sdk.chat.feature.single.ui;

import X.0CB;
import X.0CH;
import X.0CN;
import X.6Is;
import X.BZi;
import X.C1236Iep;
import X.C1436Ii3;
import X.C1460IiR;
import X.C1558Ik1;
import X.C1606Ikn;
import X.C2376IxD;
import X.C2746J7p;
import X.DuW;
import X.IA0;
import X.IBA;
import X.IW1;
import X.J84;
import X.M12;
import androidx.lifecycle.LiveData;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.im.sdk.chat.ui.fragment.ChatRoomFragment;
import com.ss.android.ugc.aweme.im.service.model.IMUser;

public final class SingleChatTitleBarComponent implements 6Is, IW1 {
    public C2746J7p LIZ;
    public LiveData<C1606Ikn> LIZIZ;
    public final C1460IiR LIZJ;
    public final ChatRoomFragment LIZLLL;
    public final C2376IxD LJ;

    static {
        Covode.recordClassIndex(84873);
    }

    public final void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_CREATE) {
            onCreate();
        } else if (r3 == 0CB.ON_RESUME) {
            onResume();
        }
    }

    @0CN(LIZ = 0CB.ON_CREATE)
    public final void onCreate() {
        IMUser fromUser = this.LIZJ.getFromUser();
        if (fromUser != null) {
            LIZ(fromUser);
        }
        if (C1236Iep.LIZIZ()) {
            this.LJ.setRightIcons(2131755406, 2131755380);
        }
        this.LJ.setOnTitlebarClickListener(new C1436Ii3(this));
    }

    @0CN(LIZ = 0CB.ON_RESUME)
    public final void onResume() {
        LiveData<C1606Ikn> liveData = this.LIZIZ;
        if (liveData != null) {
            liveData.removeObservers(this.LIZLLL);
        }
        IMUser fromUser = this.LIZJ.getFromUser();
        if (fromUser != null) {
            IBA.LIZ(fromUser.getUid(), fromUser.getSecUid(), (IA0) new C1558Ik1(fromUser, this));
        }
    }

    public final void LIZ(IMUser iMUser) {
        M12.LIZ(iMUser);
        if (DuW.LIZIZ()) {
            this.LJ.setLeftTitleVisible(true);
            this.LJ.LIZ(iMUser.getDisplayAvatar(), (J84<BZi>) null);
        } else {
            this.LJ.setLeftTitleVisible(false);
            this.LJ.LIZ(iMUser.getDisplayAvatar());
        }
        if (iMUser.getDisplayName() != null) {
            this.LJ.setTitle(iMUser.getDisplayName());
        }
    }

    public SingleChatTitleBarComponent(C1460IiR iiR, ChatRoomFragment chatRoomFragment, C2376IxD ixD) {
        M12.LIZ(iiR, chatRoomFragment, ixD);
        this.LIZJ = iiR;
        this.LIZLLL = chatRoomFragment;
        this.LJ = ixD;
    }
}
