package ca.canadapost.module.postal;

import android.app.SearchManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.appcompat.widget.SearchView;
import androidx.cardview.widget.CardView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.k0;
import androidx.fragment.app.p0;
import androidx.fragment.app.z;
import androidx.lifecycle.c1;
import androidx.lifecycle.d1;
import androidx.lifecycle.e1;
import androidx.lifecycle.g0;
import androidx.lifecycle.z0;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import ca.canadapost.core.common.customView.b0;
import ca.canadapost.core.data.addresscomplete.webservice.AddressCompleteFindItem;
import ca.canadapost.module.postal.FindPostalCodeFragment;
import com.google.android.gms.actions.SearchIntents;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.firebase.analytics.FirebaseAnalytics;
import java.util.List;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import n8.u;
import re.q;
import rm.n0;
import u7.x;
import ve.d;
import w8.d0;
import w8.l0;
import w8.p;
import w8.u;

@Metadata(d1 = {"\u0000¤\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0010\b\u0016\u0018\u0000 \\2\u00020\u00012\b\u0012\u0004\u0012\u00020\u00030\u00022\u00020\u0004:\u0001]B\u0007¢\u0006\u0004\bZ\u0010[J\u0010\u0010\b\u001a\u00020\u00072\u0006\u0010\u0006\u001a\u00020\u0005H\u0002J\u0010\u0010\u000b\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\tH\u0002J\u0010\u0010\u000e\u001a\u00020\u00072\u0006\u0010\r\u001a\u00020\fH\u0002J5\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u0010\u001a\u00020\u000f2\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\b\u0010\u0014\u001a\u0004\u0018\u00010\u00132\u0006\u0010\u0016\u001a\u00020\u00152\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J\u0012\u0010\u001b\u001a\u00020\u00072\b\u0010\u0014\u001a\u0004\u0018\u00010\u0013H\u0016J$\u0010\u001c\u001a\u00020\u00192\u0006\u0010\u0010\u001a\u00020\u000f2\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\b\u0010\u0014\u001a\u0004\u0018\u00010\u0013H\u0016J\u001a\u0010\u001e\u001a\u00020\u00072\u0006\u0010\u001d\u001a\u00020\u00192\b\u0010\u0014\u001a\u0004\u0018\u00010\u0013H\u0016J\b\u0010\u001f\u001a\u00020\u0007H\u0016J\u0010\u0010\"\u001a\u00020\u00072\u0006\u0010!\u001a\u00020 H\u0016J\u0010\u0010$\u001a\u00020\u00052\u0006\u0010\r\u001a\u00020#H\u0016J\u0012\u0010'\u001a\u00020\u00052\b\u0010&\u001a\u0004\u0018\u00010%H\u0016J\u0012\u0010)\u001a\u00020\u00052\b\u0010(\u001a\u0004\u0018\u00010%H\u0016R\u001b\u0010\u0018\u001a\u00020*8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b+\u0010,\u001a\u0004\b-\u0010.R\"\u00106\u001a\u00020/8\u0004@\u0004X\u0085.¢\u0006\u0012\n\u0004\b0\u00101\u001a\u0004\b2\u00103\"\u0004\b4\u00105R\"\u0010>\u001a\u0002078\u0004@\u0004X\u0085.¢\u0006\u0012\n\u0004\b8\u00109\u001a\u0004\b:\u0010;\"\u0004\b<\u0010=R\u0018\u0010B\u001a\u0004\u0018\u00010?8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b@\u0010AR\u0018\u0010E\u001a\u0004\u0018\u00010#8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bC\u0010DR\u0018\u0010I\u001a\u0004\u0018\u00010F8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bG\u0010HR\u0014\u0010M\u001a\u00020J8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bK\u0010LR\u0018\u0010Q\u001a\u0004\u0018\u00010N8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bO\u0010PR\u0018\u0010S\u001a\u0004\u0018\u00010N8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bR\u0010PR\u0014\u0010V\u001a\u00020\u00038\u0016X\u0096\u0005¢\u0006\u0006\u001a\u0004\bT\u0010UR\u0011\u0010Y\u001a\u00020\u00058F¢\u0006\u0006\u001a\u0004\bW\u0010X¨\u0006^"}, d2 = {"Lca/canadapost/module/postal/FindPostalCodeFragment;", "Lu8/b;", "", "Lse/c;", "Landroidx/appcompat/widget/SearchView$l;", "", "showContainer", "Lrm/n0;", "g0", "Landroid/location/Location;", FirebaseAnalytics.Param.LOCATION, "f0", "Lca/canadapost/core/data/addresscomplete/webservice/AddressCompleteFindItem$AddressCompleteRetrieveItem;", "item", "e0", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroidx/lifecycle/u;", "viewLifecycleOwner", "Landroidx/lifecycle/z0;", "viewModel", "Landroid/view/View;", "X", "onCreate", "onCreateView", "view", "onViewCreated", "onDestroyView", "Landroid/view/Menu;", "menu", "onPrepareOptionsMenu", "Landroid/view/MenuItem;", "onOptionsItemSelected", "", SearchIntents.EXTRA_QUERY, "onQueryTextSubmit", "newText", "onQueryTextChange", "Lre/i;", "t", "Lrm/o;", "V", "()Lre/i;", "Ld9/f;", "u", "Ld9/f;", "S", "()Ld9/f;", "setAnalyticsService", "(Ld9/f;)V", "analyticsService", "Lw8/p;", "v", "Lw8/p;", "T", "()Lw8/p;", "setAppExecutors", "(Lw8/p;)V", "appExecutors", "Landroidx/appcompat/widget/SearchView;", "w", "Landroidx/appcompat/widget/SearchView;", "searchView", "x", "Landroid/view/MenuItem;", "searchItem", "Lve/d;", "y", "Lve/d;", "googleMapFragment", "Landroid/content/BroadcastReceiver;", "z", "Landroid/content/BroadcastReceiver;", "mMessageReceiver", "Lcom/google/android/gms/maps/model/Marker;", "A", "Lcom/google/android/gms/maps/model/Marker;", "currentPositionMarker", "B", "selectAddressPositionMarker", "U", "()Lse/c;", "binding", "W", "()Z", "isMenuDoneLoading", "<init>", "()V", "C", "a", "findpostal_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public class FindPostalCodeFragment extends u8.b implements SearchView.l {

    /* renamed from: A, reason: from kotlin metadata */
    private Marker currentPositionMarker;

    /* renamed from: B, reason: from kotlin metadata */
    private Marker selectAddressPositionMarker;

    /* renamed from: u, reason: collision with root package name and from kotlin metadata */
    protected d9.f analyticsService;

    /* renamed from: v, reason: collision with root package name and from kotlin metadata */
    protected p appExecutors;

    /* renamed from: w, reason: collision with root package name and from kotlin metadata */
    private SearchView searchView;

    /* renamed from: x, reason: collision with root package name and from kotlin metadata */
    private MenuItem searchItem;

    /* renamed from: y, reason: collision with root package name and from kotlin metadata */
    private ve.d googleMapFragment;

    /* renamed from: s, reason: collision with root package name */
    private final /* synthetic */ x f10609s = new x(re.o.f34675b);

    /* renamed from: t, reason: collision with root package name and from kotlin metadata */
    private final rm.o viewModel = p0.a(this, kotlin.jvm.internal.p0.b(re.i.class), new n(new m(this)), new o());

    /* renamed from: z, reason: collision with root package name and from kotlin metadata */
    private final BroadcastReceiver mMessageReceiver = new b();

    /* loaded from: classes4.dex */
    public static final class b extends BroadcastReceiver {
        b() {
        }

        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            SearchView searchView;
            t.g(context, "context");
            t.g(intent, "intent");
            String stringExtra = intent.getStringExtra("message");
            if (!FindPostalCodeFragment.this.W() || (searchView = FindPostalCodeFragment.this.searchView) == null) {
                return;
            }
            searchView.d0(stringExtra, true);
        }
    }

    /* loaded from: classes4.dex */
    public static final class c implements MenuItem.OnActionExpandListener {
        c() {
        }

        @Override // android.view.MenuItem.OnActionExpandListener
        public boolean onMenuItemActionCollapse(MenuItem menuItem) {
            t.g(menuItem, "menuItem");
            if (FindPostalCodeFragment.this.getActivity() != null) {
                FindPostalCodeFragment.this.V().f0(false);
                FindPostalCodeFragment.this.C();
                androidx.fragment.app.k activity = FindPostalCodeFragment.this.getActivity();
                if (activity != null) {
                    activity.invalidateOptionsMenu();
                }
            }
            FindPostalCodeFragment.this.g0(false);
            return true;
        }

        @Override // android.view.MenuItem.OnActionExpandListener
        public boolean onMenuItemActionExpand(MenuItem menuItem) {
            t.g(menuItem, "menuItem");
            return t.b(FindPostalCodeFragment.this.V().f8096l.f(), Boolean.TRUE);
        }
    }

    /* loaded from: classes4.dex */
    static final class d extends v implements dn.l {
        d() {
            super(1);
        }

        public final void a(n0 n0Var) {
            FindPostalCodeFragment.this.C();
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((n0) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    static final class e extends v implements dn.l {
        e() {
            super(1);
        }

        public final void a(String str) {
            u.a aVar = u.f29867a;
            androidx.fragment.app.k requireActivity = FindPostalCodeFragment.this.requireActivity();
            t.f(requireActivity, "requireActivity(...)");
            t.d(str);
            aVar.a(requireActivity, str);
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((String) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    public static final class f extends b0 {
        f(Context context) {
            super(context);
        }

        @Override // ca.canadapost.core.common.customView.b0
        public void a() {
            FindPostalCodeFragment.this.g0(false);
        }
    }

    /* loaded from: classes4.dex */
    static final class g extends v implements dn.l {
        g() {
            super(1);
        }

        public final void a(Boolean bool) {
            t.d(bool);
            if (bool.booleanValue()) {
                ve.d dVar = FindPostalCodeFragment.this.googleMapFragment;
                if (dVar != null) {
                    dVar.b0();
                }
                FindPostalCodeFragment.this.V().s0(false);
            }
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((Boolean) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    static final class h extends v implements dn.l {
        h() {
            super(1);
        }

        public final void a(Boolean bool) {
            SwipeRefreshLayout swipeRefreshLayout = FindPostalCodeFragment.this.U().E;
            t.d(bool);
            swipeRefreshLayout.setRefreshing(bool.booleanValue());
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((Boolean) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    static final class i extends v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ s8.o f10624p;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        i(s8.o oVar) {
            super(1);
            this.f10624p = oVar;
        }

        public final void a(List addressCompleteFindItems) {
            t.g(addressCompleteFindItems, "addressCompleteFindItems");
            this.f10624p.N(addressCompleteFindItems);
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((List) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    static final class j extends v implements dn.l {
        j() {
            super(1);
        }

        public final void a(AddressCompleteFindItem.AddressCompleteRetrieveItem addressCompleteRetrieveItem) {
            SearchView searchView;
            if (addressCompleteRetrieveItem != null) {
                Object f10 = FindPostalCodeFragment.this.V().f8094j.f();
                t.d(f10);
                if (((Boolean) f10).booleanValue()) {
                    return;
                }
                FindPostalCodeFragment.this.e0(addressCompleteRetrieveItem);
                FindPostalCodeFragment.this.g0(true);
                FindPostalCodeFragment.this.V().f8094j.q(Boolean.FALSE);
                if (!FindPostalCodeFragment.this.W() || (searchView = FindPostalCodeFragment.this.searchView) == null) {
                    return;
                }
                searchView.clearFocus();
            }
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((AddressCompleteFindItem.AddressCompleteRetrieveItem) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    static final class k extends v implements dn.l {
        k() {
            super(1);
        }

        public final void a(Boolean bool) {
            FindPostalCodeFragment findPostalCodeFragment = FindPostalCodeFragment.this;
            t.d(bool);
            findPostalCodeFragment.g0(bool.booleanValue());
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((Boolean) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    static final class l implements g0, kotlin.jvm.internal.n {

        /* renamed from: a, reason: collision with root package name */
        private final /* synthetic */ dn.l f10627a;

        l(dn.l function) {
            t.g(function, "function");
            this.f10627a = function;
        }

        @Override // kotlin.jvm.internal.n
        public final rm.i b() {
            return this.f10627a;
        }

        @Override // androidx.lifecycle.g0
        public final /* synthetic */ void d(Object obj) {
            this.f10627a.invoke(obj);
        }

        public final boolean equals(Object obj) {
            if ((obj instanceof g0) && (obj instanceof kotlin.jvm.internal.n)) {
                return t.b(b(), ((kotlin.jvm.internal.n) obj).b());
            }
            return false;
        }

        public final int hashCode() {
            return b().hashCode();
        }
    }

    /* loaded from: classes4.dex */
    public static final class m extends v implements dn.a {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ androidx.fragment.app.f f10628p;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public m(androidx.fragment.app.f fVar) {
            super(0);
            this.f10628p = fVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final androidx.fragment.app.f invoke() {
            return this.f10628p;
        }
    }

    /* loaded from: classes4.dex */
    public static final class n extends v implements dn.a {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ dn.a f10629p;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public n(dn.a aVar) {
            super(0);
            this.f10629p = aVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final d1 invoke() {
            d1 viewModelStore = ((e1) this.f10629p.invoke()).getViewModelStore();
            t.f(viewModelStore, "ownerProducer().viewModelStore");
            return viewModelStore;
        }
    }

    /* loaded from: classes4.dex */
    static final class o extends v implements dn.a {
        o() {
            super(0);
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final c1.c invoke() {
            return FindPostalCodeFragment.this.y();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final re.i V() {
        return (re.i) this.viewModel.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void Y(FindPostalCodeFragment this$0) {
        t.g(this$0, "this$0");
        this$0.S().b("Find_Postal_Code_result_List_Adobe", null);
        this$0.V().f0(true);
        MenuItem menuItem = this$0.searchItem;
        if (menuItem != null) {
            menuItem.expandActionView();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void Z(FindPostalCodeFragment this$0, View view, boolean z10) {
        t.g(this$0, "this$0");
        se.c U = this$0.U();
        if (z10) {
            U.B.setImportantForAccessibility(4);
            U.C.setImportantForAccessibility(2);
            U.E.setVisibility(0);
            this$0.g0(false);
            return;
        }
        U.B.setImportantForAccessibility(1);
        U.C.setImportantForAccessibility(1);
        U.E.setVisibility(4);
        if (t.b(this$0.V().f8094j.f(), Boolean.TRUE)) {
            this$0.g0(false);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void a0(FindPostalCodeFragment this$0, Boolean bool) {
        t.g(this$0, "this$0");
        t.d(bool);
        if (bool.booleanValue()) {
            this$0.S().b("Allow_Location_Services_Adobe", null);
        } else {
            this$0.S().b("Dissallow_Location_Service_Adobe", null);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final boolean b0(Marker it) {
        t.g(it, "it");
        return true;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void c0(FindPostalCodeFragment this$0, Location location) {
        t.g(this$0, "this$0");
        t.d(location);
        this$0.f0(location);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void d0(s8.o adapter, FindPostalCodeFragment this$0, RecyclerView recyclerView, int i10, View view) {
        t.g(adapter, "$adapter");
        t.g(this$0, "this$0");
        Object K = adapter.K(i10);
        t.e(K, "null cannot be cast to non-null type ca.canadapost.core.data.addresscomplete.webservice.AddressCompleteFindItem");
        AddressCompleteFindItem addressCompleteFindItem = (AddressCompleteFindItem) K;
        this$0.V().f8089e.q(addressCompleteFindItem);
        if (this$0.W()) {
            SearchView searchView = this$0.searchView;
            if (searchView != null) {
                searchView.setOnQueryTextListener(null);
            }
            SearchView searchView2 = this$0.searchView;
            if (searchView2 != null) {
                searchView2.d0(addressCompleteFindItem.Text, false);
            }
            SearchView searchView3 = this$0.searchView;
            if (searchView3 != null) {
                searchView3.setOnQueryTextListener(this$0);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void e0(AddressCompleteFindItem.AddressCompleteRetrieveItem addressCompleteRetrieveItem) {
        Marker marker = this.selectAddressPositionMarker;
        if (marker != null) {
            if (marker != null) {
                marker.remove();
            }
            this.selectAddressPositionMarker = null;
        }
        try {
            List<Address> fromLocationName = new Geocoder(requireContext(), Locale.CANADA).getFromLocationName(addressCompleteRetrieveItem.Label, 1, 41.681389d, -141.001944d, 83.111389d, -52.619444d);
            if (fromLocationName == null || !(!fromLocationName.isEmpty())) {
                return;
            }
            Address address = fromLocationName.get(0);
            LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
            Location location = new Location("FPC");
            location.setLatitude(address.getLatitude());
            location.setLongitude(address.getLongitude());
            ve.d dVar = this.googleMapFragment;
            if (dVar != null) {
                dVar.S(location);
            }
            BitmapDescriptor fromBitmap = BitmapDescriptorFactory.fromBitmap(l0.d(getContext(), re.m.f34662a));
            t.f(fromBitmap, "fromBitmap(...)");
            MarkerOptions icon = new MarkerOptions().position(latLng).icon(fromBitmap);
            t.f(icon, "icon(...)");
            ve.d dVar2 = this.googleMapFragment;
            this.selectAddressPositionMarker = dVar2 != null ? dVar2.M(icon) : null;
        } catch (Exception e10) {
            tr.a.f36618a.a(e10.getMessage(), new Object[0]);
        }
    }

    private final void f0(Location location) {
        Marker marker = this.currentPositionMarker;
        if (marker != null) {
            if (marker != null) {
                marker.remove();
            }
            this.currentPositionMarker = null;
        }
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        ve.d dVar = this.googleMapFragment;
        if (dVar != null) {
            dVar.S(location);
        }
        BitmapDescriptor fromBitmap = BitmapDescriptorFactory.fromBitmap(l0.d(getContext(), re.m.f34664c));
        t.f(fromBitmap, "fromBitmap(...)");
        MarkerOptions icon = new MarkerOptions().position(latLng).icon(fromBitmap);
        t.f(icon, "icon(...)");
        ve.d dVar2 = this.googleMapFragment;
        this.currentPositionMarker = dVar2 != null ? dVar2.M(icon) : null;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void g0(boolean z10) {
        ViewGroup.LayoutParams layoutParams = U().A.getLayoutParams();
        t.e(layoutParams, "null cannot be cast to non-null type androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams");
        CoordinatorLayout.f fVar = (CoordinatorLayout.f) layoutParams;
        if (z10) {
            ((ViewGroup.MarginLayoutParams) fVar).height = -2;
        } else {
            ((ViewGroup.MarginLayoutParams) fVar).height = 0;
        }
        U().A.setLayoutParams(fVar);
    }

    protected final d9.f S() {
        d9.f fVar = this.analyticsService;
        if (fVar != null) {
            return fVar;
        }
        t.y("analyticsService");
        return null;
    }

    protected final p T() {
        p pVar = this.appExecutors;
        if (pVar != null) {
            return pVar;
        }
        t.y("appExecutors");
        return null;
    }

    public se.c U() {
        return (se.c) this.f10609s.b();
    }

    public final boolean W() {
        return this.searchView != null;
    }

    public View X(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, androidx.lifecycle.u viewLifecycleOwner, z0 viewModel) {
        t.g(inflater, "inflater");
        t.g(viewLifecycleOwner, "viewLifecycleOwner");
        t.g(viewModel, "viewModel");
        return this.f10609s.c(inflater, container, savedInstanceState, viewLifecycleOwner, viewModel);
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setHasOptionsMenu(true);
    }

    @Override // androidx.fragment.app.f
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        t.g(inflater, "inflater");
        androidx.lifecycle.u viewLifecycleOwner = getViewLifecycleOwner();
        t.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
        return X(inflater, container, savedInstanceState, viewLifecycleOwner, V());
    }

    @Override // androidx.fragment.app.f
    public void onDestroyView() {
        super.onDestroyView();
        u4.a.b(requireActivity()).e(this.mMessageReceiver);
    }

    @Override // androidx.fragment.app.f
    public boolean onOptionsItemSelected(MenuItem item) {
        t.g(item, "item");
        if (item.getItemId() != re.n.f34670e) {
            return super.onOptionsItemSelected(item);
        }
        T().b(new Runnable() { // from class: re.f
            @Override // java.lang.Runnable
            public final void run() {
                FindPostalCodeFragment.Y(FindPostalCodeFragment.this);
            }
        }, 10L);
        return true;
    }

    @Override // androidx.fragment.app.f
    public void onPrepareOptionsMenu(Menu menu) {
        t.g(menu, "menu");
        super.onPrepareOptionsMenu(menu);
        menu.clear();
        requireActivity().getMenuInflater().inflate(re.p.f34677a, menu);
        MenuItem findItem = menu.findItem(re.n.f34670e);
        this.searchItem = findItem;
        View actionView = findItem != null ? findItem.getActionView() : null;
        t.e(actionView, "null cannot be cast to non-null type androidx.appcompat.widget.SearchView");
        SearchView searchView = (SearchView) actionView;
        this.searchView = searchView;
        if (searchView != null) {
            searchView.setMaxWidth(Api.BaseClientBuilder.API_PRIORITY_OTHER);
            Object systemService = requireActivity().getSystemService(FirebaseAnalytics.Event.SEARCH);
            t.e(systemService, "null cannot be cast to non-null type android.app.SearchManager");
            searchView.setSearchableInfo(((SearchManager) systemService).getSearchableInfo(requireActivity().getComponentName()));
            searchView.setOnQueryTextListener(this);
            searchView.setQueryHint(requireActivity().getString(q.f34678a));
        }
        SearchView searchView2 = this.searchView;
        if (searchView2 != null) {
            searchView2.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { // from class: re.g
                @Override // android.view.View.OnFocusChangeListener
                public final void onFocusChange(View view, boolean z10) {
                    FindPostalCodeFragment.Z(FindPostalCodeFragment.this, view, z10);
                }
            });
        }
        MenuItem menuItem = this.searchItem;
        if (menuItem != null) {
            menuItem.setOnActionExpandListener(new c());
        }
        if (t.b(V().f8096l.f(), Boolean.TRUE)) {
            MenuItem menuItem2 = this.searchItem;
            t.d(menuItem2);
            onOptionsItemSelected(menuItem2);
        }
        SearchView searchView3 = this.searchView;
        ImageView imageView = searchView3 != null ? (ImageView) searchView3.findViewById(h.f.f20240x) : null;
        if (imageView != null) {
            imageView.setImageResource(re.m.f34663b);
        }
        w8.b.f40952a.a(this.searchView);
    }

    @Override // androidx.appcompat.widget.SearchView.l
    public boolean onQueryTextChange(String newText) {
        V().f8087c.q(newText);
        return true;
    }

    @Override // androidx.appcompat.widget.SearchView.l
    public boolean onQueryTextSubmit(String query) {
        RecyclerView.p layoutManager;
        View M;
        V().f8087c.q(query);
        if (!D() || (layoutManager = U().D.getLayoutManager()) == null || (M = layoutManager.M(0)) == null) {
            return true;
        }
        M.sendAccessibilityEvent(8);
        return true;
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        t.g(view, "view");
        super.onViewCreated(view, bundle);
        androidx.fragment.app.k activity = getActivity();
        if (activity != null) {
            activity.setTitle((CharSequence) V().p0().f());
        }
        CardView detailContainer = U().A;
        t.f(detailContainer, "detailContainer");
        d0.g(detailContainer);
        z childFragmentManager = getChildFragmentManager();
        d.Companion companion = ve.d.INSTANCE;
        androidx.fragment.app.f l02 = childFragmentManager.l0(companion.a());
        ve.d dVar = l02 instanceof ve.d ? (ve.d) l02 : null;
        this.googleMapFragment = dVar;
        if (dVar == null) {
            this.googleMapFragment = new ve.d();
            new Bundle().putBoolean("GOOGLE_MAP_HIDE_LOCATION_BUTTON", true);
            k0 p10 = getChildFragmentManager().p();
            int i10 = re.n.f34667b;
            ve.d dVar2 = this.googleMapFragment;
            t.d(dVar2);
            p10.c(i10, dVar2, companion.a()).i();
        }
        ve.d dVar3 = this.googleMapFragment;
        if (dVar3 != null) {
            dVar3.U(new w8.f() { // from class: re.b
                @Override // w8.f
                public final void accept(Object obj) {
                    FindPostalCodeFragment.a0(FindPostalCodeFragment.this, (Boolean) obj);
                }
            });
        }
        ve.d dVar4 = this.googleMapFragment;
        if (dVar4 != null) {
            dVar4.V(new GoogleMap.OnMarkerClickListener() { // from class: re.c
                @Override // com.google.android.gms.maps.GoogleMap.OnMarkerClickListener
                public final boolean onMarkerClick(Marker marker) {
                    boolean b02;
                    b02 = FindPostalCodeFragment.b0(marker);
                    return b02;
                }
            });
        }
        ve.d dVar5 = this.googleMapFragment;
        if (dVar5 != null) {
            dVar5.T(new w8.f() { // from class: re.d
                @Override // w8.f
                public final void accept(Object obj) {
                    FindPostalCodeFragment.c0(FindPostalCodeFragment.this, (Location) obj);
                }
            });
        }
        V().q0().j(getViewLifecycleOwner(), new l(new g()));
        U().E.setEnabled(false);
        V().f8090f.j(getViewLifecycleOwner(), new l(new h()));
        final s8.o oVar = new s8.o(V().f8087c, new s8.p(), getContext());
        U().D.setAdapter(oVar);
        Context context = U().D.getContext();
        RecyclerView.p layoutManager = U().D.getLayoutManager();
        t.e(layoutManager, "null cannot be cast to non-null type androidx.recyclerview.widget.LinearLayoutManager");
        androidx.recyclerview.widget.g gVar = new androidx.recyclerview.widget.g(context, ((LinearLayoutManager) layoutManager).t2());
        Resources resources = getResources();
        int i11 = re.m.f34665d;
        Context context2 = getContext();
        Drawable f10 = androidx.core.content.res.h.f(resources, i11, context2 != null ? context2.getTheme() : null);
        if (f10 != null) {
            gVar.m(f10);
        }
        U().D.h(gVar);
        V().f8088d.j(getViewLifecycleOwner(), new l(new i(oVar)));
        w8.u.e(U().D).f(new u.d() { // from class: re.e
            @Override // w8.u.d
            public final void a(RecyclerView recyclerView, int i12, View view2) {
                FindPostalCodeFragment.d0(s8.o.this, this, recyclerView, i12, view2);
            }
        });
        V().f8093i.j(getViewLifecycleOwner(), new l(new j()));
        V().r0().j(getViewLifecycleOwner(), new l(new k()));
        V().o0().j(getViewLifecycleOwner(), new l(new d()));
        V().n0().j(getViewLifecycleOwner(), new l(new e()));
        U().A.setOnTouchListener(new f(getContext()));
        u4.a.b(requireActivity()).c(this.mMessageReceiver, new IntentFilter("VoiceSearch"));
    }
}
