package com.ss.android.ugc.aweme.friendstab.ui;

import X.0Bs;
import X.0Bv;
import X.0Bx;
import X.0By;
import X.0CH;
import X.0HH;
import X.1hK;
import X.2GD;
import X.2cN;
import X.2ce;
import X.2oU;
import X.2or;
import X.2ov;
import X.46i;
import X.4B5;
import X.4pG;
import X.4pn;
import X.4rR;
import X.4rS;
import X.7he;
import X.C0059Cih;
import X.C0295Crj;
import X.C1445DZp;
import X.C3736EPs;
import X.C3741EPx;
import X.C3742EPy;
import X.C4217EdR;
import X.C4222EdW;
import X.C4224EdY;
import X.C4226Eda;
import X.C4231Edf;
import X.C4233Edh;
import X.C4236Edk;
import X.C4237Edl;
import X.C4239Edn;
import X.C4240Edo;
import X.C4241Edp;
import X.C4242Edq;
import X.C4243Edr;
import X.C4244Eds;
import X.CbG;
import X.EQ3;
import X.ESC;
import X.J7F;
import X.JNj;
import X.JOF;
import X.LeS;
import X.M12;
import X.Qeg;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.LiveData;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.powerlist.PowerCell;
import com.ss.android.ugc.aweme.IAccountUserService;
import com.ss.android.ugc.aweme.friendstab.helper.FriendsEmptyPageSharePackage;
import com.ss.android.ugc.aweme.friendstab.tab.StateOwner;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Objects;
import kotlin.h.b.n;

public final class FriendsFeedEmptyPageCell extends PowerCell<EQ3> {
    public final String LIZ = "FriendsFeedEmptyChunk";
    public FriendsEmptyPageMainSectionVM LIZIZ;
    public List<Integer> LJIIIZ;
    public List<Integer> LJIIJ;
    public ListIterator<Integer> LJIIJJI;
    public ObjectAnimator LJIIL;
    public boolean LJIILIIL;
    public boolean LJIILJJIL;
    public 2oU LJIILL = 2oU.EMPTY_STATE;
    public 2cN LJIILLIIL;
    public final C4233Edh LJIIZILJ = new C4233Edh(this);
    public int LJIJ = Integer.MIN_VALUE;
    public final C0295Crj LJIJI = 7he.LIZ(new C4242Edq(this));
    public C1445DZp LJIJJ;
    public final C0295Crj LJIJJLI = 7he.LIZ(C4243Edr.LIZ);
    public final Handler LJIL = new Handler(Looper.getMainLooper());
    public final C0295Crj LJJ = 7he.LIZ(C4239Edn.LIZ);
    public Rect LJJI = new Rect();
    public final C4241Edp LJJIFFI = new C4241Edp(this);

    static {
        Covode.recordClassIndex(81592);
    }

    public final FriendsEmptyPageRootVM LIZ() {
        return (FriendsEmptyPageRootVM) this.LJIJI.getValue();
    }

    public final AnimatorSet LIZIZ() {
        return (AnimatorSet) this.LJIJJLI.getValue();
    }

    public final boolean LIZJ() {
        return ((Boolean) this.LJJ.getValue()).booleanValue();
    }

    public final void bF_() {
        super.bF_();
        this.LJIILIIL = false;
    }

    public final void bE_() {
        super.bE_();
        this.LJIILIIL = true;
        LIZLLL();
    }

    public final void bK_() {
        super.bK_();
        if (LIZJ()) {
            LJ();
        }
    }

    private final void LJ() {
        this.LJIIZILJ.LIZIZ();
        LIZIZ().cancel();
        ObjectAnimator objectAnimator = this.LJIIL;
        if (objectAnimator == null) {
            n.LIZ("");
        }
        LIZ(objectAnimator);
        ObjectAnimator objectAnimator2 = this.LJIIL;
        if (objectAnimator2 == null) {
            n.LIZ("");
        }
        objectAnimator2.cancel();
    }

