package vn.vinfast.charginguikit.ui.views;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes6.dex */
@kotlin.Metadata(d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u000b\n\u0002\u0010\u000b\n\u0002\b\u0006\u0018\u0000 \u001a2\u00020\u0001:\u0001\u001bB'\b\u0007\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u0004\u0012\b\b\u0002\u0010\u0007\u001a\u00020\u0006¢\u0006\u0004\b\b\u0010\tJ\u0017\u0010\u000b\u001a\u00020\n2\u0006\u0010\u0005\u001a\u00020\u0004H\u0002¢\u0006\u0004\b\u000b\u0010\fJ\u001f\u0010\u000f\u001a\u00020\n2\u0006\u0010\r\u001a\u00020\u00062\u0006\u0010\u000e\u001a\u00020\u0006H\u0014¢\u0006\u0004\b\u000f\u0010\u0010J\u000f\u0010\u0011\u001a\u00020\nH\u0014¢\u0006\u0004\b\u0011\u0010\u0012R\u0016\u0010\u0015\u001a\u00020\u00068\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0013\u0010\u0014R\u0016\u0010\u0019\u001a\u00020\u00168\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0017\u0010\u0018¨\u0006\u001c"}, d2 = {"Lvn/vinfast/charginguikit/ui/views/CustomHeightRecyclerView;", "Landroidx/recyclerview/widget/RecyclerView;", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "", "defStyleAttr", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "", "P", "(Landroid/util/AttributeSet;)V", "widthSpec", "heightSpec", "onMeasure", "(II)V", "onDetachedFromWindow", "()V", "a", "I", "maxChildCount", "", "b", "Z", "isShowLastHaft", "c", "Companion", "chargingkitui_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
public final class CustomHeightRecyclerView extends androidx.recyclerview.widget.RecyclerView {

    /* JADX INFO: renamed from: a, reason: from kotlin metadata */
    private int maxChildCount;

    /* JADX INFO: renamed from: b, reason: from kotlin metadata */
    private boolean isShowLastHaft;

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    @kotlin.jvm.JvmOverloads
    public CustomHeightRecyclerView(@org.jetbrains.annotations.NotNull android.content.Context context) {
        this(context, null, 0, 6, null);
        kotlin.jvm.internal.Intrinsics.l(context, "context");
    }

    /* JADX WARN: Multi-variable type inference failed */
    private final void P(android.util.AttributeSet attrs) {
        android.content.res.TypedArray typedArrayObtainStyledAttributes = getContext().getTheme().obtainStyledAttributes(attrs, vn.vinfast.charginguikit.R.styleable.CustomHeightRecyclerView, 0, 0);
        this.maxChildCount = typedArrayObtainStyledAttributes.getInteger(vn.vinfast.charginguikit.R.styleable.CustomHeightRecyclerView_maxItemShow, 5);
        this.isShowLastHaft = typedArrayObtainStyledAttributes.getBoolean(vn.vinfast.charginguikit.R.styleable.CustomHeightRecyclerView_isShowHalfLast, false);
    }

    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        setAdapter((androidx.recyclerview.widget.RecyclerView.Adapter) null);
    }

    /* JADX WARN: Multi-variable type inference failed */
    protected void onMeasure(int widthSpec, int heightSpec) {
        if (getChildCount() > this.maxChildCount) {
            if (this.isShowLastHaft) {
                getLayoutParams().height = (getChildAt(0).getHeight() * ((this.maxChildCount * 2) + 1)) / 2;
            } else {
                heightSpec = getChildAt(0).getHeight() * this.maxChildCount;
            }
            if (getLayoutManager() instanceof vn.vinfast.charginguikit.ui.views.NonScrollableLinearLayoutManager) {
                vn.vinfast.charginguikit.ui.views.NonScrollableLinearLayoutManager layoutManager = getLayoutManager();
                kotlin.jvm.internal.Intrinsics.j(layoutManager, "null cannot be cast to non-null type vn.vinfast.charginguikit.ui.views.NonScrollableLinearLayoutManager");
                layoutManager.y();
            }
        } else if (getLayoutManager() instanceof vn.vinfast.charginguikit.ui.views.NonScrollableLinearLayoutManager) {
            vn.vinfast.charginguikit.ui.views.NonScrollableLinearLayoutManager layoutManager2 = getLayoutManager();
            kotlin.jvm.internal.Intrinsics.j(layoutManager2, "null cannot be cast to non-null type vn.vinfast.charginguikit.ui.views.NonScrollableLinearLayoutManager");
            layoutManager2.x();
        }
        super.onMeasure(widthSpec, heightSpec);
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    @kotlin.jvm.JvmOverloads
    public CustomHeightRecyclerView(@org.jetbrains.annotations.NotNull android.content.Context context, @org.jetbrains.annotations.Nullable android.util.AttributeSet attributeSet) {
        this(context, attributeSet, 0, 4, null);
        kotlin.jvm.internal.Intrinsics.l(context, "context");
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    @kotlin.jvm.JvmOverloads
    public CustomHeightRecyclerView(@org.jetbrains.annotations.NotNull android.content.Context context, @org.jetbrains.annotations.Nullable android.util.AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        kotlin.jvm.internal.Intrinsics.l(context, "context");
        this.maxChildCount = 5;
        if (attributeSet != null) {
            P(attributeSet);
        }
    }

    public /* synthetic */ CustomHeightRecyclerView(android.content.Context context, android.util.AttributeSet attributeSet, int i, int i2, kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
        this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
    }
}
