package com.scb.phone.view.fragment.findus; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.location.Location; import android.location.LocationManager; import android.net.Uri; import android.os.Bundle; import android.os.Looper; import android.os.SystemClock; import android.text.TextUtils; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.fragment.app.FragmentActivity; import butterknife.BindView; import butterknife.OnClick; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationCallback; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationResult; import com.google.android.gms.location.LocationServices; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.OnMapReadyCallback; 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.MarkerOptions; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.huawei.hms.support.api.entity.common.CommonConstant; import com.scb.phone.R; import com.scb.phone.view.activity.BaseActivity; import com.scb.phone.view.activity.findus.SelectProvinceOrDistrictActivity; import com.scb.phone.view.custom.common.DefaultButton; import com.scb.phone.view.fragment.BaseFragment; import com.scb.phone.view.fragment.findus.BaseMapTabFragment; import java.util.List; import java.util.NoSuchElementException; import java.util.concurrent.TimeUnit; import o.AHS; import o.AbstractC13163fSk; import o.C0693Mj; import o.C13417fZt; import o.C4975bkM; import o.C8949daW; import o.EnumC8951daY; import o.InterfaceC13391fZD; import o.InterfaceC6663cZf; import o.MP; import o.XxC; import o.YKU; import o.eZD; import o.fRR; import o.fSJ; import o.fSQ; import o.glR; import o.guQ; import o.zEQ; /* loaded from: classes5.dex */ public abstract class BaseMapTabFragment extends BaseFragment implements InterfaceC6663cZf.HBt, OnMapReadyCallback, C8949daW.LWm { protected String c; private BitmapDescriptor d; private FusedLocationProviderClient i; private LocationCallback k; private boolean l; private LocationRequest m; @BindView protected DefaultButton mCallButton; @BindView protected TextView mDistrict; @BindView protected RelativeLayout mInfoLayout; @BindView protected MapView mMapView; @BindView protected TextView mMarkerAddress; @BindView protected TextView mMarkerName; @BindView protected TextView mMarkerOpenHour; @BindView protected TextView mMarkerPhone; @BindView protected FloatingActionButton mMyLocationButton; @BindView protected TextView mProvince; @BindView protected FloatingActionButton mSearchButton; @BindView protected RelativeLayout mSearchLayout; @InterfaceC13391fZD public C4975bkM mapTabPresenter; /* renamed from: o, reason: collision with root package name */ private C8949daW f8041o; private fSJ q; private Location r; private GoogleMap s; private LocationManager t; private double v; private double y; private boolean h = false; private int p = 0; private double f = -99.0d; private double g = -189.0d; private long n = 0; private boolean j = false; @Override // o.C8949daW.LWm public final /* synthetic */ boolean a(MP mp) { MP mp2 = mp; a(new LatLng(mp2.b, mp2.d)); if (!TextUtils.isEmpty(mp2.a)) { this.mMarkerName.setText(String.format(getString(R.string.marker_title_value), mp2.j, mp2.a)); } else { this.mMarkerName.setText(mp2.j); } this.mMarkerAddress.setText(mp2.c); if (mp2.h == null || !mp2.h.isEmpty()) { this.mMarkerOpenHour.setText(mp2.h); } if (mp2.i == null || !mp2.i.isEmpty()) { this.mMarkerPhone.setText(mp2.i); } RelativeLayout relativeLayout = this.mInfoLayout; Animation loadAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.2130772001); loadAnimation.setDuration(300L); relativeLayout.startAnimation(loadAnimation); relativeLayout.setVisibility(0); this.mCallButton.setVisibility("ATM".equals(this.c) ? 8 : 0); this.mSearchLayout.setVisibility(8); this.mMyLocationButton.setVisibility(8); this.mSearchButton.setVisibility(8); this.v = mp2.b; this.y = mp2.d; return false; } @Override // com.scb.phone.view.fragment.BaseFragment, androidx.fragment.app.Fragment public void onActivityCreated(Bundle bundle) { super.onActivityCreated(bundle); LocationManager locationManager = (LocationManager) getContext().getSystemService("location"); this.t = locationManager; this.l = locationManager != null && locationManager.isProviderEnabled("gps"); LocationManager locationManager2 = this.t; if (locationManager2 == null || !locationManager2.isProviderEnabled("gps")) { this.p = 1; e(getString(R.string.gps_disabled), EnumC8951daY.ERROR); } MapView mapView = this.mMapView; if (mapView != null) { mapView.onCreate(bundle); if (getUserVisibleHint()) { this.mMapView.getMapAsync(this); } } this.q = AbstractC13163fSk.interval(5L, TimeUnit.SECONDS).subscribeOn(C13417fZt.c()).observeOn(fRR.e()).subscribe(new fSQ(this) { // from class: o.eZE private BaseMapTabFragment b; @Override // o.fSQ public final void c(Object obj) { BaseMapTabFragment.c(this.b); } { this.b = this; } }, new fSQ() { // from class: o.eZC @Override // o.fSQ public final void c(Object obj) { guQ.a((Throwable) obj); } }); ((BaseFragment) this).b = glR.Ge_(getContext(), new IntentFilter("com.scb.phone/BROADCAST_UPDATE_SELECTED_ITEM")).subscribe(new fSQ(this) { // from class: o.eZA private BaseMapTabFragment e; @Override // o.fSQ public final void c(Object obj) { BaseMapTabFragment.asW_(this.e, (Intent) obj); } { this.e = this; } }, new fSQ() { // from class: o.eZC @Override // o.fSQ public final void c(Object obj) { guQ.a((Throwable) obj); } }); } @Override // androidx.fragment.app.Fragment public void setUserVisibleHint(boolean z) { MapView mapView; super.setUserVisibleHint(z); if (!z || (mapView = this.mMapView) == null || this.h) { return; } mapView.getMapAsync(this); } @Override // androidx.fragment.app.Fragment public void onResume() { super.onResume(); this.j = false; MapView mapView = this.mMapView; if (mapView != null) { mapView.onResume(); } LocationManager locationManager = this.t; if (locationManager == null || !locationManager.isProviderEnabled("gps")) { e(getString(R.string.gps_disabled), EnumC8951daY.ERROR); } } @Override // androidx.fragment.app.Fragment public void onPause() { super.onPause(); this.j = true; } @Override // com.scb.phone.view.fragment.BaseFragment, androidx.fragment.app.Fragment public void onDestroy() { LocationCallback locationCallback; MapView mapView = this.mMapView; if (mapView != null) { mapView.onDestroy(); } FusedLocationProviderClient fusedLocationProviderClient = this.i; if (fusedLocationProviderClient != null && (locationCallback = this.k) != null) { fusedLocationProviderClient.removeLocationUpdates(locationCallback); } fSJ fsj = this.q; if (fsj != null && !fsj.isDisposed()) { this.q.dispose(); } C4975bkM c4975bkM = this.mapTabPresenter; if (c4975bkM != null) { c4975bkM.w_(); } super.onDestroy(); } @Override // androidx.fragment.app.Fragment, android.content.ComponentCallbacks public void onLowMemory() { MapView mapView = this.mMapView; if (mapView != null) { mapView.onLowMemory(); } super.onLowMemory(); } @Override // com.google.android.gms.maps.OnMapReadyCallback public void onMapReady(GoogleMap googleMap) { this.d = BitmapDescriptorFactory.fromResource("Branch".equals(this.c) ? R.drawable.ic_pin_branch : R.drawable.ic_pin_atm); this.s = googleMap; C8949daW c8949daW = new C8949daW<>(getContext(), this.s); this.f8041o = c8949daW; IeS ieS = new IeS(this, getContext(), this.s, this.f8041o); c8949daW.j.e(); c8949daW.j.a(null); c8949daW.d.e(); c8949daW.a.e(); c8949daW.j.d(); c8949daW.j = ieS; ieS.c(); AHS ahs = c8949daW.j; C8949daW.HBt hBt = c8949daW.i; ahs.e(); AHS ahs2 = c8949daW.j; C8949daW.IeS ieS2 = c8949daW.h; ahs2.a(); c8949daW.j.a(c8949daW.f); AHS ahs3 = c8949daW.j; C8949daW.Sts sts = c8949daW.g; ahs3.b(); c8949daW.b(); C8949daW c8949daW2 = this.f8041o; c8949daW2.f = this; c8949daW2.j.a(this); this.s.getUiSettings().setMyLocationButtonEnabled(false); this.s.getUiSettings().setMapToolbarEnabled(false); this.s.setOnMarkerClickListener(this.f8041o); this.s.setOnCameraIdleListener(this.f8041o); eZD.b(this); } /* JADX INFO: Access modifiers changed from: private */ public void f() { LocationManager locationManager; if (this.r != null && (locationManager = this.t) != null && locationManager.isProviderEnabled("gps")) { a(new LatLng(this.r.getLatitude(), this.r.getLongitude())); } else { a(new LatLng(13.75d, 100.5d)); } } private void a(LatLng latLng) { int i = this.p; if (i >= 2) { return; } this.p = i + 1; this.s.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15.0f)); if (this.r != null) { C4975bkM c4975bkM = this.mapTabPresenter; double d = latLng.latitude; double d2 = latLng.longitude; double latitude = this.r.getLatitude(); double longitude = this.r.getLongitude(); String str = this.c; LocationManager locationManager = this.t; c4975bkM.e(d, d2, latitude, longitude, str, locationManager != null && locationManager.isProviderEnabled("gps")); return; } C4975bkM c4975bkM2 = this.mapTabPresenter; double d3 = latLng.latitude; double d4 = latLng.longitude; String str2 = this.c; LocationManager locationManager2 = this.t; c4975bkM2.e(d3, d4, -99.0d, -189.0d, str2, locationManager2 != null && locationManager2.isProviderEnabled("gps")); } private void d(String str) { Intent intent = new Intent(getContext(), (Class) SelectProvinceOrDistrictActivity.class); if (str == null) { str = ""; } intent.putExtra("PROVINCE_NAME", str); startActivity(intent); } @Override // o.InterfaceC6663cZf.HBt public final void c(List list) { GoogleMap googleMap = this.s; if (googleMap == null || this.f8041o == null) { return; } googleMap.clear(); C8949daW c8949daW = this.f8041o; c8949daW.b.writeLock().lock(); try { c8949daW.e.a(); c8949daW.b.writeLock().unlock(); c8949daW = this.f8041o; c8949daW.b.writeLock().lock(); try { c8949daW.e.b(list); c8949daW.b.writeLock().unlock(); this.f8041o.b(); } finally { } } finally { } } private void i() { synchronized (this) { this.i = LocationServices.getFusedLocationProviderClient(requireContext()); LocationRequest create = LocationRequest.create(); this.m = create; create.setInterval(5000L); this.m.setFastestInterval(5000L); this.m.setPriority(100); LocationCallback locationCallback = new LocationCallback(this) { // from class: com.scb.phone.view.fragment.findus.BaseMapTabFragment.5 private BaseMapTabFragment b; { this.b = this; } @Override // com.google.android.gms.location.LocationCallback public final void onLocationResult(LocationResult locationResult) { for (Location location : locationResult.getLocations()) { if (location != null) { this.b.r = location; this.b.f(); } } } }; this.k = locationCallback; this.i.requestLocationUpdates(this.m, locationCallback, (Looper) null); } } @Override // androidx.fragment.app.Fragment public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) { super.onRequestPermissionsResult(i, strArr, iArr); eZD.d(this, i, iArr); } public final void d() { try { this.h = true; this.s.setMyLocationEnabled(true); LocationManager locationManager = this.t; if (locationManager == null || !locationManager.isProviderEnabled("gps")) { if (!this.j) { e(getString(R.string.gps_disabled), EnumC8951daY.ERROR); } f(); return; } i(); } catch (SecurityException e) { guQ.c(e, "requestPermission exception", new Object[0]); } } public final void h() { if (getUserVisibleHint()) { f(); e(getString(R.string.permission_location_denied), EnumC8951daY.ERROR); } } public final void j() { if (getUserVisibleHint()) { f(); e(getString(R.string.permission_location_never_ask_again), EnumC8951daY.ERROR); } } /* JADX INFO: Access modifiers changed from: package-private */ @OnClick public void onMyLocationClick() { LocationManager locationManager = this.t; if (locationManager == null || !locationManager.isProviderEnabled("gps")) { e(getString(R.string.gps_disabled), EnumC8951daY.ERROR); } else { this.p = 1; f(); } } /* JADX INFO: Access modifiers changed from: package-private */ @OnClick public void onSearchFloatingButtonClick() { RelativeLayout relativeLayout = this.mSearchLayout; Animation loadAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.2130772001); loadAnimation.setDuration(300L); relativeLayout.startAnimation(loadAnimation); relativeLayout.setVisibility(0); this.mInfoLayout.setVisibility(8); this.mMyLocationButton.setVisibility(8); this.mSearchButton.setVisibility(8); } /* JADX INFO: Access modifiers changed from: package-private */ @OnClick public void onProvinceClick() { d((String) null); } /* JADX INFO: Access modifiers changed from: package-private */ @OnClick public void onDistrictClick() { if (getString(R.string.province_place_holder).equals(this.mProvince.getText().toString()) || this.mProvince.getText().toString().isEmpty()) { e(getString(R.string.province_place_holder), EnumC8951daY.ERROR); } else { d(this.mProvince.getText() != null ? this.mProvince.getText().toString() : ""); } } /* JADX INFO: Access modifiers changed from: package-private */ @OnClick public void onSearchCloseClick() { if (SystemClock.elapsedRealtime() - this.n < 300) { return; } this.n = SystemClock.elapsedRealtime(); RelativeLayout relativeLayout = this.mSearchLayout; Animation loadAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.2130771999); loadAnimation.setDuration(300L); relativeLayout.startAnimation(loadAnimation); relativeLayout.setVisibility(8); this.mMyLocationButton.setVisibility(0); this.mSearchButton.setVisibility(0); } /* JADX INFO: Access modifiers changed from: package-private */ @OnClick public void onInfoCloseClick() { if (SystemClock.elapsedRealtime() - this.n < 300) { return; } this.n = SystemClock.elapsedRealtime(); RelativeLayout relativeLayout = this.mInfoLayout; Animation loadAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.2130771999); loadAnimation.setDuration(300L); relativeLayout.startAnimation(loadAnimation); relativeLayout.setVisibility(8); this.mMyLocationButton.setVisibility(0); this.mSearchButton.setVisibility(0); } /* JADX INFO: Access modifiers changed from: package-private */ @OnClick public void onSearchButtonClick() { if (this.f != -99.0d && this.g != -189.0d) { onSearchCloseClick(); this.p = 1; a(new LatLng(this.f, this.g)); return; } e(getString(R.string.invalid_lat_long), EnumC8951daY.ERROR); } /* JADX INFO: Access modifiers changed from: package-private */ /* JADX WARN: Multi-variable type inference failed */ @OnClick public void onCallButtonClicked() { String str; zEQ d; String obj = this.mMarkerPhone.getText().toString(); if (TextUtils.isEmpty(obj)) { str = ""; } else { if (obj.contains(",")) { YKU c = YKU.c(obj.split(",")); if (c.b.hasNext()) { d = zEQ.a(c.b.next()); } else { d = zEQ.d(); } if (d.d != 0) { T t = d.d; if (t != 0) { obj = (String) t; } else { throw new NoSuchElementException("No value present"); } } else { obj = ""; } } str = obj.replaceAll("\\D+", ""); if (str.length() > 9) { str = str.substring(0, 9); } } if (TextUtils.isEmpty(str)) { e(getString(R.string.marker_phone), EnumC8951daY.ERROR); return; } StringBuilder sb = new StringBuilder("tel:"); sb.append(str.trim().replace("-", "")); Intent intent = new Intent("android.intent.action.DIAL", Uri.parse(sb.toString())); intent.addFlags(268435456); startActivity(intent); } /* JADX INFO: Access modifiers changed from: package-private */ @OnClick public void onDirectionButtonClicked() { if (this.r != null) { StringBuilder sb = new StringBuilder("http://maps.google.com/maps?f=d&hl=en&saddr="); sb.append(this.r.getLatitude()); sb.append(","); sb.append(this.r.getLongitude()); sb.append("&daddr="); sb.append(this.v); sb.append(","); sb.append(this.y); startActivity(Intent.createChooser(new Intent(CommonConstant.ACTION.HWID_SCHEME_URL, Uri.parse(sb.toString())), "Select an application")); return; } e(getString(R.string.gps_initializing), EnumC8951daY.ERROR); } /* loaded from: classes5.dex */ class IeS extends XxC { private BaseMapTabFragment j; @Override // o.XxC public final /* synthetic */ void e(MP mp, MarkerOptions markerOptions) { MP mp2 = mp; if (this.j.d != null) { markerOptions.icon(this.j.d); super.e((IeS) mp2, markerOptions); } } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ IeS(BaseMapTabFragment baseMapTabFragment, Context context, GoogleMap googleMap, C8949daW c8949daW) { super(context, googleMap, c8949daW); this.j = baseMapTabFragment; } } private void e(String str, EnumC8951daY enumC8951daY) { FragmentActivity activity = getActivity(); if (activity == null || getActivity() == null) { return; } BaseActivity.a(new Object[]{(BaseActivity) getActivity(), activity, Integer.valueOf(R.id.find_us_container_view), str, enumC8951daY}, 855668825, -855668822, R.id.find_us_container_view); } public static /* synthetic */ void c(BaseMapTabFragment baseMapTabFragment) { boolean z = baseMapTabFragment.l; LocationManager locationManager = baseMapTabFragment.t; if (z == (locationManager != null && locationManager.isProviderEnabled("gps")) || !baseMapTabFragment.getUserVisibleHint()) { return; } guQ.b("gps status changed...", new Object[0]); LocationManager locationManager2 = baseMapTabFragment.t; baseMapTabFragment.l = locationManager2 != null && locationManager2.isProviderEnabled("gps"); if (!baseMapTabFragment.getUserVisibleHint() || baseMapTabFragment.mMapView == null) { return; } baseMapTabFragment.h = false; LocationManager locationManager3 = baseMapTabFragment.t; if (locationManager3 == null || !locationManager3.isProviderEnabled("gps")) { baseMapTabFragment.p = 1; } else { baseMapTabFragment.p = 0; } baseMapTabFragment.mMapView.getMapAsync(baseMapTabFragment); } public static /* synthetic */ void asW_(BaseMapTabFragment baseMapTabFragment, Intent intent) { if (intent != null) { baseMapTabFragment.mProvince.setText(intent.getStringExtra("PROVINCE_NAME")); baseMapTabFragment.mDistrict.setText(intent.getStringExtra("DISTRICT_NAME")); baseMapTabFragment.f = intent.getDoubleExtra("DISTRICT_LAT", -99.0d); baseMapTabFragment.g = intent.getDoubleExtra("DISTRICT_LON", -189.0d); } } @Override // o.InterfaceC6663cZf.HBt public final void d(C0693Mj c0693Mj) { e(c0693Mj.c, EnumC8951daY.ERROR); } }