    public final void bC_() {
        2or.LIZ("friends_tab_empty", 2ov.CANCEL, 4);
        if (this.LJIILJJIL) {
            super.bC_();
            this.LJIILJJIL = false;
            if (!LIZJ()) {
                LIZIZ().cancel();
                this.LJIL.removeCallbacksAndMessages((Object) null);
                return;
            }
            LJ();
        }
    }

    public final void bL_() {
        super.bL_();
        C1445DZp dZp = this.LJIJJ;
        if (dZp == null) {
            n.LIZ("");
        }
        dZp.LIZIZ(this.LJJIFFI);
        if (!LIZJ()) {
            LIZIZ().cancel();
            ObjectAnimator objectAnimator = this.LJIIL;
            if (objectAnimator == null) {
                n.LIZ("");
            }
            LIZ(objectAnimator);
            ObjectAnimator objectAnimator2 = this.LJIIL;
            if (objectAnimator2 == null) {
                n.LIZ("");
            }
            objectAnimator2.cancel();
            return;
        }
        LJ();
    }

    public final void LIZLLL() {
        View view = this.itemView;
        n.LIZIZ(view, "");
        CbG findViewById = view.findViewById(2131365213);
        View view2 = this.itemView;
        n.LIZIZ(view2, "");
        4pG findViewById2 = view2.findViewById(2131367356);
        FriendsEmptyPageMainSectionVM friendsEmptyPageMainSectionVM = this.LIZIZ;
        if (friendsEmptyPageMainSectionVM == null) {
            n.LIZ("");
        }
        boolean LIZIZ2 = friendsEmptyPageMainSectionVM.LIZIZ();
        if (this.LJIILIIL && findViewById != null && findViewById2 != null && LIZIZ2) {
            boolean z = true;
            findViewById.getGlobalVisibleRect(this.LJJI);
            FriendsEmptyPageRootVM LIZ2 = LIZ();
            if (LIZ2 != null) {
                if (this.LJJI.bottom < 0) {
                    z = false;
                }
                LIZ2.LIZ(z);
            }
            FriendsEmptyPageRootVM LIZ3 = LIZ();
            if (LIZ3 != null) {
                CharSequence text = findViewById.getText();
                n.LIZIZ(text, "");
                LIZ3.LIZ(text);
            }
            this.LJJI.set(0, 0, 0, 0);
        }
    }

    private final void LJFF() {
        Fragment bA_ = bA_();
        if (bA_ == null) {
            n.LIZIZ();
        }
        Objects.requireNonNull(bA_, "null cannot be cast to non-null type androidx.fragment.app.Fragment");
        1hK activity = bA_.getActivity();
        if (activity != null) {
            C4244Eds eds = FriendsEmptyPageSharePackage.LIZIZ;
            FriendsEmptyPageMainSectionVM friendsEmptyPageMainSectionVM = this.LIZIZ;
            if (friendsEmptyPageMainSectionVM == null) {
                n.LIZ("");
            }
            M12.LIZ(friendsEmptyPageMainSectionVM);
            J7F j7f = new J7F();
            j7f.LIZJ("");
            IAccountUserService LJFF = 46i.LJFF();
            n.LIZIZ(LJFF, "");
            j7f.LIZLLL(eds.LIZ(ESC.LJIIJ(LJFF.getCurUser())));
            j7f.LJ("");
            j7f.LIZ("text");
            FriendsEmptyPageSharePackage friendsEmptyPageSharePackage = new FriendsEmptyPageSharePackage(j7f, friendsEmptyPageMainSectionVM);
            4rS r2 = new 4rS();
            4B5.LIZ.LIZ(r2, activity, true);
            r2.LIZ(friendsEmptyPageSharePackage);
            r2.LIZ(new JNj());
            4rR LIZ2 = r2.LIZ();
            if (LIZ2.LJ) {
                Iterator it = LIZ2.LIZ.iterator();
                while (it.hasNext()) {
                    View view = this.itemView;
                    n.LIZIZ(view, "");
                    Context context = view.getContext();
                    n.LIZIZ(context, "");
                    if (!((JOF) it.next()).LIZIZ(context)) {
                        it.remove();
                    }
                }
            }
            View view2 = this.itemView;
            n.LIZIZ(view2, "");
            view2.findViewById(2131367356).LIZ(LIZ2.LIZ);
            View view3 = this.itemView;
            n.LIZIZ(view3, "");
            view3.findViewById(2131367356).LIZ(new C4236Edk(friendsEmptyPageSharePackage, this));
        }
    }

