package e.f.a.a.b.j; import android.animation.ArgbEvaluator; import android.animation.ValueAnimator; import android.content.Context; import android.content.res.Resources; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.animation.LinearInterpolator; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.huawei.hms.support.api.push.pushselfshow.prepare.NotificationIconUtil; import com.huawei.hms.support.feature.result.CommonConstant; import com.overlook.android.fing.R; import com.overlook.android.fing.engine.l.u; import com.overlook.android.fing.engine.l.z; import com.overlook.android.fing.ui.internet.IspDetailsActivity; import com.overlook.android.fing.ui.internet.g0; import com.overlook.android.fing.vl.components.ImageIndicator; import h.c0; import h.e0; import h.f; import h.g; import h.i0; import h.k0; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.json.JSONArray; import org.json.JSONObject; /* compiled from: PlacesHelper */ public class t { /* renamed from: a reason: collision with root package name */ private static final Handler f22754a = new Handler(Looper.getMainLooper()); /* access modifiers changed from: package-private */ /* compiled from: PlacesHelper */ public static class a implements g { /* renamed from: a reason: collision with root package name */ final /* synthetic */ b f22755a; a(b bVar) { this.f22755a = bVar; } /* JADX WARNING: Code restructure failed: missing block: B:33:0x0085, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:34:0x0086, code lost: if (r12 != null) goto L_0x0088; */ /* JADX WARNING: Code restructure failed: missing block: B:36:?, code lost: r12.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:37:0x008c, code lost: r12 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:38:0x008d, code lost: r11.addSuppressed(r12); */ /* JADX WARNING: Code restructure failed: missing block: B:39:0x0090, code lost: throw r0; */ @Override // h.g public void a(f fVar, i0 i0Var) { IspDetailsActivity ispDetailsActivity; com.overlook.android.fing.ui.internet.i0 i0Var2; ArrayList arrayList = new ArrayList(); try { if (i0Var.x()) { try { k0 b = i0Var.b(); if (b != null) { JSONArray jSONArray = new JSONArray(b.i()); for (int i2 = 0; i2 < jSONArray.length(); i2++) { JSONObject jSONObject = jSONArray.getJSONObject(i2); if (jSONObject.has(CommonConstant.KEY_COUNTRY_CODE)) { e eVar = new e(jSONObject.getString(CommonConstant.KEY_COUNTRY_CODE)); eVar.b = z.a(jSONObject.getString(CommonConstant.KEY_COUNTRY_CODE)) ? jSONObject.optString("kRegionName") : null; eVar.f22757c = jSONObject.optString("cityName"); if (jSONObject.has("imageReference")) { try { JSONObject jSONObject2 = jSONObject.getJSONObject("imageReference"); if (jSONObject2.has("imageUrl")) { eVar.f22758d = jSONObject2.getString("imageUrl"); } } catch (Exception unused) { } } arrayList.add(eVar); } } b.close(); g0 g0Var = (g0) this.f22755a; ispDetailsActivity = g0Var.f16768a; i0Var2 = new com.overlook.android.fing.ui.internet.i0(ispDetailsActivity, arrayList, g0Var.b); ispDetailsActivity.runOnUiThread(i0Var2); return; } throw new IOException("HTTP response body is empty!"); } catch (Exception e2) { Log.e("fing:places", "Failed to retrieve places JSON", e2); } } else { throw new IOException("HTTP response invalid (code=" + i0Var.i() + ",message=" + i0Var.y() + ")"); } } catch (Exception e3) { Log.e("fing:places", "Failed to retrieve places JSON", e3); g0 g0Var2 = (g0) this.f22755a; ispDetailsActivity = g0Var2.f16768a; i0Var2 = new com.overlook.android.fing.ui.internet.i0(ispDetailsActivity, arrayList, g0Var2.b); } catch (Throwable th) { g0 g0Var3 = (g0) this.f22755a; IspDetailsActivity ispDetailsActivity2 = g0Var3.f16768a; ispDetailsActivity2.runOnUiThread(new com.overlook.android.fing.ui.internet.i0(ispDetailsActivity2, arrayList, g0Var3.b)); throw th; } } @Override // h.g public void b(f fVar, IOException iOException) { Log.e("fing:places", "Failed to retrieve places JSON", iOException); ((g0) this.f22755a).a(Collections.emptyList()); } } /* compiled from: PlacesHelper */ public interface b { } /* compiled from: PlacesHelper */ public interface c { } /* compiled from: PlacesHelper */ public interface d { } public static void a(String str, String str2, b bVar) { StringBuilder H = e.a.a.a.a.H("https://app.fing.com", "/rest/place/cities/", str); if (!TextUtils.isEmpty(str2) && z.a(str)) { H.append(NotificationIconUtil.SPLIT_CHAR); H.append(str2); } H.append("?top="); H.append(12); try { c0 c0Var = new c0(com.overlook.android.fing.engine.j.h.b.b()); e0.a aVar = new e0.a(); aVar.h(H.toString()); ((okhttp3.internal.connection.e) c0Var.A(aVar.b())).g(new a(bVar)); } catch (Exception e2) { Log.e("fing:places", "Failed to retrieve places JSON", e2); ((g0) bVar).a(Collections.emptyList()); } } public static void c(Context context, String str, ImageView imageView) { ValueAnimator ofInt = ValueAnimator.ofInt(androidx.core.content.a.b(context, R.color.background100), androidx.core.content.a.b(context, R.color.grey80)); ofInt.setEvaluator(new ArgbEvaluator()); ofInt.setDuration(500L); ofInt.setInterpolator(new LinearInterpolator()); ofInt.setRepeatMode(2); ofInt.setRepeatCount(-1); ofInt.addUpdateListener(new h(imageView)); ofInt.start(); e.f.a.a.b.h.d u = e.f.a.a.b.h.d.u(context); u.r(str + "&w=128"); u.s(imageView); u.i(new d(ofInt, imageView, context)); u.a(); } public static void d(Context context, List<e> list, d dVar) { Resources resources = context.getResources(); int dimensionPixelSize = resources.getDimensionPixelSize(R.dimen.image_size_giant); int dimensionPixelSize2 = resources.getDimensionPixelSize(R.dimen.spacing_small); int dimensionPixelSize3 = resources.getDimensionPixelSize(R.dimen.spacing_mini); e.f.a.a.b.f.e0 e0Var = new e.f.a.a.b.f.e0(context); View inflate = LayoutInflater.from(context).inflate(R.layout.dialog_settings_location, (ViewGroup) null); ((TextView) inflate.findViewById(R.id.dialog_settings_header_title)).setText(context.getString(R.string.isp_select_place)); ((ImageView) inflate.findViewById(R.id.dialog_settings_back)).setVisibility(8); inflate.findViewById(R.id.dialog_settings_done).setOnClickListener(new g(e0Var)); LinearLayout linearLayout = (LinearLayout) inflate.findViewById(R.id.container); int i2 = 0; while (i2 < list.size()) { e eVar = list.get(i2); ImageIndicator imageIndicator = new ImageIndicator(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(dimensionPixelSize, -2); layoutParams.setMargins(i2 > 0 ? dimensionPixelSize3 : dimensionPixelSize2, dimensionPixelSize2, i2 < list.size() + -1 ? dimensionPixelSize3 : dimensionPixelSize2, dimensionPixelSize2); imageIndicator.setLayoutParams(layoutParams); imageIndicator.n().setScaleType(ImageView.ScaleType.CENTER_CROP); if (!TextUtils.isEmpty(eVar.f22757c)) { imageIndicator.o().setText(eVar.f22757c); } else if (TextUtils.isEmpty(eVar.b) || !z.a(eVar.f22756a)) { imageIndicator.o().setText(u.b(eVar.f22756a)); } else { imageIndicator.o().setText(eVar.b); } String str = eVar.f22758d; if (str != null) { c(context, str, imageIndicator.n()); } else { c cVar = new c(eVar, context, imageIndicator); StringBuilder G = e.a.a.a.a.G("https://app.fing.com", "/rest/place/image/"); G.append(eVar.f22756a); if (!TextUtils.isEmpty(eVar.b) && z.a(eVar.f22756a)) { G.append(NotificationIconUtil.SPLIT_CHAR); G.append(eVar.b); } if (!TextUtils.isEmpty(eVar.f22757c)) { G.append(NotificationIconUtil.SPLIT_CHAR); G.append(eVar.f22757c); } try { c0 c0Var = new c0(com.overlook.android.fing.engine.j.h.b.b()); e0.a aVar = new e0.a(); aVar.h(G.toString()); ((okhttp3.internal.connection.e) c0Var.A(aVar.b())).g(new u(cVar)); } catch (Exception e2) { Log.e("fing:places", "Failed to retrieve place image JSON", e2); cVar.a(null); } } imageIndicator.setOnClickListener(new f(e0Var, dVar, eVar)); linearLayout.addView(imageIndicator); i2++; } try { e0Var.setContentView(inflate); e0Var.show(); } catch (WindowManager.BadTokenException unused) { } } /* compiled from: PlacesHelper */ public static class e { /* renamed from: a reason: collision with root package name */ public String f22756a; public String b; /* renamed from: c reason: collision with root package name */ public String f22757c; /* renamed from: d reason: collision with root package name */ public String f22758d; public e(String str) { this.f22756a = str; } public e(String str, String str2) { this.f22756a = str; this.b = str2; } public e(String str, String str2, String str3) { this.f22756a = str; this.b = str2; this.f22757c = str3; } } }