package com.ss.android.ugc.aweme.notification.vm;

import X.2HN;
import X.2Pr;
import X.2ce;
import X.7he;
import X.Aw4;
import X.C0295Crj;
import X.C1806Dfe;
import X.C1886Dgw;
import X.C1887Dgx;
import X.C1888Dgy;
import X.C3104E1k;
import X.C3224E6a;
import X.C3231E6h;
import X.C3238E6o;
import X.C3245E6v;
import X.C5285Euf;
import X.E2H;
import X.E6V;
import X.E6W;
import X.E6X;
import X.E6Y;
import X.E8G;
import X.E93;
import X.M12;
import android.content.Context;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.friends.model.RecommendList;
import com.ss.android.ugc.aweme.notice.repo.list.bean.MusNotice;
import com.ss.android.ugc.aweme.profile.model.User;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

public final class NotificationCombineVM extends BaseNotificationVM {
    public static final E6V LJFF = new E6V((byte) 0);
    public final C0295Crj LIZ = 7he.LIZ(C1806Dfe.LIZ);
    public boolean LIZIZ;
    public boolean LIZJ;
    public boolean LIZLLL;
    public boolean LJ;
    public WeakReference<Context> LJIIJ;
    public WeakReference<Fragment> LJIIJJI;
    public final C0295Crj LJIIL = 7he.LIZ(E6Y.LIZ);
    public final C0295Crj LJIILIIL = 7he.LIZ(C1888Dgy.LIZ);
    public final C0295Crj LJIILJJIL = 7he.LIZ(E6X.LIZ);
    public final C0295Crj LJIILL = 7he.LIZ(C1886Dgw.LIZ);
    public final C0295Crj LJIILLIIL = Aw4.LIZ(E6W.LIZ);
    public final C0295Crj LJIIZILJ = 7he.LIZ(C1887Dgx.LIZ);
    public final C0295Crj LJIJ = 7he.LIZ(C3224E6a.LIZ);

    static {
        Covode.recordClassIndex(96082);
    }

    public final 2ce<C3238E6o> LIZ() {
        return (2ce) this.LJIIL.getValue();
    }

    public final 2ce<Boolean> LIZIZ() {
        return (2ce) this.LJIILIIL.getValue();
    }

    public final 2ce<C3238E6o> LIZJ() {
        return (2ce) this.LJIILJJIL.getValue();
    }

    public final 2ce<Boolean> LIZLLL() {
        return (2ce) this.LJIILL.getValue();
    }

    public final MusNotice LJ() {
        return (MusNotice) this.LJIILLIIL.getValue();
    }

    public final List<MusNotice> LJIILLIIL() {
        return (List) this.LJIIZILJ.getValue();
    }

    public final C3231E6h LJIIZILJ() {
        return (C3231E6h) this.LJIJ.getValue();
    }

    public final void onCleared() {
        LJIIZILJ();
    }

    public final E93 LJIILJJIL() {
        Context context;
        this.LIZIZ = C5285Euf.LIZ.LJFF().LIZJ();
        if (LJI() != C3104E1k.LIZ.LIZ()) {
            return E93.GONE;
        }
        E2H e2h = E2H.CONTACTS;
        WeakReference<Context> weakReference = this.LJIIJ;
        Fragment fragment = null;
        if (weakReference != null) {
            context = (Context) weakReference.get();
        } else {
            context = null;
        }
        WeakReference<Fragment> weakReference2 = this.LJIIJJI;
        if (weakReference2 != null) {
            fragment = (Fragment) weakReference2.get();
        }
        return e2h.decideDisplay(context, fragment);
    }

    public final int LIZ(String str) {
        return LJIIZILJ().LIZ(str);
    }

    public final 2Pr LIZ(Context context) {
        if (context == null) {
            return null;
        }
        this.LJIIJ = new WeakReference<>(context);
        return 2Pr.LIZ;
    }

    public final 2Pr LIZ(Fragment fragment) {
        if (fragment == null) {
            return null;
        }
        this.LJIIJJI = new WeakReference<>(fragment);
        return 2Pr.LIZ;
    }

    public final C3245E6v LIZ(List<? extends MusNotice> list, C3238E6o e6o) {
        M12.LIZ(e6o);
        ArrayList arrayList = new ArrayList();
        if (list != null) {
            arrayList.addAll(list);
        }
        ArrayList arrayList2 = new ArrayList();
        if (LJIILJJIL() == E93.BOTTOM) {
            arrayList2.add(LJ());
        }
        RecommendList recommendList = e6o.LIZ;
        boolean z = false;
        if (recommendList != null) {
            List<User> inviterList = recommendList.getInviterList();
            if (inviterList != null) {
                for (User e8g : inviterList) {
                    arrayList2.add(new E8G(2011, e8g, 12));
                }
            }
            List<User> userList = recommendList.getUserList();
            if (userList != null && !userList.isEmpty()) {
                for (User e8g2 : userList) {
                    arrayList2.add(new E8G(2001, e8g2, 12));
                }
            }
        }
        if (!arrayList2.isEmpty()) {
            arrayList2.add(0, new E8G(2000, (User) null, 14));
        }
        ArrayList arrayList3 = new ArrayList();
        arrayList3.addAll(arrayList2);
        if (arrayList.isEmpty() && (!arrayList3.isEmpty())) {
            MusNotice musNotice = new MusNotice(false, 1, (2HN) null);
            musNotice.type = 2003;
            arrayList.add(musNotice);
        }
        arrayList.addAll(arrayList3);
        RecommendList recommendList2 = e6o.LIZ;
        if (recommendList2 != null && recommendList2.hasMore()) {
            z = true;
        }
        return new C3245E6v(arrayList, arrayList3, z);
    }
}
