package p037.p091.p095;

import android.R;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.Checkable;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.leanback.widget.picker.DatePicker;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import p037.p065.p068.C1850;
import p037.p091.C2079;
import p037.p091.p095.C2155;
import p037.p091.p095.InterfaceC2152;
import p037.p091.p095.InterfaceC2166;
import p037.p107.p108.C2307;
import p037.p107.p108.C2339;
import p138.p139.p143.p144.C2803;

/* JADX INFO: renamed from: މ.މ.ލ.ވ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C2141 extends RecyclerView.AbstractC0191 {

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final boolean f6995;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final ViewOnKeyListenerC2147 f6996;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final ViewOnFocusChangeListenerC2146 f6997;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final C2145 f6998;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final C2144 f6999;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final List<C2138> f7000;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public InterfaceC2148 f7001;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final C2155 f7002;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public C2151 f7003;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public AbstractC2121<C2138> f7004;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public final View.OnClickListener f7005 = new ViewOnClickListenerC2142();

    /* JADX INFO: renamed from: މ.މ.ލ.ވ$֏, reason: contains not printable characters */
    public class ViewOnClickListenerC2142 implements View.OnClickListener {
        public ViewOnClickListenerC2142() {
        }

        @Override // android.view.View.OnClickListener
        public void onClick(View view) {
            InterfaceC2148 interfaceC2148;
            if (view == null || view.getWindowToken() == null || C2141.this.m4197() == null) {
                return;
            }
            C2155.C2160 c2160 = (C2155.C2160) C2141.this.m4197().mo564(view);
            C2138 c2138 = c2160.f7050;
            int i = c2138.f6975;
            if (i == 1 || i == 2) {
                C2141 c2141 = C2141.this;
                c2141.f7003.m4205(c2141, c2160);
                return;
            }
            if (c2138.m4174()) {
                InterfaceC2148 interfaceC21482 = C2141.this.f7001;
                if (interfaceC21482 != null) {
                    interfaceC21482.mo4066(c2160.f7050);
                    return;
                }
                return;
            }
            C2141 c21412 = C2141.this;
            if (c21412 == null) {
                throw null;
            }
            C2138 c21382 = c2160.f7050;
            int i2 = c21382.f6981;
            if (c21412.m4197() != null && i2 != 0) {
                if (i2 != -1) {
                    int size = c21412.f7000.size();
                    for (int i3 = 0; i3 < size; i3++) {
                        C2138 c21383 = c21412.f7000.get(i3);
                        if (c21383 != c21382 && c21383.f6981 == i2 && c21383.m4177()) {
                            c21383.m4171(0, 1);
                            C2155.C2160 c21602 = (C2155.C2160) c21412.m4197().m553(i3);
                            if (c21602 != null) {
                                c21412.f7002.m4214(c21602, false);
                            }
                        }
                    }
                }
                if (!c21382.m4177()) {
                    c21382.m4171(1, 1);
                    c21412.f7002.m4214(c2160, true);
                } else if (i2 == -1) {
                    c21382.m4171(0, 1);
                    c21412.f7002.m4214(c2160, false);
                }
            }
            if (c2138.m4180()) {
                if (((c2138.f6972 & 8) == 8) || (interfaceC2148 = C2141.this.f7001) == null) {
                    return;
                }
                interfaceC2148.mo4066(c2160.f7050);
            }
        }
    }

    /* JADX INFO: renamed from: މ.މ.ލ.ވ$ؠ, reason: contains not printable characters */
    public class C2143 extends C2339.AbstractC2341 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final /* synthetic */ List f7007;

        public C2143(List list) {
            this.f7007 = list;
        }

        @Override // p037.p107.p108.C2339.AbstractC2341
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public int mo4198() {
            return C2141.this.f7000.size();
        }

        /* JADX WARN: Removed duplicated region for block: B:29:0x006b  */
        @Override // p037.p107.p108.C2339.AbstractC2341
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public boolean mo4199(int i, int i2) {
            AbstractC2121<C2138> abstractC2121 = C2141.this.f7004;
            Object obj = this.f7007.get(i);
            C2138 c2138 = C2141.this.f7000.get(i2);
            if (((C2154) abstractC2121) == null) {
                throw null;
            }
            C2138 c21382 = (C2138) obj;
            C2138 c21383 = c2138;
            boolean z = true;
            if (c21382 == null) {
                if (c21383 != null) {
                    z = false;
                }
            } else {
                if (c21383 == null) {
                    return false;
                }
                if (c21382.f6981 != c21383.f6981 || c21382.f6972 != c21383.f6972 || !TextUtils.equals(c21382.f6869, c21383.f6869) || !TextUtils.equals(c21382.f6870, c21383.f6870) || c21382.f6976 != c21383.f6976 || !TextUtils.equals(c21382.f6973, c21383.f6973) || !TextUtils.equals(c21382.f6974, c21383.f6974) || c21382.f6978 != c21383.f6978 || c21382.f6979 != c21383.f6979) {
                }
            }
            return z;
        }

        @Override // p037.p107.p108.C2339.AbstractC2341
        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public int mo4200() {
            return this.f7007.size();
        }

        /* JADX WARN: Removed duplicated region for block: B:13:0x002d  */
        @Override // p037.p107.p108.C2339.AbstractC2341
        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public boolean mo4201(int i, int i2) {
            AbstractC2121<C2138> abstractC2121 = C2141.this.f7004;
            Object obj = this.f7007.get(i);
            C2138 c2138 = C2141.this.f7000.get(i2);
            if (((C2154) abstractC2121) == null) {
                throw null;
            }
            C2138 c21382 = (C2138) obj;
            C2138 c21383 = c2138;
            boolean z = true;
            if (c21382 == null) {
                if (c21383 != null) {
                    z = false;
                }
            } else {
                if (c21383 == null) {
                    return false;
                }
                if (c21382.f6867 != c21383.f6867) {
                }
            }
            return z;
        }

        @Override // p037.p107.p108.C2339.AbstractC2341
        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public Object mo4202(int i, int i2) {
            AbstractC2121<C2138> abstractC2121 = C2141.this.f7004;
            this.f7007.get(i);
            C2141.this.f7000.get(i2);
            if (abstractC2121 != null) {
                return null;
            }
            throw null;
        }
    }

    /* JADX INFO: renamed from: މ.މ.ލ.ވ$ހ, reason: contains not printable characters */
    public class C2144 implements InterfaceC2152.InterfaceC2153 {
        public C2144() {
        }
    }

    /* JADX INFO: renamed from: މ.މ.ލ.ވ$ށ, reason: contains not printable characters */
    public class C2145 implements TextView.OnEditorActionListener, InterfaceC2166.InterfaceC2167 {
        public C2145() {
        }

        @Override // android.widget.TextView.OnEditorActionListener
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == 5 || i == 6) {
                C2141 c2141 = C2141.this;
                c2141.f7003.m4204(c2141, textView);
                return true;
            }
            if (i != 1) {
                return false;
            }
            C2141 c21412 = C2141.this;
            c21412.f7003.m4207(c21412, textView);
            return true;
        }
    }

    /* JADX INFO: renamed from: މ.މ.ލ.ވ$ނ, reason: contains not printable characters */
    public class ViewOnFocusChangeListenerC2146 implements View.OnFocusChangeListener {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public InterfaceC2150 f7011;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public View f7012;

        public ViewOnFocusChangeListenerC2146(InterfaceC2150 interfaceC2150) {
            this.f7011 = interfaceC2150;
        }

        @Override // android.view.View.OnFocusChangeListener
        public void onFocusChange(View view, boolean z) {
            if (C2141.this.m4197() == null) {
                return;
            }
            C2155.C2160 c2160 = (C2155.C2160) C2141.this.m4197().mo564(view);
            if (z) {
                this.f7012 = view;
                InterfaceC2150 interfaceC2150 = this.f7011;
                if (interfaceC2150 != null) {
                    interfaceC2150.mo4058(c2160.f7050);
                }
            } else if (this.f7012 == view) {
                if (C2141.this.f7002 == null) {
                    throw null;
                }
                c2160.m4221(false);
                this.f7012 = null;
            }
            if (C2141.this.f7002 == null) {
                throw null;
            }
        }
    }

    /* JADX INFO: renamed from: މ.މ.ލ.ވ$ރ, reason: contains not printable characters */
    public class ViewOnKeyListenerC2147 implements View.OnKeyListener {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public boolean f7014 = false;

        public ViewOnKeyListenerC2147() {
        }

        @Override // android.view.View.OnKeyListener
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            if (view == null || keyEvent == null || C2141.this.m4197() == null) {
                return false;
            }
            if (i == 23 || i == 66 || i == 160 || i == 99 || i == 100) {
                C2155.C2160 c2160 = (C2155.C2160) C2141.this.m4197().mo564(view);
                C2138 c2138 = c2160.f7050;
                if (c2138.m4180()) {
                    if (!((c2138.f6972 & 8) == 8)) {
                        int action = keyEvent.getAction();
                        if (action != 0) {
                            if (action == 1 && this.f7014) {
                                this.f7014 = false;
                                if (C2141.this.f7002 == null) {
                                    throw null;
                                }
                                c2160.m4221(false);
                            }
                        } else if (!this.f7014) {
                            this.f7014 = true;
                            if (C2141.this.f7002 == null) {
                                throw null;
                            }
                            c2160.m4221(true);
                        }
                    }
                }
                keyEvent.getAction();
                return true;
            }
            return false;
        }
    }

    /* JADX INFO: renamed from: މ.މ.ލ.ވ$ބ, reason: contains not printable characters */
    public interface InterfaceC2148 {
        /* JADX INFO: renamed from: ֏ */
        void mo4066(C2138 c2138);
    }

    /* JADX INFO: renamed from: މ.މ.ލ.ވ$ޅ, reason: contains not printable characters */
    public interface InterfaceC2149 {
    }

    /* JADX INFO: renamed from: މ.މ.ލ.ވ$ކ, reason: contains not printable characters */
    public interface InterfaceC2150 {
        /* JADX INFO: renamed from: ֏ */
        void mo4058(C2138 c2138);
    }

    public C2141(List<C2138> list, InterfaceC2148 interfaceC2148, InterfaceC2150 interfaceC2150, C2155 c2155, boolean z) {
        this.f7000 = list == null ? new ArrayList() : new ArrayList(list);
        this.f7001 = interfaceC2148;
        this.f7002 = c2155;
        this.f6996 = new ViewOnKeyListenerC2147();
        this.f6997 = new ViewOnFocusChangeListenerC2146(interfaceC2150);
        this.f6998 = new C2145();
        this.f6999 = new C2144();
        this.f6995 = z;
        if (z) {
            return;
        }
        this.f7004 = C2154.f7019;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0191
    /* JADX INFO: renamed from: ֏ */
    public int mo327() {
        return this.f7000.size();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public int m4192(C2138 c2138) {
        return this.f7000.indexOf(c2138);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0191
    /* JADX INFO: renamed from: ֏ */
    public RecyclerView.AbstractC0224 mo328(ViewGroup viewGroup, int i) {
        int iMo2069;
        C2155.C2160 c2160;
        C2155 c2155 = this.f7002;
        if (c2155 == null) {
            throw null;
        }
        if (i == 0) {
            c2160 = c2155.mo2043(viewGroup);
        } else {
            LayoutInflater layoutInflaterFrom = LayoutInflater.from(viewGroup.getContext());
            if (i == 0) {
                iMo2069 = c2155.mo2069();
            } else {
                if (i != 1) {
                    throw new RuntimeException(C2803.m4872("ViewType ", i, " not supported in GuidedActionsStylist"));
                }
                iMo2069 = C2079.lb_guidedactions_datepicker_item;
            }
            c2160 = new C2155.C2160(layoutInflaterFrom.inflate(iMo2069, viewGroup, false), viewGroup == c2155.f7023);
        }
        View view = c2160.f1326;
        view.setOnKeyListener(this.f6996);
        view.setOnClickListener(this.f7005);
        view.setOnFocusChangeListener(this.f6997);
        m4194(c2160.m4223());
        m4194(c2160.m4222());
        return c2160;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public C2155.C2160 m4193(View view) {
        if (m4197() == null) {
            return null;
        }
        ViewParent parent = view.getParent();
        while (parent != m4197() && parent != null) {
            view = parent;
            parent = parent.getParent();
        }
        if (parent != null) {
            return (C2155.C2160) m4197().mo564(view);
        }
        return null;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m4194(EditText editText) {
        if (editText != 0) {
            editText.setPrivateImeOptions("escapeNorth");
            editText.setOnEditorActionListener(this.f6998);
            if (editText instanceof InterfaceC2166) {
                ((InterfaceC2166) editText).setImeKeyListener(this.f6998);
            }
            if (editText instanceof InterfaceC2152) {
                ((InterfaceC2152) editText).setOnAutofillListener(this.f6999);
            }
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0191
    /* JADX INFO: renamed from: ֏ */
    public void mo330(RecyclerView.AbstractC0224 abstractC0224, int i) {
        if (i >= this.f7000.size()) {
            return;
        }
        C2155.C2160 c2160 = (C2155.C2160) abstractC0224;
        C2138 c2138 = this.f7000.get(i);
        C2155 c2155 = this.f7002;
        if (c2155 == null) {
            throw null;
        }
        c2160.f7050 = c2138;
        TextView textView = c2160.f7051;
        if (textView != null) {
            textView.setInputType(c2138.f6976);
            c2160.f7051.setText(c2138.f6869);
            c2160.f7051.setAlpha(c2138.m4180() ? c2155.f7027 : c2155.f7028);
            c2160.f7051.setFocusable(false);
            c2160.f7051.setClickable(false);
            c2160.f7051.setLongClickable(false);
            int i2 = Build.VERSION.SDK_INT;
            if (i2 >= 28) {
                if (c2138.m4179()) {
                    c2160.f7051.setAutofillHints(c2138.f6980);
                } else {
                    c2160.f7051.setAutofillHints(null);
                }
            } else if (i2 >= 26) {
                c2160.f7051.setImportantForAutofill(2);
            }
        }
        TextView textView2 = c2160.f7052;
        if (textView2 != null) {
            textView2.setInputType(c2138.f6977);
            c2160.f7052.setText(c2138.f6870);
            c2160.f7052.setVisibility(TextUtils.isEmpty(c2138.f6870) ? 8 : 0);
            c2160.f7052.setAlpha(c2138.m4180() ? c2155.f7029 : c2155.f7030);
            c2160.f7052.setFocusable(false);
            c2160.f7052.setClickable(false);
            c2160.f7052.setLongClickable(false);
            int i3 = Build.VERSION.SDK_INT;
            if (i3 >= 28) {
                if (c2138.m4178()) {
                    c2160.f7052.setAutofillHints(c2138.f6980);
                } else {
                    c2160.f7052.setAutofillHints(null);
                }
            } else if (i3 >= 26) {
                c2160.f7051.setImportantForAutofill(2);
            }
        }
        ImageView imageView = c2160.f7055;
        if (imageView != null) {
            if (c2138.f6981 != 0) {
                imageView.setVisibility(0);
                int i4 = c2138.f6981 == -1 ? R.attr.listChoiceIndicatorMultiple : R.attr.listChoiceIndicatorSingle;
                Context context = c2160.f7055.getContext();
                TypedValue typedValue = new TypedValue();
                c2160.f7055.setImageDrawable(context.getTheme().resolveAttribute(i4, typedValue, true) ? C1850.m3655(context, typedValue.resourceId) : null);
                KeyEvent.Callback callback = c2160.f7055;
                if (callback instanceof Checkable) {
                    ((Checkable) callback).setChecked(c2138.m4177());
                }
            } else {
                imageView.setVisibility(8);
            }
        }
        ImageView imageView2 = c2160.f7054;
        if (imageView2 != null) {
            Drawable drawable = c2138.f6868;
            if (drawable != null) {
                imageView2.setImageLevel(drawable.getLevel());
                imageView2.setImageDrawable(drawable);
                imageView2.setVisibility(0);
            } else {
                imageView2.setVisibility(8);
            }
        }
        if ((c2138.f6972 & 2) == 2) {
            TextView textView3 = c2160.f7051;
            if (textView3 != null) {
                C2155.m4210(textView3, c2155.f7034);
                TextView textView4 = c2160.f7051;
                textView4.setInputType(textView4.getInputType() | 131072);
                TextView textView5 = c2160.f7052;
                if (textView5 != null) {
                    textView5.setInputType(textView5.getInputType() | 131072);
                    c2160.f7052.setMaxHeight((c2155.f7037 - (c2155.f7036 * 2)) - (c2160.f7051.getLineHeight() * (c2155.f7034 * 2)));
                }
            }
        } else {
            TextView textView6 = c2160.f7051;
            if (textView6 != null) {
                C2155.m4210(textView6, c2155.f7033);
            }
            TextView textView7 = c2160.f7052;
            if (textView7 != null) {
                C2155.m4210(textView7, c2155.f7035);
            }
        }
        View view = c2160.f7053;
        if (view != null && (c2138 instanceof C2165)) {
            C2165 c2165 = (C2165) c2138;
            DatePicker datePicker = (DatePicker) view;
            datePicker.setDatePickerFormat(null);
            long j = c2165.f7066;
            if (j != Long.MIN_VALUE) {
                datePicker.setMinDate(j);
            }
            long j2 = c2165.f7067;
            if (j2 != Long.MAX_VALUE) {
                datePicker.setMaxDate(j2);
            }
            Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(c2165.f7065);
            datePicker.m314(calendar.get(1), calendar.get(2), calendar.get(5), false);
        }
        c2155.m4220(c2160, false, false);
        if ((c2138.f6972 & 32) == 32) {
            c2160.f1326.setFocusable(true);
            ((ViewGroup) c2160.f1326).setDescendantFocusability(131072);
        } else {
            c2160.f1326.setFocusable(false);
            ((ViewGroup) c2160.f1326).setDescendantFocusability(393216);
        }
        EditText editTextM4223 = c2160.m4223();
        if (editTextM4223 != null) {
            editTextM4223.setImeOptions(5);
        }
        EditText editTextM4222 = c2160.m4222();
        if (editTextM4222 != null) {
            editTextM4222.setImeOptions(5);
        }
        c2155.m4218(c2160);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void m4195(List<C2138> list) {
        if (!this.f6995) {
            this.f7002.m4216(false);
        }
        ViewOnFocusChangeListenerC2146 viewOnFocusChangeListenerC2146 = this.f6997;
        if (viewOnFocusChangeListenerC2146.f7012 != null && C2141.this.m4197() != null) {
            RecyclerView.AbstractC0224 abstractC0224Mo564 = C2141.this.m4197().mo564(viewOnFocusChangeListenerC2146.f7012);
            if (abstractC0224Mo564 != null) {
                if (C2141.this.f7002 == null) {
                    throw null;
                }
            } else {
                Log.w("GuidedActionAdapter", "RecyclerView returned null view holder", new Throwable());
            }
        }
        if (this.f7004 == null) {
            this.f7000.clear();
            this.f7000.addAll(list);
            this.f1232.m603();
        } else {
            ArrayList arrayList = new ArrayList();
            arrayList.addAll(this.f7000);
            this.f7000.clear();
            this.f7000.addAll(list);
            C2339.m4389(new C2143(arrayList)).m4391(new C2307(this));
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void m4196(C2155.C2160 c2160) {
        InterfaceC2148 interfaceC2148 = this.f7001;
        if (interfaceC2148 != null) {
            interfaceC2148.mo4066(c2160.f7050);
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0191
    /* JADX INFO: renamed from: ؠ */
    public int mo597(int i) {
        C2155 c2155 = this.f7002;
        C2138 c2138 = this.f7000.get(i);
        if (c2155 != null) {
            return c2138 instanceof C2165 ? 1 : 0;
        }
        throw null;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public RecyclerView m4197() {
        return this.f6995 ? this.f7002.f7023 : this.f7002.f7022;
    }
}
