package com.ss.android.ugc.aweme.story.interaction.fragment;

import X.0CM;
import X.0EB;
import X.0HH;
import X.1hK;
import X.2yN;
import X.33g;
import X.9EH;
import X.AnonymousClass9ly;
import X.AnonymousClass9mN;
import X.AnonymousClass9wY;
import X.C02659wf;
import X.C0729AEb;
import X.C0733AEf;
import X.C0736AEi;
import X.C1393AbV;
import X.Cl7;
import X.ClS;
import X.Cwu;
import X.DZp;
import X.DaU;
import X.M12;
import X.Qeg;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.base.fragment.AmeBaseFragment;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.profile.model.User;
import com.ss.android.ugc.aweme.story.interaction.cell.StoryViewerAndLikerCell;
import com.ss.android.ugc.aweme.story.interaction.vm.StoryLikedListViewModel;
import kotlin.h.b.n;

public final class StoryLikerListFragment extends AmeBaseFragment implements 0CM<33g>, AnonymousClass9wY, C02659wf {
    public static final C0733AEf LJIIJ = new C0733AEf((byte) 0);
    public StoryLikedListViewModel LIZ;
    public String LIZIZ = "";
    public Aweme LIZJ;
    public int LIZLLL;
    public AnonymousClass9mN LJ;
    public C0736AEi LJIIIZ;
    public DaU<Long> LJIIJJI;
    public boolean LJIIL;
    public AnonymousClass9ly LJIILIIL;
    public SparseArray LJIILJJIL;

    static {
        Covode.recordClassIndex(117806);
    }

    public final void LIZ(int i) {
    }

    public final void LIZ(boolean z) {
    }

    public final View LIZIZ(int i) {
        if (this.LJIILJJIL == null) {
            this.LJIILJJIL = new SparseArray();
        }
        View view = (View) this.LJIILJJIL.get(i);
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJIILJJIL.put(i, findViewById);
        return findViewById;
    }

    public final void LIZIZ(boolean z) {
    }

    public final String LJIIIIZZ() {
        return null;
    }

    public final int LJIIIZ() {
        return -1;
    }

    public final boolean LJIIJ() {
        return false;
    }

    public final /* bridge */ /* synthetic */ AmeBaseFragment LIZ() {
        return this;
    }

    private final void LJFF() {
        DaU<Long> daU = this.LJIIJJI;
        if (daU == null) {
            n.LIZ("");
        }
        daU.LIZLLL.LIZLLL();
    }

    public final RecyclerView LIZLLL() {
        DZp LIZIZ2 = LIZIZ(2131367123);
        n.LIZIZ(LIZIZ2, "");
        return LIZIZ2;
    }

