package com.ss.android.ugc.aweme.zerorating;

import X.7lW;
import X.8QU;
import X.9DY;
import X.9EH;
import X.9Vc;
import X.C0835RWd;
import X.C0836RWe;
import X.C0837RWf;
import X.C0841RWj;
import X.C0842RWk;
import X.C0843RWl;
import X.C0844RWm;
import X.C0845RWn;
import X.C0846RWo;
import X.C0847RWp;
import X.C0848RWq;
import X.C0850RWs;
import X.C0851RWt;
import X.JsH;
import X.Lnj;
import X.M12;
import X.OJn;
import X.OQt;
import X.PTw;
import X.RWM;
import X.RX6;
import android.content.Context;
import android.os.Handler;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.ugc.aweme.network.RetrofitFactory;
import com.bytedance.keva.Keva;
import com.bytedance.ttnet.INetworkApi;
import com.ss.android.ugc.aweme.api.IZeroRatingService;
import java.util.ArrayList;

public final class ZeroRatingServiceImpl implements IZeroRatingService {
    public static final boolean LIZLLL = false;
    public static final C0851RWt LJ = new C0851RWt((byte) 0);
    public INetworkApi LIZ;
    public INetworkApi LIZIZ;
    public final ArrayList<String> LIZJ = new ArrayList<>();
    public volatile C0848RWq LJFF;

    public final OJn LIZJ() {
        return new C0847RWp();
    }

    public final void LIZLLL() {
        C0848RWq rWq = this.LJFF;
        if (rWq != null) {
            rWq.LIZIZ();
        }
    }

    public final void LJ() {
        C0848RWq rWq = this.LJFF;
        if (rWq != null) {
            rWq.LIZJ();
        }
    }

    public final boolean LIZIZ() {
        C0848RWq rWq = this.LJFF;
        if (rWq != null) {
            return rWq.LIZ();
        }
        return false;
    }

    static {
        Covode.recordClassIndex(124730);
    }

    public static IZeroRatingService LJFF() {
        MethodCollector.i(530);
        IZeroRatingService iZeroRatingService = (IZeroRatingService) Lnj.LIZ(IZeroRatingService.class, false);
        if (iZeroRatingService != null) {
            MethodCollector.o(530);
            return iZeroRatingService;
        }
        Object LIZIZ2 = Lnj.LIZIZ(IZeroRatingService.class, false);
        if (LIZIZ2 != null) {
            IZeroRatingService iZeroRatingService2 = (IZeroRatingService) LIZIZ2;
            MethodCollector.o(530);
            return iZeroRatingService2;
        }
        if (Lnj.ca == null) {
            synchronized (IZeroRatingService.class) {
                try {
                    if (Lnj.ca == null) {
                        Lnj.ca = new ZeroRatingServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(530);
                    throw th;
                }
            }
        }
        ZeroRatingServiceImpl zeroRatingServiceImpl = (ZeroRatingServiceImpl) Lnj.ca;
        MethodCollector.o(530);
        return zeroRatingServiceImpl;
    }

    public final void LIZ() {
        String str;
        boolean z;
        if (this.LIZ == null) {
            this.LIZ = (INetworkApi) RetrofitFactory.LIZ().LIZIZ(9DY.LJ).LIZJ().LIZ(INetworkApi.class);
        }
        if (this.LIZIZ == null) {
            PTw LIZIZ2 = RetrofitFactory.LIZ().LIZIZ(9DY.LJ);
            LIZIZ2.LIZ();
            this.LIZIZ = (INetworkApi) LIZIZ2.LIZJ().LIZ(INetworkApi.class);
        }
        C0845RWn rWn = new C0845RWn();
        Context applicationContext = 9EH.LJJIFFI.LIZ().getApplicationContext();
        if (7lW.LIZJ && applicationContext == null) {
            applicationContext = 7lW.LIZ;
        }
        rWn.LIZIZ = applicationContext;
        if (9EH.LJIILJJIL == 1233) {
            str = "carrierflow-va.tiktokv.com";
        } else {
            str = "carrierflow-sg.tiktokv.com";
        }
        rWn.LJI = str;
        rWn.LIZ = new 9Vc(this);
        rWn.LIZLLL = new C0844RWm(this);
        rWn.LJFF = 8QU.LIZ(new String[]{"72402", "72403", "72404", "72408"});
        rWn.LJ = new C0846RWo(this);
        rWn.LJIIIIZZ = JsH.LIZ();
        boolean z2 = LIZLLL;
        if (z2) {
            z = Keva.getRepoFromSp(9EH.LJJIFFI.LIZ(), "test_sp", 1).getBoolean("key_mock_mobile", false);
        } else {
            z = false;
        }
        rWn.LIZJ = z;
        String str2 = "";
        if (z2) {
            str2 = Keva.getRepoFromSp(9EH.LJJIFFI.LIZ(), "test_sp", 1).getString("key_mock_mccmnc", str2);
        }
        rWn.LJIIJ = str2;
        C0843RWl rWl = new C0843RWl(rWn, (byte) 0);
        C0850RWs rWs = new C0850RWs();
        boolean z3 = rWl.LJIIJ;
        C0841RWj.LIZ = rWl;
        C0841RWj.LJIIIZ();
        C0841RWj.LIZ();
        if (z3) {
            RWM rwm = C0836RWe.LIZ;
            C0842RWk rWk = new C0842RWk(rWs);
            if (rwm.LIZIZ != null) {
                rwm.LIZIZ.post(new C0835RWd(rwm, rWk));
            }
        }
        this.LJFF = C0841RWj.LIZLLL();
    }

    public final void LIZ(RX6<OQt> rx6) {
        C0848RWq rWq = this.LJFF;
        if (rWq != null) {
            rWq.LIZ(rx6);
        }
    }

    public final void LIZ(Handler handler) {
        M12.LIZ(handler);
        C0848RWq rWq = this.LJFF;
        if (rWq != null) {
            rWq.LIZ(handler);
        }
    }

    public final void LIZ(boolean z, C0837RWf rWf) {
        M12.LIZ(rWf);
        C0848RWq rWq = this.LJFF;
        if (rWq != null) {
            rWq.LIZ(z, rWf);
        }
    }
}
