package com.scb.phone.view.adapter.mwpartner; import android.content.Context; import android.text.SpannableString; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Filter; import android.widget.Filterable; import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; import com.google.android.gms.tasks.Task; import com.google.android.gms.tasks.Tasks; import com.google.android.libraries.places.api.model.AutocompletePrediction; import com.google.android.libraries.places.api.model.AutocompleteSessionToken; import com.google.android.libraries.places.api.model.RectangularBounds; import com.google.android.libraries.places.api.net.FindAutocompletePredictionsRequest; import com.google.android.libraries.places.api.net.FindAutocompletePredictionsResponse; import com.google.android.libraries.places.api.net.PlacesClient; import com.scb.phone.R; import com.scb.phone.view.adapter.mwpartner.MwPlaceAdapter; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; import o.C14851gaI; import o.C14866gag; import o.C14957gcv; import o.pyT; /* loaded from: classes5.dex */ public final class MwPlaceAdapter extends RecyclerView.Sts implements Filterable { public AutocompleteSessionToken a; public PlacesClient b; public Context c; public LWm d; public RectangularBounds e; private ArrayList j; /* loaded from: classes5.dex */ public interface LWm { void R(); void ax(); void d(String str); } /* loaded from: classes5.dex */ public final class PredictionHolder_ViewBinding implements Unbinder { private PredictionHolder d; public PredictionHolder_ViewBinding(PredictionHolder predictionHolder, View view) { this.d = predictionHolder; predictionHolder.tvPlace = (TextView) pyT.e(view, R.id.tv_place, "field 'tvPlace'", TextView.class); predictionHolder.tvAddress = (TextView) pyT.e(view, R.id.tv_address, "field 'tvAddress'", TextView.class); } @Override // butterknife.Unbinder public final void a() { PredictionHolder predictionHolder = this.d; if (predictionHolder == null) { throw new IllegalStateException("Bindings already cleared."); } this.d = null; predictionHolder.tvPlace = null; predictionHolder.tvAddress = null; } } @Override // androidx.recyclerview.widget.RecyclerView.Sts public final /* synthetic */ void onBindViewHolder(PredictionHolder predictionHolder, int i) { PredictionHolder predictionHolder2 = predictionHolder; C14957gcv.e(predictionHolder2, ""); ArrayList arrayList = this.j; if (arrayList != null) { Sts sts = arrayList.get(i); C14957gcv.c(sts, ""); Sts sts2 = sts; C14957gcv.e(sts2, ""); TextView textView = predictionHolder2.tvPlace; TextView textView2 = null; if (textView == null) { C14957gcv.a(""); textView = null; } textView.setText(sts2.b); CharSequence charSequence = sts2.a; if (charSequence != null) { TextView textView3 = predictionHolder2.tvAddress; if (textView3 != null) { textView2 = textView3; } else { C14957gcv.a(""); } textView2.setText(charSequence); } final String str = sts2.c; if (str != null) { final MwPlaceAdapter mwPlaceAdapter = predictionHolder2.d; predictionHolder2.itemView.setOnClickListener(new View.OnClickListener(mwPlaceAdapter, str) { // from class: o.exj private String d; private MwPlaceAdapter e; @Override // android.view.View.OnClickListener public final void onClick(View view) { MwPlaceAdapter.PredictionHolder.d(this.e, this.d); } { this.e = mwPlaceAdapter; this.d = str; } }); } } } @Override // androidx.recyclerview.widget.RecyclerView.Sts public final /* synthetic */ PredictionHolder onCreateViewHolder(ViewGroup viewGroup, int i) { C14957gcv.e(viewGroup, ""); Context context = this.c; if (context == null) { C14957gcv.a(""); context = null; } Object systemService = context.getSystemService("layout_inflater"); C14957gcv.d(systemService, ""); View inflate = ((LayoutInflater) systemService).inflate(R.layout.2131560019, viewGroup, false); C14957gcv.c(inflate, ""); return new PredictionHolder(this, inflate); } @Override // androidx.recyclerview.widget.RecyclerView.Sts public final int getItemCount() { ArrayList arrayList = this.j; if (arrayList != null) { return arrayList.size(); } return 0; } /* loaded from: classes5.dex */ public static final class HBt extends Filter { private MwPlaceAdapter e; HBt(MwPlaceAdapter mwPlaceAdapter) { this.e = mwPlaceAdapter; } @Override // android.widget.Filter protected final Filter.FilterResults performFiltering(CharSequence charSequence) { ArrayList arrayList = this.e.j; if (arrayList != null) { arrayList.clear(); } Filter.FilterResults filterResults = new Filter.FilterResults(); if (charSequence != null) { MwPlaceAdapter mwPlaceAdapter = this.e; List b = mwPlaceAdapter.b(charSequence); List list = b; C14957gcv.e(list, ""); mwPlaceAdapter.j = new ArrayList(list); filterResults.values = b; filterResults.count = b.size(); } return filterResults; } @Override // android.widget.Filter protected final void publishResults(CharSequence charSequence, Filter.FilterResults filterResults) { C14866gag c14866gag; LWm lWm = null; if (filterResults != null) { MwPlaceAdapter mwPlaceAdapter = this.e; if (filterResults.count <= 0) { LWm lWm2 = mwPlaceAdapter.d; if (lWm2 == null) { C14957gcv.a(""); lWm2 = null; } lWm2.ax(); } else { mwPlaceAdapter.notifyDataSetChanged(); LWm lWm3 = mwPlaceAdapter.d; if (lWm3 == null) { C14957gcv.a(""); lWm3 = null; } lWm3.R(); } c14866gag = C14866gag.c; } else { c14866gag = null; } if (c14866gag == null) { LWm lWm4 = this.e.d; if (lWm4 == null) { C14957gcv.a(""); } else { lWm = lWm4; } lWm.ax(); } } } @Override // android.widget.Filterable public final Filter getFilter() { return new HBt(this); } /* JADX INFO: Access modifiers changed from: private */ public final List b(CharSequence charSequence) { FindAutocompletePredictionsResponse result; List autocompletePredictions; FindAutocompletePredictionsRequest.Builder builder = FindAutocompletePredictionsRequest.builder(); RectangularBounds rectangularBounds = this.e; ArrayList arrayList = null; if (rectangularBounds == null) { C14957gcv.a(""); rectangularBounds = null; } FindAutocompletePredictionsRequest build = builder.setLocationBias(rectangularBounds).setCountry("TH").setSessionToken(this.a).setQuery(String.valueOf(charSequence)).build(); PlacesClient placesClient = this.b; if (placesClient == null) { C14957gcv.a(""); placesClient = null; } Task findAutocompletePredictions = placesClient.findAutocompletePredictions(build); try { Tasks.await(findAutocompletePredictions, 60L, TimeUnit.SECONDS); if (findAutocompletePredictions.isSuccessful() && (result = findAutocompletePredictions.getResult()) != null && (autocompletePredictions = result.getAutocompletePredictions()) != null) { C14957gcv.c(autocompletePredictions, ""); List list = autocompletePredictions; C14957gcv.e(list, ""); ArrayList arrayList2 = new ArrayList(list instanceof Collection ? list.size() : 10); for (AutocompletePrediction autocompletePrediction : list) { String placeId = autocompletePrediction.getPlaceId(); SpannableString primaryText = autocompletePrediction.getPrimaryText(null); C14957gcv.c(primaryText, ""); arrayList2.add(new Sts(this, placeId, primaryText, autocompletePrediction.getSecondaryText(null))); } arrayList = arrayList2; } return arrayList == null ? C14851gaI.c : arrayList; } catch (Exception unused) { return C14851gaI.c; } } /* loaded from: classes5.dex */ public final class PredictionHolder extends RecyclerView.zJl { final MwPlaceAdapter d; @BindView public TextView tvAddress; @BindView public TextView tvPlace; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public PredictionHolder(MwPlaceAdapter mwPlaceAdapter, View view) { super(view); C14957gcv.e(view, ""); this.d = mwPlaceAdapter; ButterKnife.c(this, view); } public static /* synthetic */ void d(MwPlaceAdapter mwPlaceAdapter, String str) { C14957gcv.e(mwPlaceAdapter, ""); C14957gcv.e(str, ""); LWm lWm = mwPlaceAdapter.d; if (lWm == null) { C14957gcv.a(""); lWm = null; } lWm.d(str); } } /* loaded from: classes5.dex */ public final class Sts { CharSequence a; CharSequence b; String c; private MwPlaceAdapter d; public Sts(MwPlaceAdapter mwPlaceAdapter, String str, CharSequence charSequence, CharSequence charSequence2) { C14957gcv.e(charSequence, ""); this.d = mwPlaceAdapter; this.c = str; this.b = charSequence; this.a = charSequence2; } } /* loaded from: classes5.dex */ public static final class IeS { private IeS() { } public /* synthetic */ IeS(byte b) { this(); } } static { new IeS((byte) 0); } }