    /* JADX WARNING: type inference failed for: r0v36, types: [X.Eda, android.view.View$OnClickListener] */
    /* JADX WARNING: type inference failed for: r0v37, types: [android.view.View$OnClickListener, X.EdY] */
    public final void bD_() {
        FriendsEmptyPageMainSectionVM LIZ2;
        super.bD_();
        if (LIZJ()) {
            View view = this.itemView;
            n.LIZIZ(view, "");
            Context context = view.getContext();
            n.LIZIZ(context, "");
            while (true) {
                if (context != null) {
                    if (!(context instanceof 1hK)) {
                        if (!(context instanceof ContextWrapper)) {
                            break;
                        }
                        context = ((ContextWrapper) context).getBaseContext();
                    } else {
                        1hK r2 = (1hK) context;
                        if (r2 != null) {
                            StateOwner.LJI.observe(r2, new C4237Edl(this));
                            StateOwner.LJII.observe(r2, new C4240Edo(this));
                        }
                    }
                } else {
                    break;
                }
            }
        } else {
            this.LJIJ = Integer.MIN_VALUE;
        }
        if (bA_() instanceof Fragment) {
            Fragment bA_ = bA_();
            Objects.requireNonNull(bA_, "null cannot be cast to non-null type androidx.fragment.app.Fragment");
            Fragment fragment = bA_;
            0Bx LIZ3 = 0By.LIZ(fragment, (0Bv) null);
            if (2GD.LIZ) {
                0Bs.LIZ(LIZ3, fragment);
            }
            FriendsEmptyPageMainSectionVM LIZ4 = LIZ3.LIZ(FriendsEmptyPageMainSectionVM.class);
            n.LIZIZ(LIZ4, "");
            LIZ2 = LIZ4;
        } else {
            View view2 = this.itemView;
            n.LIZIZ(view2, "");
            Context context2 = view2.getContext();
            n.LIZIZ(context2, "");
            while (true) {
                if (context2 != null) {
                    if (!(context2 instanceof 1hK)) {
                        if (!(context2 instanceof ContextWrapper)) {
                            break;
                        }
                        context2 = ((ContextWrapper) context2).getBaseContext();
                    } else {
                        1hK r22 = (1hK) context2;
                        if (r22 != null) {
                            0Bx LIZ5 = 0By.LIZ(r22, (0Bv) null);
                            if (2GD.LIZ) {
                                0Bs.LIZ(LIZ5, r22);
                            }
                            LIZ2 = LIZ5.LIZ(FriendsEmptyPageMainSectionVM.class);
                            if (LIZ2 != null) {
                                n.LIZIZ(LIZ2, "");
                            }
                        }
                    }
                } else {
                    break;
                }
            }
            throw new IllegalStateException("cannot create ViewModel, lifecycle owner must be a Fragment or FragmentActivity");
        }
        this.LIZIZ = LIZ2;
        FriendsEmptyPageRootVM LIZ6 = LIZ();
        if (LIZ6 != null) {
            FriendsEmptyPageMainSectionVM friendsEmptyPageMainSectionVM = this.LIZIZ;
            if (friendsEmptyPageMainSectionVM == null) {
                n.LIZ("");
            }
            LIZ6.LIZ(friendsEmptyPageMainSectionVM);
        }
        View view3 = this.itemView;
        n.LIZIZ(view3, "");
        Qeg findViewById = view3.findViewById(2131365208);
        if (findViewById != null) {
            findViewById.LIZ(56.0f);
            findViewById.setGravity(16);
        }
        this.LJIIIZ = LeS.LIZJ(new Integer[]{2131825328, 2131825329});
        this.LJIIJ = new ArrayList();
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(findViewById, "alpha", new float[]{1.0f, 0.0f});
        n.LIZIZ(ofFloat, "");
        this.LJIIL = ofFloat;
        if (ofFloat == null) {
            n.LIZ("");
        }
        ofFloat.setDuration(500);
        ObjectAnimator objectAnimator = this.LJIIL;
        if (objectAnimator == null) {
            n.LIZ("");
        }
        objectAnimator.setInterpolator(4pn.LIZ.LIZIZ());
        ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(findViewById, "alpha", new float[]{0.0f, 1.0f});
        n.LIZIZ(ofFloat2, "");
        ofFloat2.setDuration(500);
        ofFloat2.setInterpolator(4pn.LIZ.LIZ());
        AnimatorSet.Builder play = LIZIZ().play(ofFloat2);
        ObjectAnimator objectAnimator2 = this.LJIIL;
        if (objectAnimator2 == null) {
            n.LIZ("");
        }
        play.after(objectAnimator2);
        LJFF();
        View view4 = this.itemView;
        n.LIZIZ(view4, "");
        CbG findViewById2 = view4.findViewById(2131365213);
        View view5 = this.itemView;
        n.LIZIZ(view5, "");
        CbG findViewById3 = view5.findViewById(2131365214);
        if (findViewById2 != null) {
            View view6 = this.itemView;
            n.LIZIZ(view6, "");
            findViewById2.setBackground(view6.getResources().getDrawable(2131232273));
            findViewById2.setTuxFont(33);
        }
        if (findViewById3 != null) {
            View view7 = this.itemView;
            n.LIZIZ(view7, "");
            findViewById3.setBackground(view7.getResources().getDrawable(2131232275));
        }
        if (findViewById2 != null) {
            findViewById2.setOnClickListener(new C4224EdY(this));
        }
        if (findViewById3 != null) {
            findViewById3.setOnClickListener(new C4226Eda(this));
        }
        if (bA_() != null) {
            FriendsEmptyPageMainSectionVM friendsEmptyPageMainSectionVM2 = this.LIZIZ;
            if (friendsEmptyPageMainSectionVM2 == null) {
                n.LIZ("");
            }
            LiveData<C4217EdR> liveData = friendsEmptyPageMainSectionVM2.LIZJ;
            0CH bA_2 = bA_();
            if (bA_2 == null) {
                n.LIZIZ();
            }
            liveData.observe(bA_2, new C4222EdW(this));
            FriendsEmptyPageMainSectionVM friendsEmptyPageMainSectionVM3 = this.LIZIZ;
            if (friendsEmptyPageMainSectionVM3 == null) {
                n.LIZ("");
            }
            2ce<C3741EPx> r23 = friendsEmptyPageMainSectionVM3.LJ;
            0CH bA_3 = bA_();
            if (bA_3 == null) {
                n.LIZIZ();
            }
            r23.observe(bA_3, new C3742EPy(this));
        }
    }

