酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319
以下内容为反编译后的 AbstractMarketActivity.java 源代码,内容仅作参考
package com.kugou.android.apprecommand;
import android.annotation.TargetApi;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.JsResult;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.LinearLayout;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.kugou.android.app.KGApplication;
import com.kugou.android.app.MarketFragment;
import com.kugou.android.app.process.EnvManager;
import com.kugou.android.common.delegate.DelegateActivity;
import com.kugou.android.common.dialog.a;
import com.kugou.android.lite.R;
import com.kugou.common.apm.ApmDataEnum;
import com.kugou.common.app.KGCommonApplication;
import com.kugou.common.datacollect.view.web.c;
import com.kugou.common.filemanager.entity.FileHolder;
import com.kugou.common.filemanager.entity.KGDownloadingInfo;
import com.kugou.common.filemanager.entity.KGFile;
import com.kugou.common.filemanager.entity.KGFileDownloadInfo;
import com.kugou.common.skin.d;
import com.kugou.common.utils.as;
import com.kugou.common.utils.br;
import com.kugou.common.utils.g;
import com.kugou.common.utils.s;
import com.kugou.framework.common.utils.stacktrace.e;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public abstract class AbstractMarketActivity extends DelegateActivity {
protected static WebView f21187a;
protected static HashMap<String, Integer> n = new HashMap<>();
protected LinearLayout f21188b;
protected LinearLayout f21189c;
protected String f21190d;
protected String f21191e;
protected String f;
protected String g;
protected String h;
protected String i;
protected String j;
private View u;
protected final int k = 1;
protected final int l = 2;
protected final int m = 3;
private final int t = 10001;
protected Handler o = new e() {
@Override
@TargetApi(11)
public void handleMessage(Message message) {
int i = message.what;
if (i == 1) {
AbstractMarketActivity.this.s();
return;
}
if (i == 2) {
AbstractMarketActivity.this.showToast(KGApplication.getContext().getString(R.string.n0, (String) message.obj));
return;
}
if (i == 3) {
AbstractMarketActivity.this.showToast(message.arg1);
return;
}
if (i != 10001) {
return;
}
String str = (String) message.obj;
synchronized (AbstractMarketActivity.this.s) {
if (AbstractMarketActivity.f21187a != null && str != null && !AbstractMarketActivity.this.r) {
if (as.f54365e) {
as.b("BLUE", "load url " + str);
}
com.kugou.common.web.a.a.removeJavascriptInterface(AbstractMarketActivity.f21187a);
AbstractMarketActivity.f21187a.loadUrl(str);
}
}
}
};
protected String p = "BLUE-store-download";
protected g.a q = new g.a() {
private Map<String, Long> f21194b = new HashMap();
@Override
public void onStop(String str) {
}
@Override
public void onStart(String str) {
if (as.f54365e) {
as.b(AbstractMarketActivity.this.p, "onStart " + str);
}
this.f21194b.put(str, Long.valueOf(System.currentTimeMillis()));
}
@Override
public void onProgress(String str, int i) {
if (as.f54365e) {
as.b(AbstractMarketActivity.this.p, "onProgress " + str + " " + i);
}
AbstractMarketActivity.n.put(AbstractMarketActivity.this.f(str), Integer.valueOf(i));
}
@Override
public void onError(String str, int i) {
if (as.f54365e) {
as.b(AbstractMarketActivity.this.p, "onError " + str + " " + i);
}
String f = AbstractMarketActivity.this.f(str);
Integer num = AbstractMarketActivity.n.get(f);
int intValue = num != null ? num.intValue() : 0;
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("url", f);
jSONObject.put("status", 0);
jSONObject.put(NotificationCompat.CATEGORY_PROGRESS, intValue);
String replace = jSONObject.toString().replace("\\", "");
AbstractMarketActivity.this.o.obtainMessage(10001, "javascript:notifyError('" + replace + "')").sendToTarget();
KGFile c2 = com.kugou.common.filemanager.service.a.b.c(str);
String q = c2 != null ? c2.q() : "";
if (!TextUtils.isEmpty(q) && q.lastIndexOf(".") != -1) {
q = q.substring(0, q.lastIndexOf("."));
}
AbstractMarketActivity.this.o.obtainMessage(2, q).sendToTarget();
} catch (Exception unused) {
}
AbstractMarketActivity.n.remove(f);
Long l = this.f21194b.get(str);
if (l != null) {
System.currentTimeMillis();
l.longValue();
}
this.f21194b.remove(str);
}
@Override
public void onComplete(String str, String str2) {
if (as.f54365e) {
as.b(AbstractMarketActivity.this.p, "onComplete " + str + " " + str2);
}
AbstractMarketActivity.n.put(AbstractMarketActivity.this.f(str), 100);
br.d(KGCommonApplication.getContext(), str2);
this.f21194b.remove(str);
}
};
protected boolean r = false;
protected Object s = new Object();
private boolean v = false;
private final int w = 1;
private final int x = 2;
private final int y = 3;
private final int z = 4;
private final int A = 5;
private final int B = 6;
protected abstract Object a();
public abstract String b();
public String f(String str) {
return !TextUtils.isEmpty(str) ? str.replaceAll(g.b(1010, ""), "") : "";
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
}
@Override
public void onContentChanged() {
super.onContentChanged();
enableTitleDelegate(null);
initDelegates();
f21187a = (WebView) findViewById(R.id.bx);
if (f21187a == null) {
throw new RuntimeException("Your content must have a TextView whose id attribute is 'R.id.app_wv'");
}
this.f21188b = (LinearLayout) findViewById(R.id.b35);
if (this.f21188b == null) {
throw new RuntimeException("Your content must have a TextView whose id attribute is 'R.id.loading_bar'");
}
this.f21189c = (LinearLayout) findViewById(R.id.bpt);
if (this.f21189c == null) {
throw new RuntimeException("Your content must have a TextView whose id attribute is 'R.id.refresh_bar'");
}
this.u = findViewById(R.id.t5);
if (this.f21189c == null) {
throw new RuntimeException("Your content must have a TextView whose id attribute is 'R.id.common_title_colse_button'");
}
f21187a.setVerticalScrollBarEnabled(false);
WebSettings settings = f21187a.getSettings();
settings.setJavaScriptEnabled(true);
settings.setSavePassword(false);
settings.setDefaultTextEncodingName("utf-8");
settings.setCacheMode(2);
f21187a.setWebViewClient(new b());
f21187a.setWebChromeClient(new a(b(), c()));
if (!com.kugou.common.web.a.a.Is_Injected_Open) {
f21187a.addJavascriptInterface(a(), b());
}
this.f21189c.findViewById(R.id.it).setOnClickListener(new View.OnClickListener() {
@Override
@TargetApi(11)
public void onClick(View view) {
if (br.Q(KGCommonApplication.getContext())) {
AbstractMarketActivity.this.v = false;
AbstractMarketActivity.this.t();
com.kugou.common.web.a.a.removeJavascriptInterface(AbstractMarketActivity.f21187a);
AbstractMarketActivity.f21187a.loadUrl(AbstractMarketActivity.this.j);
return;
}
AbstractMarketActivity.this.a(R.string.av3);
}
});
d();
}
private Class c() {
return MarketFragment.AndroidMethodProvider.class;
}
@Override
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (i == 4 && f21187a.canGoBack()) {
try {
f21187a.goBack();
return true;
} catch (NullPointerException e2) {
as.e(e2);
return true;
}
}
return super.onKeyDown(i, keyEvent);
}
@Override
public void onDestroy() {
this.r = true;
Handler handler = this.o;
if (handler != null) {
handler.removeMessages(1);
}
Object obj = this.s;
if (obj != null) {
synchronized (obj) {
try {
f21187a.removeAllViews();
f21187a.clearCache(true);
f21187a.destroy();
} catch (Exception e2) {
as.e(e2);
}
}
}
super.onDestroy();
}
protected synchronized void s() {
if (as.f54365e) {
as.d("InjectedChromeClient", "refreshProgress()");
}
if (!n.isEmpty()) {
JSONArray jSONArray = new JSONArray();
Iterator<String> it = n.keySet().iterator();
while (it.hasNext()) {
try {
JSONObject jSONObject = new JSONObject();
String next = it.next();
int intValue = n.get(next).intValue();
if (as.f54365e) {
as.d("InjectedChromeClient", "progress is " + intValue);
}
if (intValue == 100) {
it.remove();
jSONObject.put("status", 2);
} else {
jSONObject.put("status", 1);
}
jSONObject.put("url", next);
jSONObject.put(NotificationCompat.CATEGORY_PROGRESS, intValue);
jSONArray.put(jSONObject);
} catch (Exception unused) {
}
}
try {
a(jSONArray.toString().replace("\\", ""));
} catch (Exception unused2) {
}
this.o.sendEmptyMessageDelayed(1, 200L);
}
}
@TargetApi(11)
protected void a(String str) {
if (as.f54365e) {
as.d("InjectedChromeClient", "notifyProgress " + str);
}
com.kugou.common.web.a.a.removeJavascriptInterface(f21187a);
f21187a.loadUrl("javascript:notifyProgress('" + str + "')");
}
public synchronized void a(String str, int i) {
if (!n.containsKey(str)) {
n.put(str, Integer.valueOf(i));
}
}
public synchronized void b(String str) {
n.remove(str);
}
public void a(int i) {
this.o.obtainMessage(3, i, 0).sendToTarget();
}
public void t() {
this.f21188b.setVisibility(0);
this.f21189c.setVisibility(4);
f21187a.setVisibility(4);
}
public void u() {
this.f21189c.setVisibility(0);
this.f21188b.setVisibility(4);
f21187a.setVisibility(4);
}
protected void v() {
f21187a.setVisibility(0);
this.f21189c.setVisibility(4);
this.f21188b.setVisibility(4);
}
public boolean c(String str) {
KGFileDownloadInfo b2 = com.kugou.common.filemanager.service.a.b.b(g.b(1010, str));
return (b2 == null || b2.o() == 0 || !new s(b2.h()).exists() || b2.k() == 0 || b2.n() != b2.k()) ? false : true;
}
public boolean d(String str) {
String b2 = g.b(1010, str);
List<KGDownloadingInfo> b3 = com.kugou.common.filemanager.service.a.b.b(new FileHolder(com.kugou.common.filemanager.entity.b.FILE_HOLDER_TYPE_APPPACKAGE.a(), com.kugou.common.filemanager.entity.b.FILE_HOLDER_TYPE_APPPACKAGE.b() + "_" + b2));
boolean z = false;
if (b3 != null) {
for (KGDownloadingInfo kGDownloadingInfo : b3) {
if (kGDownloadingInfo.m() == b2 && kGDownloadingInfo.a() == com.kugou.common.filemanager.downloadengine.entity.b.FILE_DOWNLOAD_STATE_DOWNLOADING) {
z = true;
}
}
}
return z;
}
public int e(String str) {
String b2 = g.b(1010, str);
KGFileDownloadInfo b3 = com.kugou.common.filemanager.service.a.b.b(b2);
int i = 0;
if (b3 != null && b3.o() == 1) {
return 100;
}
if (b3 != null && b3.o() == 0) {
if (b3.k() == 0) {
return 0;
}
return (int) ((((float) b3.n()) / ((float) b3.k())) * 100.0f);
}
List<KGDownloadingInfo> b4 = com.kugou.common.filemanager.service.a.b.b(new FileHolder(com.kugou.common.filemanager.entity.b.FILE_HOLDER_TYPE_APPPACKAGE.a(), com.kugou.common.filemanager.entity.b.FILE_HOLDER_TYPE_APPPACKAGE.b() + "_" + b2));
if (b4 == null) {
return 0;
}
for (KGDownloadingInfo kGDownloadingInfo : b4) {
if (kGDownloadingInfo.m() == b2 && kGDownloadingInfo.a() == com.kugou.common.filemanager.downloadengine.entity.b.FILE_DOWNLOAD_STATE_DOWNLOADING) {
i = (int) ((((float) kGDownloadingInfo.n()) / ((float) kGDownloadingInfo.k())) * 100.0f);
}
}
return i;
}
protected class b extends c {
protected b() {
}
@Override
@TargetApi(11)
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
com.kugou.common.web.a.a.removeJavascriptInterface(AbstractMarketActivity.f21187a);
webView.loadUrl(str);
return true;
}
@Override
public void onReceivedError(WebView webView, int i, String str, String str2) {
super.onReceivedError(webView, i, str, str2);
webView.loadData("<html><p></p></html>", "text/html", "utf-8");
AbstractMarketActivity.this.u();
AbstractMarketActivity.this.v = true;
com.kugou.common.apm.c.a().a(ApmDataEnum.APM_ENTER_MARKET, false);
com.kugou.common.apm.c.a().a(ApmDataEnum.APM_ENTER_MARKET, "fs", String.valueOf(i) + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + str);
com.kugou.common.apm.c.a().f(ApmDataEnum.APM_ENTER_MARKET, -2L);
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
com.kugou.common.apm.c.a().a(ApmDataEnum.APM_ENTER_MARKET, true);
com.kugou.common.apm.c.a().f(ApmDataEnum.APM_ENTER_MARKET, -2L);
if (AbstractMarketActivity.this.v) {
return;
}
AbstractMarketActivity.this.v();
}
}
class a extends com.kugou.common.web.a.a {
public a(String str, Class cls) {
super(str, cls);
}
@Override
public boolean onJsAlert(WebView webView, String str, String str2, final JsResult jsResult) {
a.C0394a c0394a = new a.C0394a(AbstractMarketActivity.this.getParent() == null ? AbstractMarketActivity.this : AbstractMarketActivity.this.getParent());
c0394a.a("提示");
c0394a.b(str2);
c0394a.a(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
jsResult.cancel();
}
});
c0394a.b();
return super.onJsAlert(webView, str, str2, jsResult);
}
@Override
public void onProgressChanged(WebView webView, int i) {
super.onProgressChanged(webView, i);
}
@Override
public void onReceivedTitle(WebView webView, String str) {
super.onReceivedTitle(webView, str);
}
}
private void d() {
this.f21190d = "#ffffff";
this.f21191e = "#000000";
this.f = "#666666";
this.g = "#666666";
this.h = "#ffffff";
if (d.o(this)) {
this.i = b(5);
this.f21190d = b(6);
return;
}
int e2 = d.e();
if (e2 == 0) {
this.i = "#72AAD6";
} else if (e2 == 1) {
this.i = "#DB778F";
} else {
this.i = "#2A2A2A";
}
}
private String b(int i) {
int a2;
com.kugou.common.skin.b g = com.kugou.common.skin.c.g();
switch (i) {
case 1:
a2 = g.a();
break;
case 2:
a2 = g.b();
break;
case 3:
a2 = g.c();
break;
case 4:
a2 = g.d();
break;
case 5:
case 6:
return g(d.i(this));
default:
a2 = g.b();
break;
}
return g(getString(a2));
}
private String g(String str) {
if (TextUtils.isEmpty(str)) {
return "";
}
if (!str.startsWith("#")) {
return str;
}
if (str.length() < 9) {
return "";
}
return "#" + str.substring(3, 9);
}
@Override
@TargetApi(11)
public void onSkinColorChanged() {
super.onSkinColorChanged();
d();
com.kugou.common.web.a.a.removeJavascriptInterface(f21187a);
f21187a.loadUrl("javascript:notifySkinChanged()");
}
public boolean w() {
if (!EnvManager.isOnline()) {
br.T(getActivity());
return false;
}
if (!br.A()) {
a(R.string.av6);
return false;
}
if (br.Q(KGCommonApplication.getContext())) {
return true;
}
a(R.string.av3);
return false;
}
}