package i;

import d.C0424d;
import g.C0474a;
import g.InterfaceC0476c;
import java.lang.reflect.Type;
import java.text.DecimalFormat;
import java.text.NumberFormat;

/* JADX INFO: renamed from: i.B, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public class C0509B implements U, h.t {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static C0509B f4215b = new C0509B();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private NumberFormat f4216a;

    public C0509B() {
    }

    public static Object e(C0474a c0474a) {
        InterfaceC0476c interfaceC0476c = c0474a.f3944H;
        if (interfaceC0476c.F() == 2) {
            String strA0 = interfaceC0476c.a0();
            interfaceC0476c.s(16);
            return Float.valueOf(Float.parseFloat(strA0));
        }
        if (interfaceC0476c.F() == 3) {
            float fD = interfaceC0476c.D();
            interfaceC0476c.s(16);
            return Float.valueOf(fD);
        }
        Object objA = c0474a.A();
        if (objA == null) {
            return null;
        }
        return l.l.s(objA);
    }

    @Override // i.U
    public void a(C0516I c0516i, Object obj, Object obj2, Type type, int i2) {
        e0 e0Var = c0516i.f4223k;
        if (obj == null) {
            e0Var.N(f0.WriteNullNumberAsZero);
            return;
        }
        float fFloatValue = ((Float) obj).floatValue();
        NumberFormat numberFormat = this.f4216a;
        if (numberFormat != null) {
            e0Var.write(numberFormat.format(fFloatValue));
        } else {
            e0Var.D(fFloatValue, true);
        }
    }

    @Override // h.t
    public Object b(C0474a c0474a, Type type, Object obj) {
        try {
            return e(c0474a);
        } catch (Exception e2) {
            throw new C0424d("parseLong error, field : " + obj, e2);
        }
    }

    @Override // h.t
    public int d() {
        return 2;
    }

    public C0509B(DecimalFormat decimalFormat) {
        this.f4216a = decimalFormat;
    }

    public C0509B(String str) {
        this(new DecimalFormat(str));
    }
}