    public static final /* synthetic */ ListIterator LIZ(FriendsFeedEmptyPageCell friendsFeedEmptyPageCell) {
        ListIterator<Integer> listIterator = friendsFeedEmptyPageCell.LJIIJJI;
        if (listIterator == null) {
            n.LIZ("");
        }
        return listIterator;
    }

    public static final /* synthetic */ List LIZIZ(FriendsFeedEmptyPageCell friendsFeedEmptyPageCell) {
        List<Integer> list = friendsFeedEmptyPageCell.LJIIJ;
        if (list == null) {
            n.LIZ("");
        }
        return list;
    }

    public static final /* synthetic */ ObjectAnimator LIZJ(FriendsFeedEmptyPageCell friendsFeedEmptyPageCell) {
        ObjectAnimator objectAnimator = friendsFeedEmptyPageCell.LJIIL;
        if (objectAnimator == null) {
            n.LIZ("");
        }
        return objectAnimator;
    }

    public static final /* synthetic */ FriendsEmptyPageMainSectionVM LIZLLL(FriendsFeedEmptyPageCell friendsFeedEmptyPageCell) {
        FriendsEmptyPageMainSectionVM friendsEmptyPageMainSectionVM = friendsFeedEmptyPageCell.LIZIZ;
        if (friendsEmptyPageMainSectionVM == null) {
            n.LIZ("");
        }
        return friendsEmptyPageMainSectionVM;
    }