    public final void LJIIJJI() {
        if (this.LJIIL) {
            this.LJIIL = false;
            LJI();
        }
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        SparseArray sparseArray = this.LJIILJJIL;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    private final void LJ() {
        StoryLikedListViewModel storyLikedListViewModel = this.LIZ;
        if (storyLikedListViewModel == null) {
            n.LIZ("");
        }
        storyLikedListViewModel.LIZ("REFRESH_STORY_LIKED_LIST_SUCCESS", this);
        storyLikedListViewModel.LIZ("REFRESH_STORY_LIKED_LIST_FAIL", this);
    }

    private final void LIZIZ() {
        String str;
        User user;
        Aweme aweme = this.LIZJ;
        AnonymousClass9ly r0 = this.LJIILIIL;
        String str2 = null;
        if (r0 != null) {
            str = r0.getEnterFrom();
        } else {
            str = null;
        }
        String str3 = this.LIZIZ;
        ClS clS = ClS.LIZIZ;
        Aweme aweme2 = this.LIZJ;
        if (aweme2 != null) {
            user = aweme2.getAuthor();
        } else {
            user = null;
        }
        int LIZ2 = clS.LIZ(user);
        Aweme aweme3 = this.LIZJ;
        if (aweme3 != null) {
            str2 = Cl7.LIZIZ(aweme3);
        }
        this.LJIIIZ = new C0736AEi(aweme, str, "like_list", str3, LIZ2, "story", str2);
    }

    public final String LJII() {
        Resources resources = 9EH.LJJIFFI.LIZ().getResources();
        int i = this.LIZLLL;
        String quantityString = resources.getQuantityString(2131689918, i, new Object[]{2yN.LIZ((long) i)});
        n.LIZIZ(quantityString, "");
        return quantityString;
    }

    private final void LIZJ() {
        StoryLikedListViewModel storyLikedListViewModel = this.LIZ;
        if (storyLikedListViewModel == null) {
            n.LIZ("");
        }
        Integer num = storyLikedListViewModel.LIZLLL.get(this.LIZIZ);
        if (num != null) {
            int intValue = num.intValue();
            if (intValue == 0) {
                LJ();
                return;
            } else if (intValue == 1) {
                LJFF();
                LJ();
                return;
            } else if (intValue == 2) {
                LJFF();
                LJ();
                return;
            } else if (intValue == 3) {
                return;
            } else {
                if (intValue == 4) {
                    LJFF();
                    return;
                }
            }
        }
        LJFF();
        LJ();
    }

    private final void LJI() {
        String str;
        String str2;
        String str3;
        AnonymousClass9ly r0 = this.LJIILIIL;
        String str4 = null;
        if (r0 != null) {
            str = r0.getEventType();
        } else {
            str = null;
        }
        if (!n.LIZ("homepage_follow", str)) {
            AnonymousClass9ly r02 = this.LJIILIIL;
            if (r02 != null) {
                str2 = r02.getEventType();
            } else {
                str2 = null;
            }
            if (!n.LIZ("homepage_hot", str2)) {
                AnonymousClass9ly r03 = this.LJIILIIL;
                if (r03 != null) {
                    str3 = r03.getEventType();
                } else {
                    str3 = null;
                }
                if (!n.LIZ("homepage_nearby", str3)) {
                    AnonymousClass9ly r04 = this.LJIILIIL;
                    if (r04 != null) {
                        str4 = r04.getEventType();
                    }
                    if (!n.LIZ("homepage_friends", str4)) {
                        LIZJ();
                        return;
                    }
                }
            }
        }
        LJ();
        StoryLikedListViewModel storyLikedListViewModel = this.LIZ;
        if (storyLikedListViewModel == null) {
            n.LIZ("");
        }
        storyLikedListViewModel.LIZ(this.LIZIZ, 0);
    }

    public final void LIZIZ(Aweme aweme) {
        this.LIZJ = aweme;
    }

    public final void LIZ(AnonymousClass9ly r1) {
        this.LJIILIIL = r1;
    }

    public final void LIZ(AnonymousClass9mN r1) {
        M12.LIZ(r1);
        this.LJ = r1;
    }

    public final void LIZJ(boolean z) {
        int i;
        Qeg LIZIZ2 = LIZIZ(2131371255);
        if (LIZIZ2 != null) {
            if (z) {
                i = 0;
            } else {
                i = 8;
            }
            LIZIZ2.setVisibility(i);
        }
    }

    public final void onActivityCreated(Bundle bundle) {
        super.onActivityCreated(bundle);
        1hK requireActivity = requireActivity();
        n.LIZIZ(requireActivity, "");
        this.LIZ = StoryLikedListViewModel.LJFF.LIZ(requireActivity, requireActivity);
        LIZIZ();
        LJI();
    }

    public final void LIZ(Aweme aweme) {
        String str;
        if (aweme == null || (str = aweme.getAid()) == null) {
            str = "";
        }
        this.LIZIZ = str;
        this.LIZJ = aweme;
        this.LJIIL = true;
        LIZIZ();
    }

    public final void LIZ(String str) {
        M12.LIZ(str);
        M12.LIZ(str);
    }

    public final /* synthetic */ void onChanged(Object obj) {
        String str;
        33g r4 = (33g) obj;
        if (r4 != null && (str = r4.LIZ) != null) {
            int hashCode = str.hashCode();
            if (hashCode != 1000683874) {
                if (hashCode == 1736731135 && str.equals("REFRESH_STORY_LIKED_LIST_FAIL")) {
                    n.LIZ(r4.LIZ(), this.LIZIZ);
                }
            } else if (str.equals("REFRESH_STORY_LIKED_LIST_SUCCESS") && n.LIZ(((Cwu) r4.LIZ()).getFirst(), this.LIZIZ)) {
                LJFF();
            }
        }
    }

    public final void onViewCreated(View view, Bundle bundle) {
        String str;
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        Qeg LIZIZ2 = LIZIZ(2131371255);
        n.LIZIZ(LIZIZ2, "");
        LIZIZ2.setVisibility(8);
        Bundle arguments = getArguments();
        if (arguments == null || (str = arguments.getString("story_id")) == null) {
            str = "";
        }
        this.LIZIZ = str;
        view.findViewById(2131364530).setText(2131827605);
        view.findViewById(2131364526).setText(2131827606);
        LIZIZ(2131367123).LIZ(new Class[]{StoryViewerAndLikerCell.class});
        RecyclerView LIZIZ3 = LIZIZ(2131367123);
        n.LIZIZ(LIZIZ3, "");
        LIZIZ3.setItemAnimator((0EB) null);
        C1393AbV abV = new C1393AbV();
        abV.LIZ = 10;
        abV.LIZIZ = false;
        this.LJIIJJI = new C0729AEb(this, abV);
        DZp LIZIZ4 = LIZIZ(2131367123);
        DaU<Long> daU = this.LJIIJJI;
        if (daU == null) {
            n.LIZ("");
        }
        LIZIZ4.LIZ(daU);
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return 0HH.LIZ(layoutInflater, 2131561401, viewGroup, false);
    }
}
