package com.bytedance.android.livesdk.feed.network;

import X.0UO;
import X.0z8;
import X.0z9;
import X.1c3;
import X.1c4;
import X.1c5;
import X.H20;
import X.H21;
import com.bytedance.android.live.network.response.RequestError;
import com.bytedance.android.livesdk.feed.services.FeedItemDeserializer;
import com.bytedance.android.livesdk.model.Extra;
import com.bytedance.android.livesdk.model.FeedItem;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import com.google.gson.Gson;
import com.google.gson.c;
import com.google.gson.e;
import com.google.gson.h;
import com.google.gson.i;
import com.google.gson.j;
import com.google.gson.m;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public final class GsonProvider implements H20<Gson> {
    static {
        Covode.recordClassIndex(16141);
    }

    public static class RoomDeserializer implements i<Room> {
        public Gson LIZ;

        static {
            Covode.recordClassIndex(16150);
        }

        public RoomDeserializer() {
            this.LIZ = 0UO.LIZIZ;
        }

        public /* synthetic */ RoomDeserializer(byte b) {
            this();
        }

        public final /* synthetic */ Object LIZ(j jVar, Type type, h hVar) {
            Room room = (Room) this.LIZ.LIZ(jVar, type);
            room.init();
            return room;
        }
    }

    public static class BaseListResponseDeserializer extends AbsJsonDeserializer<0z8> {
        static {
            Covode.recordClassIndex(16144);
        }

        public BaseListResponseDeserializer(Gson gson) {
            super(gson);
        }

        public final /* synthetic */ Object LIZ(j jVar, Type type, h hVar) {
            m LJIIL = jVar.LJIIL();
            int LJI = LJIIL.LIZJ("status_code").LJI();
            if (LJI == 0) {
                return this.LIZ.LIZ(jVar, type);
            }
            0z8 r5 = new 0z8();
            r5.LIZ = LJI;
            r5.LJI = (RequestError) this.LIZ.LIZ(LJIIL.LIZJ("data"), RequestError.class);
            if (type instanceof ParameterizedType) {
                Type[] actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
                if (actualTypeArguments.length > 1) {
                    r5.LIZJ = (Extra) this.LIZ.LIZ(LJIIL.LIZJ("extra"), actualTypeArguments[1]);
                    return r5;
                }
            }
            r5.LIZJ = (Extra) this.LIZ.LIZ(LJIIL.LIZJ("extra"), Extra.class);
            return r5;
        }
    }

    public static class BaseResponseDeserializer extends AbsJsonDeserializer<0z9> {
        static {
            Covode.recordClassIndex(16145);
        }

        public BaseResponseDeserializer(Gson gson) {
            super(gson);
        }

        public final /* synthetic */ Object LIZ(j jVar, Type type, h hVar) {
            0z9 r3 = (0z9) this.LIZ.LIZ(jVar, type);
            if (r3.statusCode != 0) {
                r3.error = (RequestError) this.LIZ.LIZ(jVar.LJIIL().LIZJ("data"), RequestError.class);
            }
            return r3;
        }
    }

    public static class LinkMicResponseDeserializer extends AbsJsonDeserializer<1c3> {
        static {
            Covode.recordClassIndex(16147);
        }

        public LinkMicResponseDeserializer(Gson gson) {
            super(gson);
        }

        public final /* synthetic */ Object LIZ(j jVar, Type type, h hVar) {
            0z9 r3 = (0z9) this.LIZ.LIZ(jVar, type);
            if (r3.statusCode != 0) {
                r3.error = (RequestError) this.LIZ.LIZ(jVar.LJIIL().LIZJ("data"), RequestError.class);
            }
            return r3;
        }
    }

    public static class ListResponseDeserializer extends AbsJsonDeserializer<1c4> {
        static {
            Covode.recordClassIndex(16148);
        }

        public ListResponseDeserializer(Gson gson) {
            super(gson);
        }

        public final /* synthetic */ Object LIZ(j jVar, Type type, h hVar) {
            m LJIIL = jVar.LJIIL();
            int LJI = LJIIL.LIZJ("status_code").LJI();
            if (LJI == 0) {
                return this.LIZ.LIZ(jVar, type);
            }
            1c4 r3 = new 1c4();
            r3.LIZ = LJI;
            r3.LIZJ = (Extra) this.LIZ.LIZ(LJIIL.LIZJ("extra"), Extra.class);
            r3.LJI = (RequestError) this.LIZ.LIZ(LJIIL.LIZJ("data"), RequestError.class);
            return r3;
        }
    }

    public static class ResponseDeserializer extends AbsJsonDeserializer<1c5> {
        static {
            Covode.recordClassIndex(16149);
        }

        public ResponseDeserializer(Gson gson) {
            super(gson);
        }

        public final /* synthetic */ Object LIZ(j jVar, Type type, h hVar) {
            0z9 r3 = (0z9) this.LIZ.LIZ(jVar, type);
            if (r3.statusCode != 0) {
                r3.error = (RequestError) this.LIZ.LIZ(jVar.LJIIL().LIZJ("data"), RequestError.class);
            }
            return r3;
        }
    }

    public static abstract class AbsJsonDeserializer<T> implements i<T> {
        public Gson LIZ;

        static {
            Covode.recordClassIndex(16143);
        }

        public AbsJsonDeserializer(Gson gson) {
            this.LIZ = gson;
        }
    }

    public final H21<Gson> LIZ(H21<Gson> h21) {
        e eVar = new e();
        eVar.LIZIZ = c.LOWER_CASE_WITH_UNDERSCORES;
        eVar.LIZ(Room.class, new RoomDeserializer((byte) 0));
        eVar.LIZ(FeedItem.class, new FeedItemDeserializer());
        eVar.LIZ(Boolean.class, new BooleanTypeAdapter((byte) 0));
        eVar.LIZ(Boolean.TYPE, new BooleanTypeAdapter((byte) 0));
        e eVar2 = new e();
        eVar2.LIZIZ = c.LOWER_CASE_WITH_UNDERSCORES;
        eVar2.LIZ(Room.class, new RoomDeserializer((byte) 0));
        eVar2.LIZ(FeedItem.class, new FeedItemDeserializer());
        eVar2.LIZ(Boolean.class, new BooleanTypeAdapter((byte) 0));
        eVar2.LIZ(Boolean.TYPE, new BooleanTypeAdapter((byte) 0));
        Gson LIZIZ = eVar2.LIZIZ();
        eVar.LIZ(0z9.class, new BaseResponseDeserializer(LIZIZ));
        eVar.LIZ(1c5.class, new ResponseDeserializer(LIZIZ));
        eVar.LIZ(0z8.class, new BaseListResponseDeserializer(LIZIZ));
        eVar.LIZ(1c4.class, new ListResponseDeserializer(LIZIZ));
        eVar.LIZ(1c3.class, new LinkMicResponseDeserializer(LIZIZ));
        h21.LIZ = eVar.LIZIZ();
        h21.LIZIZ = true;
        return h21;
    }
}