    public static void LIZ(ObjectAnimator objectAnimator) {
        if (!C0059Cih.LIZ.LIZ()) {
            objectAnimator.removeAllListeners();
            return;
        }
        System.err.println(Log.getStackTraceString(new Exception()));
        objectAnimator.removeAllListeners();
    }

    public final View LIZ(ViewGroup viewGroup) {
        M12.LIZ(viewGroup);
        if (!LIZJ()) {
            this.LJIL.removeCallbacksAndMessages((Object) null);
        }
        View LIZ2 = 0HH.LIZ(LayoutInflater.from(viewGroup.getContext()), 2131559815, viewGroup, false);
        double height = (double) viewGroup.getHeight();
        C3736EPs.LIZ(LIZ2, (int) (0.074d * height));
        C3736EPs.LIZIZ(LIZ2, (int) (height * 0.05d));
        if (viewGroup instanceof C1445DZp) {
            C1445DZp dZp = (C1445DZp) viewGroup;
            this.LJIJJ = dZp;
            if (dZp == null) {
                n.LIZ("");
            }
            dZp.LIZ(this.LJJIFFI);
        }
        n.LIZIZ(LIZ2, "");
        return LIZ2;
    }

    public final void LIZIZ(boolean z) {
        String string;
        View view = this.itemView;
        n.LIZIZ(view, "");
        Qeg findViewById = view.findViewById(2131365212);
        if (findViewById != null) {
            if (this.LJIILL == 2oU.EMPTY_STATE) {
                if (z) {
                    View view2 = this.itemView;
                    n.LIZIZ(view2, "");
                    string = view2.getResources().getString(2131825332);
                } else {
                    View view3 = this.itemView;
                    n.LIZIZ(view3, "");
                    string = view3.getResources().getString(2131825331);
                }
            } else if (z) {
                View view4 = this.itemView;
                n.LIZIZ(view4, "");
                string = view4.getResources().getString(2131825334);
            } else {
                View view5 = this.itemView;
                n.LIZIZ(view5, "");
                string = view5.getResources().getString(2131825333);
            }
            findViewById.setText(string);
        }
    }

    public final void LIZ(EQ3 eq3) {
        int i;
        M12.LIZ(eq3);
        if (!this.LJIILJJIL) {
            this.LJIILJJIL = true;
            this.LJIILL = eq3.LIZ;
            View view = this.itemView;
            n.LIZIZ(view, "");
            Qeg findViewById = view.findViewById(2131365208);
            if (findViewById != null) {
                findViewById.setAlpha(1.0f);
            }
            View view2 = this.itemView;
            n.LIZIZ(view2, "");
            Qeg findViewById2 = view2.findViewById(2131365208);
            if (findViewById2 != null) {
                View view3 = this.itemView;
                n.LIZIZ(view3, "");
                Resources resources = view3.getResources();
                if (this.LJIILL == 2oU.EMPTY_STATE) {
                    i = 2131825323;
                } else {
                    i = 2131825324;
                }
                findViewById2.setText(resources.getString(i));
            }
            LIZIZ().cancel();
            List<Integer> list = this.LJIIJ;
            if (list == null) {
                n.LIZ("");
            }
            this.LJIIJJI = list.listIterator();
            if (!LIZJ()) {
                int i2 = this.LJIJ;
                if (i2 >= Integer.MAX_VALUE) {
                    this.LJIJ = Integer.MIN_VALUE;
                } else {
                    this.LJIJ = i2 + 1;
                }
                this.LJIL.postDelayed(new C4231Edf(this, this.LJIJ), 3500);
            } else {
                this.LJIIZILJ.LIZ();
            }
            2or.LIZ("friends_tab_empty", (2ov) null, 6);
        }
    }

    public final void LIZ(boolean z) {
        super.LIZ(z);
        if (z && this.LJIILJJIL && this.LJIILIIL && LIZJ()) {
            this.LJIIZILJ.LIZ();
        }
    }
}
