what-the-bank/sources/com/google/android/libraries/places/widget/AutocompleteSupportFragment...

314 lines
11 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.libraries.places.widget;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.LiveData;
import com.google.android.libraries.places.R;
import com.google.android.libraries.places.api.model.LocationBias;
import com.google.android.libraries.places.api.model.LocationRestriction;
import com.google.android.libraries.places.api.model.Place;
import com.google.android.libraries.places.api.model.TypeFilter;
import com.google.android.libraries.places.internal.zzgb;
import com.google.android.libraries.places.internal.zzgp;
import com.google.android.libraries.places.internal.zzgq;
import com.google.android.libraries.places.internal.zzgr;
import com.google.android.libraries.places.internal.zzgu;
import com.google.android.libraries.places.internal.zziy;
import com.google.android.libraries.places.widget.Autocomplete;
import com.google.android.libraries.places.widget.listener.PlaceSelectionListener;
import com.google.android.libraries.places.widget.model.AutocompleteActivityMode;
import java.util.List;
import o.HeN;
import o.zBc;
/* loaded from: classes2.dex */
public class AutocompleteSupportFragment extends Fragment {
private final HeN zza;
private final HeN zzb;
private zzgq zzc;
private PlaceSelectionListener zzd;
public AutocompleteSupportFragment() {
super(R.layout.places_autocomplete_fragment);
this.zza = new HeN();
this.zzb = new HeN();
this.zzc = zzgr.zzn(AutocompleteActivityMode.OVERLAY, zziy.zzm(), zzgp.FRAGMENT);
}
public static AutocompleteSupportFragment newInstance() {
return new AutocompleteSupportFragment();
}
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ void zzd(EditText editText, View view, CharSequence charSequence) {
try {
editText.setHint(charSequence);
view.setContentDescription(charSequence);
} catch (Error | RuntimeException e) {
zzgb.zzb(e);
throw e;
}
}
private final void zze() {
Intent build = new Autocomplete.IntentBuilder(this.zzc.zzm()).build(requireContext());
if (requireView().isEnabled()) {
requireView().setEnabled(false);
startActivityForResult(build, 30421);
}
}
@Override // androidx.fragment.app.Fragment
public void onActivityResult(int i, int i2, Intent intent) {
if (i == 30421) {
try {
PlaceSelectionListener placeSelectionListener = this.zzd;
if (placeSelectionListener == null) {
Log.isLoggable("Places", 5);
return;
}
if (intent == null) {
Log.isLoggable("Places", 6);
} else {
if (i2 == -1) {
Place placeFromIntent = Autocomplete.getPlaceFromIntent(intent);
placeSelectionListener.onPlaceSelected(placeFromIntent);
setText(placeFromIntent.getName());
return;
}
placeSelectionListener.onError(Autocomplete.getStatusFromIntent(intent));
}
} catch (Error | RuntimeException e) {
zzgb.zzb(e);
throw e;
}
}
}
@Override // androidx.fragment.app.Fragment
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (bundle != null) {
try {
zzgr zzgrVar = (zzgr) bundle.getParcelable("options");
if (zzgrVar != null) {
Object obj = this.zza.d;
if (obj == LiveData.c) {
obj = null;
}
if (obj == null) {
this.zza.e((HeN) zzgrVar.zzm());
}
Object obj2 = this.zzb.d;
if ((obj2 != LiveData.c ? obj2 : null) == null) {
this.zzb.e((HeN) zzgrVar.zzl());
}
this.zzc = zzgrVar.zzg();
}
} catch (Error | RuntimeException e) {
zzgb.zzb(e);
throw e;
}
}
}
@Override // androidx.fragment.app.Fragment
public void onResume() {
super.onResume();
requireView().setEnabled(true);
}
@Override // androidx.fragment.app.Fragment
public void onSaveInstanceState(Bundle bundle) {
bundle.putParcelable("options", this.zzc.zzm());
}
@Override // androidx.fragment.app.Fragment
public void onViewCreated(View view, Bundle bundle) {
final View findViewById = view.findViewById(R.id.places_autocomplete_search_button);
final View findViewById2 = view.findViewById(R.id.places_autocomplete_clear_button);
final EditText editText = (EditText) view.findViewById(R.id.places_autocomplete_search_input);
editText.setHint(zzgu.zzc(requireContext(), R.string.places_autocomplete_search_hint));
findViewById.setOnClickListener(new View.OnClickListener(this) { // from class: com.google.android.libraries.places.widget.zze
public final AutocompleteSupportFragment zza;
@Override // android.view.View.OnClickListener
public final void onClick(View view2) {
this.zza.zza(view2);
}
{
this.zza = this;
}
});
editText.setOnClickListener(new View.OnClickListener(this) { // from class: com.google.android.libraries.places.widget.zzf
public final AutocompleteSupportFragment zza;
@Override // android.view.View.OnClickListener
public final void onClick(View view2) {
this.zza.zzb(view2);
}
{
this.zza = this;
}
});
findViewById2.setOnClickListener(new View.OnClickListener(this) { // from class: com.google.android.libraries.places.widget.zzg
public final AutocompleteSupportFragment zza;
@Override // android.view.View.OnClickListener
public final void onClick(View view2) {
this.zza.setText(null);
}
{
this.zza = this;
}
});
zzf(findViewById2);
this.zza.d(getViewLifecycleOwner(), new zBc(this, editText, findViewById2) { // from class: com.google.android.libraries.places.widget.zzh
public final AutocompleteSupportFragment zza;
public final EditText zzb;
public final View zzc;
@Override // o.zBc
public final void onChanged(Object obj) {
this.zza.zzc(this.zzb, this.zzc, (CharSequence) obj);
}
{
this.zza = this;
this.zzb = editText;
this.zzc = findViewById2;
}
});
this.zzb.d(getViewLifecycleOwner(), new zBc(editText, findViewById) { // from class: com.google.android.libraries.places.widget.zzi
public final EditText zza;
public final View zzb;
@Override // o.zBc
public final void onChanged(Object obj) {
AutocompleteSupportFragment.zzd(this.zza, this.zzb, (CharSequence) obj);
}
{
this.zza = editText;
this.zzb = findViewById;
}
});
}
public AutocompleteSupportFragment setActivityMode(AutocompleteActivityMode autocompleteActivityMode) {
this.zzc.zzf(autocompleteActivityMode);
return this;
}
public AutocompleteSupportFragment setCountries(List<String> list) {
this.zzc.zza(list);
return this;
}
public AutocompleteSupportFragment setCountry(String str) {
this.zzc.zzn(str);
return this;
}
public AutocompleteSupportFragment setHint(CharSequence charSequence) {
try {
if (charSequence == null) {
String string = getString(R.string.places_autocomplete_search_hint);
this.zzc.zzb(string);
this.zzb.e((HeN) string);
} else {
this.zzc.zzb(charSequence.toString());
this.zzb.e((HeN) charSequence);
}
return this;
} catch (Error | RuntimeException e) {
zzgb.zzb(e);
throw e;
}
}
public AutocompleteSupportFragment setLocationBias(LocationBias locationBias) {
this.zzc.zzd(locationBias);
return this;
}
public AutocompleteSupportFragment setLocationRestriction(LocationRestriction locationRestriction) {
this.zzc.zze(locationRestriction);
return this;
}
public AutocompleteSupportFragment setPlaceFields(List<Place.Field> list) {
this.zzc.zzh(list);
return this;
}
public AutocompleteSupportFragment setText(CharSequence charSequence) {
try {
this.zzc.zzc(TextUtils.isEmpty(charSequence) ? null : charSequence.toString());
this.zza.e((HeN) charSequence);
return this;
} catch (Error | RuntimeException e) {
zzgb.zzb(e);
throw e;
}
}
@Deprecated
public AutocompleteSupportFragment setTypeFilter(TypeFilter typeFilter) {
this.zzc.zzk(typeFilter);
return this;
}
public AutocompleteSupportFragment setTypesFilter(List<String> list) {
this.zzc.zzl(list);
return this;
}
/* JADX INFO: Access modifiers changed from: package-private */
public final /* synthetic */ void zza(View view) {
zze();
}
/* JADX INFO: Access modifiers changed from: package-private */
public final /* synthetic */ void zzb(View view) {
zze();
}
/* JADX INFO: Access modifiers changed from: package-private */
public final /* synthetic */ void zzc(EditText editText, View view, CharSequence charSequence) {
try {
editText.setText(charSequence);
zzf(view);
} catch (Error | RuntimeException e) {
zzgb.zzb(e);
throw e;
}
}
public AutocompleteSupportFragment setCountries(String... strArr) {
this.zzc.zza(zziy.zzl(strArr));
return this;
}
private final void zzf(View view) {
Object obj = this.zza.d;
if (obj == LiveData.c) {
obj = null;
}
view.setVisibility(true != TextUtils.isEmpty((CharSequence) obj) ? 0 : 8);
}
public AutocompleteSupportFragment setOnPlaceSelectedListener(PlaceSelectionListener placeSelectionListener) {
this.zzd = placeSelectionListener;
return this;
}
}