package com.ss.android.ugc.aweme.ecommerce.mall;

import X.1hK;
import X.2Gx;
import X.3hg;
import X.7he;
import X.C0295Crj;
import X.C3658EMs;
import X.C4574EjC;
import X.C4795Eml;
import X.C4847Enb;
import X.C4957EpN;
import X.C4958EpO;
import X.C4959EpP;
import X.C4961EpR;
import X.C5188Et6;
import X.M12;
import android.content.Context;
import android.content.ContextWrapper;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.hox.Hox;
import com.bytedance.tiktok.homepage.mainfragment.TopTabProtocol;
import com.ss.android.ugc.aweme.base.MainBusinessAbility;
import com.ss.android.ugc.aweme.ecommerce.ECommerceService;
import com.ss.android.ugc.aweme.main.TabChangeManager;
import kotlin.h.b.n;

public final class ShopTopTabProtocol extends TopTabProtocol {
    public Context LIZ;
    public final String LIZIZ = "homepage_mall";
    public boolean LIZJ;
    public final C0295Crj LIZLLL = 7he.LIZ(new C4958EpO(this));
    public final String LJ = "Shop";
    public final Class<? extends Fragment> LJFF = MallMainFragment.class;
    public final C0295Crj LJI = 7he.LIZ(new C4961EpR(this));
    public final 3hg LJII = 3hg.X_TAB;
    public final C4795Eml LJIIIIZZ = C4795Eml.SHOP;

    static {
        Covode.recordClassIndex(70235);
    }

    public final C3658EMs LJIIJJI() {
        return (C3658EMs) this.LIZLLL.getValue();
    }

    public final C5188Et6 LJIIL() {
        return (C5188Et6) this.LJI.getValue();
    }

    public final String LIZ() {
        return this.LIZIZ;
    }

    public final String LIZIZ() {
        return this.LJ;
    }

    public final Class<? extends Fragment> LIZJ() {
        return this.LJFF;
    }

    public final C4795Eml LJ() {
        return this.LJIIIIZZ;
    }

    public final 3hg LJIIIIZZ() {
        return this.LJII;
    }

    public final C4847Enb LJII() {
        return new C4959EpP(this);
    }

    public final boolean LJFF() {
        return ECommerceService.createIECommerceServicebyMonsterPlugin(false).hitTopTabExpExperiment();
    }

    public final void LJIIIZ() {
        String str;
        if (!LJIILIIL()) {
            this.LIZJ = true;
            MainBusinessAbility LIZ2 = C4574EjC.LIZ(LJIIJJI());
            if (LIZ2 != null) {
                str = LIZ2.LJI();
            } else {
                str = null;
            }
            LJIIL().LIZ(str, false);
        }
    }

    public final void LJIIJ() {
        String str;
        if (this.LIZJ) {
            this.LIZJ = false;
            return;
        }
        MainBusinessAbility LIZ2 = C4574EjC.LIZ(LJIIJJI());
        if (LIZ2 != null) {
            str = LIZ2.LJI();
        } else {
            str = null;
        }
        LJIIL().LIZ(str, true);
    }

    public final boolean LJIILIIL() {
        Context context = this.LIZ;
        if (context != null) {
            while (true) {
                if (!(context instanceof 1hK)) {
                    if (context instanceof ContextWrapper) {
                        context = ((ContextWrapper) context).getBaseContext();
                        if (context == null) {
                            break;
                        }
                    } else {
                        break;
                    }
                } else {
                    1hK r2 = (1hK) context;
                    if (r2 != null) {
                        if (!n.LIZ("HOME", TabChangeManager.LJII.LIZ(r2).LIZLLL) || !Hox.LJ.LIZ(r2).LIZJ("Shop")) {
                            return false;
                        }
                        return true;
                    }
                }
            }
        }
        throw new IllegalArgumentException("activity is null".toString());
    }

    public final boolean LIZJ(Context context) {
        M12.LIZ(context);
        return ECommerceService.createIECommerceServicebyMonsterPlugin(false).shouldShowMallTopTab();
    }

    public final String LIZIZ(Context context) {
        M12.LIZ(context);
        String string = context.getResources().getString(2131824386);
        n.LIZIZ(string, "");
        return string;
    }

    public final void LIZLLL(Context context) {
        M12.LIZ(context);
        super.LIZLLL(context);
        this.LIZ = context;
        2Gx.LIZ.post(new C4957EpN(this, context));
    }
}
