package com.uzmap.pkg.openapi; import android.app.Activity; import android.content.Context; import android.text.TextUtils; import android.webkit.ValueCallback; import android.widget.FrameLayout; import com.deepe.b.b.c; import com.deepe.b.d; import com.uzmap.pkg.uzcore.b.d; import com.uzmap.pkg.uzcore.e; import com.uzmap.pkg.uzcore.e.b; import com.uzmap.pkg.uzcore.f; import com.uzmap.pkg.uzcore.h; import com.uzmap.pkg.uzcore.uzmodule.b.p; import org.json.JSONObject; public final class SuperWebview extends FrameLayout { protected static boolean a = false; private Activity b; private h c; private f d; private ViewClient e = new ViewClient(this); private Object f; public SuperWebview(Context context, Object obj) { super(context); this.f = obj; this.b = (Activity) context; f b2 = f.b(this.b); this.d = b2; Object obj2 = this.f; b2.c(obj2 != null ? obj2.toString() : null); } private String ifNeededTransUrl(String str) { d k; int indexOf; if (str == null || FileSystem.isLocked() || (k = e.a().k()) == null || !k.k || (indexOf = str.indexOf("widget/")) <= 0) { return str; } String substring = str.substring(indexOf); String b2 = k.b(); int indexOf2 = b2.indexOf("widget/"); if (indexOf2 <= 0) { return str; } return String.valueOf(b2.substring(0, indexOf2)) + substring; } private void initialize(d dVar) { b.a(dVar); this.d.a((f.a) this.e); h hVar = new h(getContext(), dVar); this.c = hVar; hVar.a(); this.c.setLayoutParams(com.uzmap.pkg.b.d.b.b()); this.c.a(true); this.c.b(1); addView(this.c); this.c.d(); startupProcess(); } private boolean shouldOverrideKeyPress(int i) { h hVar = this.c; return hVar != null && hVar.c(i); } private final void startupProcess() { a = true; e.a().a((com.deepe.b.c.d) new com.deepe.b.d(new d.a() { /* class com.uzmap.pkg.openapi.SuperWebview.AnonymousClass1 */ @Override // com.deepe.b.d.a public Activity getActivity() { return SuperWebview.this.b; } @Override // com.deepe.b.d.a public boolean isFromNativeSDK() { return true; } @Override // com.deepe.b.d.a public void onSmartUpdateFinish(boolean z, c cVar) { if (SuperWebview.this.c != null) { SuperWebview.this.c.a(z, cVar); } } @Override // com.deepe.b.d.a public boolean requestFinishApp(boolean z) { return false; } @Override // com.deepe.b.d.a public boolean requestRebootApp() { return false; } })); e.a().d(); } public final void addHtml5EventListener(Html5EventListener html5EventListener) { APIEventCenter.get().addHtml5EventListener(this.b, html5EventListener); } public final void destroy() { h hVar = this.c; if (hVar != null) { removeView(hVar); this.c.r(); this.c = null; } } public final void evaluateJavascript(String str) { evaluateJavascript((String) null, str); } public final void evaluateJavascript(String str, ValueCallback valueCallback) { evaluateJavascript(null, null, str, valueCallback); } public final void evaluateJavascript(String str, String str2) { evaluateJavascript(str, null, str2); } public final void evaluateJavascript(String str, String str2, String str3) { evaluateJavascript(str, str2, str3, null); } public final void evaluateJavascript(String str, String str2, String str3, ValueCallback valueCallback) { if (this.c != null) { p pVar = new p(); pVar.a = str; pVar.b = str2; pVar.c = str3; pVar.d = valueCallback; this.c.b(pVar); } } public String getDefaultStartUrl() { com.uzmap.pkg.uzcore.b.d k = e.a().k(); return k != null ? k.b() : "file:///android_asset/widget/index.html"; } public final void loadUrl(String str) { h hVar = this.c; } public final void onPause() { h hVar = this.c; if (hVar != null) { hVar.j(); } } public final void onResume() { h hVar = this.c; if (hVar != null) { hVar.k(); } } public final void removeAllHtml5EventListener() { APIEventCenter.get().removeAllHtml5EventListener(this.b); } public final void removeHtml5EventListener(Html5EventListener html5EventListener) { if (html5EventListener != null) { APIEventCenter.get().removeHtml5EventListener(this.b, html5EventListener); } } public final void sendEvent(EventEntity eventEntity) { if (this.c != null) { com.uzmap.pkg.uzcore.uzmodule.b.e eVar = new com.uzmap.pkg.uzcore.uzmodule.b.e(null, null); eVar.c = eventEntity.name; eVar.b = eventEntity.extra; this.c.a(eVar); } } public final void sendEventToHtml5(String str, JSONObject jSONObject) { sendEvent(new EventEntity(str, jSONObject)); } public void setApiListener(APIListener aPIListener) { this.e.setApiClient(aPIListener); } public void setImmerseState(boolean z) { this.e.setImmerseState(Boolean.valueOf(z)); } public void start() { start(null); } public void start(String str) { com.uzmap.pkg.uzcore.b.d dVar; com.uzmap.pkg.uzcore.uzmodule.e eVar; String defaultStartUrl = getDefaultStartUrl(); if (TextUtils.isEmpty(str)) { dVar = com.uzmap.pkg.uzcore.b.d.c(defaultStartUrl, null); } else { int indexOf = str.indexOf("?"); if (indexOf >= 0) { eVar = com.uzmap.pkg.uzcore.uzmodule.e.a(str.substring(indexOf + 1)); str = str.substring(0, indexOf); } else { eVar = null; } if (str.endsWith("config.xml")) { com.uzmap.pkg.uzcore.b.d j = com.uzmap.pkg.uzcore.b.d.j(str); if (!(j == null || eVar == null || j.w != null)) { j.w = eVar; } defaultStartUrl = str; dVar = j; } else { defaultStartUrl = str; dVar = null; } } if (dVar == null) { dVar = com.uzmap.pkg.uzcore.b.d.c(ifNeededTransUrl(defaultStartUrl), null); } initialize(dVar); } public boolean windowBack() { if (this.c == null) { return false; } if (!shouldOverrideKeyPress(4)) { return this.c.g(); } this.c.a(4, false); return true; } public boolean windowCanBack() { h hVar = this.c; if (hVar != null) { return hVar.i(); } return false; } }