package com.google.android.material.datepicker;

import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import com.google.android.material.textfield.TextInputLayout;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;

/* loaded from: classes3.dex */
public class t implements f {
    public static final Parcelable.Creator<t> CREATOR = new b();

    /* renamed from: p, reason: collision with root package name */
    private Long f13190p;

    /* loaded from: classes3.dex */
    class a extends e {

        /* renamed from: v, reason: collision with root package name */
        final /* synthetic */ r f13191v;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        a(String str, DateFormat dateFormat, TextInputLayout textInputLayout, com.google.android.material.datepicker.a aVar, r rVar) {
            super(str, dateFormat, textInputLayout, aVar);
            this.f13191v = rVar;
        }

        @Override // com.google.android.material.datepicker.e
        void e() {
            this.f13191v.a();
        }

        @Override // com.google.android.material.datepicker.e
        void f(Long l10) {
            if (l10 == null) {
                t.this.c();
            } else {
                t.this.K0(l10.longValue());
            }
            this.f13191v.b(t.this.B0());
        }
    }

    /* loaded from: classes3.dex */
    class b implements Parcelable.Creator {
        b() {
        }

        @Override // android.os.Parcelable.Creator
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public t createFromParcel(Parcel parcel) {
            t tVar = new t();
            tVar.f13190p = (Long) parcel.readValue(Long.class.getClassLoader());
            return tVar;
        }

        @Override // android.os.Parcelable.Creator
        /* renamed from: b, reason: merged with bridge method [inline-methods] */
        public t[] newArray(int i10) {
            return new t[i10];
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void c() {
        this.f13190p = null;
    }

    @Override // com.google.android.material.datepicker.f
    public void K0(long j10) {
        this.f13190p = Long.valueOf(j10);
    }

    @Override // com.google.android.material.datepicker.f
    public View X(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle, com.google.android.material.datepicker.a aVar, r rVar) {
        View inflate = layoutInflater.inflate(vi.h.A, viewGroup, false);
        TextInputLayout textInputLayout = (TextInputLayout) inflate.findViewById(vi.f.G);
        EditText editText = textInputLayout.getEditText();
        if (com.google.android.material.internal.g.a()) {
            editText.setInputType(17);
        }
        SimpleDateFormat f10 = w.f();
        String g10 = w.g(inflate.getResources(), f10);
        textInputLayout.setPlaceholderText(g10);
        Long l10 = this.f13190p;
        if (l10 != null) {
            editText.setText(f10.format(l10));
        }
        editText.addTextChangedListener(new a(g10, f10, textInputLayout, aVar, rVar));
        com.google.android.material.internal.q.h(editText);
        return inflate;
    }

    @Override // com.google.android.material.datepicker.f
    public int Y() {
        return vi.j.f39874o;
    }

    @Override // com.google.android.material.datepicker.f
    /* renamed from: d, reason: merged with bridge method [inline-methods] */
    public Long B0() {
        return this.f13190p;
    }

    @Override // android.os.Parcelable
    public int describeContents() {
        return 0;
    }

    @Override // com.google.android.material.datepicker.f
    /* renamed from: e, reason: merged with bridge method [inline-methods] */
    public void z(Long l10) {
        this.f13190p = l10 == null ? null : Long.valueOf(w.a(l10.longValue()));
    }

    @Override // com.google.android.material.datepicker.f
    public int k0(Context context) {
        return ij.b.d(context, vi.b.C, l.class.getCanonicalName());
    }

    @Override // com.google.android.material.datepicker.f
    public boolean q0() {
        return this.f13190p != null;
    }

    @Override // com.google.android.material.datepicker.f
    public String s(Context context) {
        Resources resources = context.getResources();
        Long l10 = this.f13190p;
        if (l10 == null) {
            return resources.getString(vi.j.f39875p);
        }
        return resources.getString(vi.j.f39873n, g.h(l10.longValue()));
    }

    @Override // com.google.android.material.datepicker.f
    public Collection v() {
        return new ArrayList();
    }

    @Override // android.os.Parcelable
    public void writeToParcel(Parcel parcel, int i10) {
        parcel.writeValue(this.f13190p);
    }

    @Override // com.google.android.material.datepicker.f
    public Collection y0() {
        ArrayList arrayList = new ArrayList();
        Long l10 = this.f13190p;
        if (l10 != null) {
            arrayList.add(l10);
        }
        return arrayList;
    }
}
