package com.ss.android.ugc.aweme.feed.assem.music.artistprofile;

import X.2GO;
import X.2HZ;
import X.4HR;
import X.4Ix;
import X.4Iy;
import X.4Jn;
import X.4r1;
import X.7he;
import X.9HM;
import X.B5W;
import X.C0479A4l;
import X.C0481A4n;
import X.C2202AoY;
import X.C3044B5c;
import X.C3045B5d;
import X.Crj;
import X.DWM;
import X.DaP;
import X.ISm;
import X.LeS;
import X.Lel;
import X.M12;
import X.Rc9;
import X.SsI;
import com.bytedance.covode.number.Covode;
import com.bytedance.ext_power_list.AssemListViewModel;
import com.ss.android.ugc.aweme.base.model.UrlModel;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.music.model.Music;
import com.ss.android.ugc.aweme.music.model.MusicOwnerInfo;
import com.ss.android.ugc.aweme.profile.model.FollowStatusEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import kotlin.h.b.n;
import org.greenrobot.eventbus.ThreadMode;

public final class ArtistProfileTuxSheetViewModel extends AssemListViewModel<4Ix, DaP, Long> implements 2HZ, 2GO {
    public final 4Jn LIZ = new 4Jn(true, C2202AoY.LIZIZ(this, B5W.class, "hierarchy_data_key"));
    public final Crj LIZIZ = 7he.LIZ(C3045B5d.LIZ);

    static {
        Covode.recordClassIndex(77478);
    }

    private final B5W LIZ() {
        return (B5W) this.LIZ.getValue();
    }

    private final boolean LIZIZ() {
        return ((Boolean) this.LIZIZ.getValue()).booleanValue();
    }

    public final Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(7, new Rc9(ArtistProfileTuxSheetViewModel.class, "onFollowStatus", FollowStatusEvent.class, ThreadMode.BACKGROUND, 0, false));
        return hashMap;
    }

    public final /* synthetic */ 4HR defaultState() {
        return new 4Ix();
    }

    public final void onCleared() {
        ArtistProfileTuxSheetViewModel.super.onCleared();
        SsI.LIZIZ(this);
    }

    public final void onPrepared() {
        ArtistProfileTuxSheetViewModel.super.onPrepared();
        SsI.LIZ(this);
    }

    public final void newState(DWM<DaP> dwm) {
        M12.LIZ(dwm);
        setState(new 4Iy(dwm));
    }

    @ISm(LIZ = ThreadMode.BACKGROUND)
    public final void onFollowStatus(FollowStatusEvent followStatusEvent) {
        FollowStatusEvent followStatusEvent2 = followStatusEvent;
        if (followStatusEvent2 != null) {
            List listGetAll = listGetAll();
            if (listGetAll != null) {
                int i = 0;
                for (Object next : listGetAll) {
                    int i2 = i + 1;
                    if (i < 0) {
                        LeS.LIZIZ();
                    }
                    C3044B5c b5c = (DaP) next;
                    if (b5c instanceof C3044B5c) {
                        C3044B5c b5c2 = b5c;
                        if (n.LIZ(followStatusEvent2.status.userId, b5c2.LIZIZ) && n.LIZ(followStatusEvent2.status.secUserId, b5c2.LIZJ)) {
                            listSetItemAt(i, new C3044B5c(b5c2.LIZ, b5c2.LIZIZ, b5c2.LIZJ, b5c2.LIZLLL, b5c2.LJ, b5c2.LJFF, b5c2.LJI, Integer.valueOf(followStatusEvent2.status.followStatus), b5c2.LJIIIIZZ));
                        }
                    }
                    i = i2;
                }
                return;
            }
        }
    }

    public final Object onRefresh(4r1<? super C0479A4l<Long>> r17) {
        Aweme aweme;
        Music music;
        List<MusicOwnerInfo> artistProfileList;
        String str;
        String handle;
        String nickName;
        Aweme aweme2;
        B5W LIZ2 = LIZ();
        if (LIZ2 == null || (aweme = LIZ2.LIZ) == null || (music = aweme.getMusic()) == null || (artistProfileList = music.getArtistProfileList()) == null || artistProfileList.isEmpty()) {
            return C0479A4l.LIZ.LIZ(new Exception());
        }
        C0481A4n a4n = C0479A4l.LIZ;
        ArrayList arrayList = new ArrayList(9HM.LIZ(artistProfileList, 10));
        for (MusicOwnerInfo musicOwnerInfo : artistProfileList) {
            B5W LIZ3 = LIZ();
            if (LIZ3 == null || (aweme2 = LIZ3.LIZ) == null) {
                str = null;
            } else {
                str = aweme2.getAid();
            }
            String uid = musicOwnerInfo.getUid();
            String secUid = musicOwnerInfo.getSecUid();
            UrlModel avatar = musicOwnerInfo.getAvatar();
            if (LIZIZ()) {
                handle = musicOwnerInfo.getNickName();
            } else {
                handle = musicOwnerInfo.getHandle();
            }
            boolean verified = musicOwnerInfo.getVerified();
            if (LIZIZ()) {
                nickName = musicOwnerInfo.getHandle();
            } else {
                nickName = musicOwnerInfo.getNickName();
            }
            arrayList.add(new C3044B5c(str, uid, secUid, avatar, handle, verified, nickName, musicOwnerInfo.getFollowStatus(), LIZ()));
        }
        return a4n.LIZ((List<? extends DaP>) arrayList);
    }

    public final /* synthetic */ Object onLoadMore(Object obj, 4r1 r4) {
        ((Number) obj).longValue();
        return C0479A4l.LIZ.LIZ((List<? extends DaP>) Lel.INSTANCE);
    }
}
