360手机助手 v3.3.0版本的 MD5 值为:127c345ad16bbebee6e347381328afd0
以下内容为反编译后的 LbsActivity.java 源代码,内容仅作参考
package com.qihoo.appstore.personnalcenter.lbs;
import android.content.Intent;
import android.graphics.Bitmap;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewStub;
import android.webkit.WebBackForwardList;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.amap.api.location.AMapLocation;
import com.qihoo.appstore.activities.MainActivity;
import com.qihoo.appstore.activities.PopluarizeActivity;
import com.qihoo.appstore.activities.StatFragmentActivity;
import com.qihoo.appstore.personnalcenter.lbs.LbsLocationHelper;
import com.qihoo.appstore.utils.aw;
import com.qihoo.appstore.utils.bk;
import com.qihoo.appstore.utils.dc;
import com.qihoo.appstore.webview.MyWebView;
import com.qihoo.freewifi.push.R;
import com.qihoo.speedometer.Config;
import java.text.DecimalFormat;
import org.json.JSONObject;
public class LbsActivity extends StatFragmentActivity implements View.OnClickListener, i {
public static boolean f2983a = true;
private ViewStub f2984b;
private MyWebView c;
private View d;
private TextView e;
private View f;
private TextView g;
private TextView h;
private TextView i;
private View j;
private View k;
private View l;
private long m;
private Location n;
private boolean r;
private boolean s;
private boolean t;
private LbsLocationHelper x;
private FrameLayout y;
private long o = 0;
private boolean p = true;
private boolean q = false;
private boolean u = true;
private int v = 0;
private int w = 0;
private Handler z = new e(this);
public class FakeLocation extends Location {
private FakeLocation() {
super("lbs");
setLongitude(0.0d);
setLatitude(0.0d);
}
FakeLocation(LbsActivity lbsActivity, a aVar) {
this();
}
}
public static String b(String str) {
return aw.a("wer#$%321" + str);
}
public void b(int i) {
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "showErrorPanel, errorCode = " + i);
}
if (i == 2) {
this.e.setText(R.string.RetryMessge);
this.g.setVisibility(0);
this.g.setOnClickListener(this);
this.h.setVisibility(8);
this.h.setOnClickListener(null);
} else if (i == 1) {
this.e.setText(R.string.personnal_center_neary_location_retry_open_settings);
this.g.setVisibility(8);
this.g.setOnClickListener(null);
this.h.setVisibility(0);
this.h.setOnClickListener(this);
}
this.d.setVisibility(0);
this.f.setVisibility(0);
}
private void b(Location location) {
this.n = location;
this.k.setVisibility(0);
this.s = true;
g();
}
private String c(Location location) {
if (location instanceof FakeLocation) {
return "0_0";
}
try {
DecimalFormat decimalFormat = new DecimalFormat("###.###");
return decimalFormat.format(location.getLongitude()) + "_" + decimalFormat.format(location.getLatitude());
} catch (Exception e) {
return Config.INVALID_IP;
}
}
private void c() {
this.j = findViewById(R.id.root);
this.i = (TextView) findViewById(R.id.title);
this.f2984b = (ViewStub) findViewById(R.id.confirm_view);
boolean c = com.qihoo.appstore.utils.f.c("LBS_CONFIRMED", false);
this.f2984b.setVisibility(!c ? 0 : 8);
if (!c) {
findViewById(R.id.confirm_btn).setOnClickListener(!c ? this : null);
}
this.i.setText(c ? R.string.personnal_center_neary_title : R.string.personnal_center_neary_title_1);
findViewById(R.id.title_left_root).setOnClickListener(this);
this.y = (FrameLayout) findViewById(R.id.webview_container);
this.c = new f(this);
this.c.a(findViewById(R.id.loading), (View) null, (View) null);
this.c.setCacheMode(2);
this.c.g.setActivity(this);
this.c.setActivity(this);
this.c.clearHistory();
this.c.setNeedCookie(false);
this.y.addView(this.c, 0);
this.d = findViewById(R.id.error_panel);
this.e = (TextView) findViewById(R.id.error_msg_to_retry);
this.f = findViewById(R.id.retry);
this.g = (TextView) findViewById(R.id.retry_btn_main);
this.h = (TextView) findViewById(R.id.retry_btn_sub);
this.k = findViewById(R.id.list);
this.l = findViewById(R.id.share);
this.k.setOnClickListener(this);
this.l.setOnClickListener(this);
}
private void c(int i) {
new Thread(new d(this, i)).start();
}
private String d(Location location) {
Bundle extras;
return ((location instanceof FakeLocation) || Math.abs(location.getTime() - System.currentTimeMillis()) > 3600000 || (extras = location.getExtras()) == null) ? Config.INVALID_IP : extras.getString("desc");
}
private void d() {
if (com.qihoo.appstore.utils.f.c("LBS_CONFIRMED", false)) {
if (!com.qihoo.express.mini.c.i.b()) {
b(2);
return;
}
try {
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "startGetLocation");
}
f();
this.m = System.currentTimeMillis();
if (this.x == null) {
this.x = new LbsLocationHelper(this, this);
}
this.x.a();
this.w++;
} catch (Exception e) {
e();
}
}
}
private void e() {
this.z.sendEmptyMessage(0);
}
private void f() {
StringBuilder sb = new StringBuilder();
sb.append(dc.ax()).append("html/lbs/beacon.html?page_ver=").append(com.qihoo.appstore.utils.f.b("RPEF_KEY_LBS_PAGE_VERSION", 1));
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.c("LbsActivity", "gotoResultPage url=" + sb.toString());
}
this.c.clearHistory();
this.c.loadUrl(sb.toString());
}
public void g() {
if (this.r && this.s) {
try {
i();
StringBuilder sb = new StringBuilder();
sb.append("?m2=").append(com.qihoo.appstore.r.g.f).append("&sign=").append(b(com.qihoo.appstore.r.g.f)).append("&").append(j());
String a2 = com.qihoo.appstore.r.g.a(sb.toString(), MainActivity.g());
JSONObject jSONObject = new JSONObject();
jSONObject.put("params", a2);
String str = "onLocationChanged(" + jSONObject.toString() + ")";
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.c("LbsActivity", "notifyPosition : " + str);
}
this.c.d(str);
} catch (Exception e) {
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.d("LbsActivity", "notifyPosition failed.", e);
}
}
}
}
public void h() {
if (this.n == null || (this.n instanceof FakeLocation)) {
return;
}
new Thread(new b(this)).start();
}
private void i() {
if (this.n == null) {
return;
}
String c = c(this.n);
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.c("LbsActivity", "saveLastLocation, locationText = " + c);
}
if (TextUtils.isEmpty(c)) {
return;
}
String b2 = aw.b(c);
String d = com.qihoo.appstore.utils.f.d("LAST_PAGE_LBS_LOCATION", Config.INVALID_IP);
com.qihoo.appstore.utils.f.b("LAST_PAGE_LBS_LOCATION", b2);
com.qihoo.appstore.utils.f.b("IS_PAGE_LBS_LOCATION_CHANGED", d.equals(b2) ? "0" : "1");
}
public String j() {
if (this.n == null) {
return Config.INVALID_IP;
}
String c = c(this.n);
if (TextUtils.isEmpty(c)) {
return Config.INVALID_IP;
}
com.qihoo.appstore.personnalcenter.friends.a aVar = new com.qihoo.appstore.personnalcenter.friends.a(c, d(this.n));
aVar.a();
StringBuilder sb = new StringBuilder();
sb.append("pos=").append(aVar.c()[0]);
sb.append("&desc=").append(aVar.c()[1]);
sb.append("&dkey=").append(aVar.b());
return sb.toString();
}
private void k() {
if (this.t) {
return;
}
this.t = true;
Bitmap a2 = com.qihoo.express.mini.c.b.a(this.j);
if (a2 != null) {
new Thread(new c(this, a2)).start();
return;
}
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "BitmapUtil.getBitmapFromView failed");
}
this.z.sendEmptyMessage(4);
}
public void a(int i) {
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "onLbsPageVersionChanged " + i);
}
com.qihoo.appstore.utils.f.a("RPEF_KEY_LBS_PAGE_VERSION", i);
this.v++;
if (this.v > 2) {
return;
}
this.c.clearHistory();
this.c.loadUrl("javascript:document.body.innerHTML = '';");
this.c.setCacheMode(1);
f();
}
@Override
public void a(Location location) {
int a2;
a aVar = null;
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "onLocationChanged location = " + location + " , cost " + (System.currentTimeMillis() - this.m) + " ms.");
}
if (this.u) {
if (location instanceof LbsLocationHelper.FailedLocation) {
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "onLocationChanged , location instanceof FailedLocation");
}
c(((LbsLocationHelper.FailedLocation) location).a());
b(new FakeLocation(this, aVar));
return;
}
if (!(location instanceof AMapLocation)) {
if (location == null) {
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "onLocationChanged , location == null");
}
c(-2);
b(new FakeLocation(this, aVar));
return;
}
if (LbsLocationHelper.a(location)) {
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "onLocationChanged , LbsLocationHelper.isValidLocation(location)");
}
b(location);
return;
} else {
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "onLocationChanged , else");
}
b(new FakeLocation(this, aVar));
return;
}
}
com.amap.api.location.core.a a3 = ((AMapLocation) location).a();
if (a3 != null && (a2 = a3.a()) != 0) {
c(a2);
if (a2 == 31 && !LbsLocationHelper.a(this)) {
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "onLocationChanged , location instanceof AMapLocation, !LbsLocationHelper.hasEnabledProvider");
}
Toast.makeText(this, getString(R.string.personnal_center_neary_location_fail_toast_fail, new Object[]{Integer.valueOf(a3.a())}), 0).show();
e();
return;
}
}
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.b("LbsActivity", "onLocationChanged , location instanceof AMapLocation, otherwise ");
}
if (LbsLocationHelper.a(location)) {
b(location);
} else {
b(new FakeLocation(this, aVar));
}
}
}
protected boolean a() {
if (!this.c.i()) {
try {
WebBackForwardList copyBackForwardList = this.c.copyBackForwardList();
if (copyBackForwardList != null) {
String url = copyBackForwardList.getCurrentItem().getUrl();
String url2 = copyBackForwardList.getItemAtIndex(0).getUrl();
if (url != null && url.equals(url2)) {
this.c.clearHistory();
}
}
} catch (Exception e) {
}
if (!this.c.canGoBack() || System.currentTimeMillis() - this.o <= 500) {
if (this.c != null) {
this.c.clearHistory();
this.c.goBack();
this.c.loadUrl("javascript:void document.body.innerHTML = '';");
}
new Handler().postDelayed(new a(this), 500L);
} else {
this.o = System.currentTimeMillis();
this.c.goBack();
}
}
return true;
}
public void b() {
this.l.setVisibility(0);
}
@Override
public String getStatTag() {
return "fujin";
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.list:
StringBuilder sb = new StringBuilder();
sb.append(dc.ax()).append("html/lbs/beacon_list.html?").append("m2=").append(com.qihoo.appstore.r.g.f).append("&sign=").append(b(com.qihoo.appstore.r.g.f)).append("&").append(j()).append("&titlebar_space=1");
if (com.qihoo360.mobilesafe.a.a.f5313a) {
bk.c("LbsActivity", "gotoListPage url=" + sb.toString());
}
MainActivity e = MainActivity.e();
Intent intent = new Intent(e, (Class<?>) PopluarizeActivity.class);
intent.putExtra("needCookie", true);
intent.putExtra("forceNoCache", true);
intent.putExtra("detail_url", sb.toString());
intent.putExtra("statTag", "fujinall");
intent.putExtra("showScan", false);
e.b(intent);
return;
case R.id.title_left_root:
onkeyBack();
return;
case R.id.confirm_btn:
com.qihoo.appstore.utils.f.b("LBS_CONFIRMED", true);
this.f2984b.setVisibility(8);
this.i.setText(R.string.personnal_center_neary_title);
d();
return;
case R.id.share:
k();
return;
case R.id.retry_btn_main:
this.d.setVisibility(8);
d();
return;
case R.id.retry_btn_sub:
try {
Intent intent2 = new Intent("android.settings.LOCATION_SOURCE_SETTINGS");
intent2.setFlags(268435456);
startActivity(intent2);
this.q = true;
return;
} catch (Exception e2) {
this.d.setVisibility(8);
d();
return;
}
default:
return;
}
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.personnal_center_lbs_page);
this.p = true;
this.mStatTag = getStatTag();
if (getIntent() != null) {
f2983a = getIntent().getBooleanExtra("EXTRA_BACK_TO_USER_CENTER", true);
}
c();
}
@Override
public void onDestroy() {
if (this.c != null) {
this.c.b();
this.c.loadUrl("javascript:document.body.innerHTML = '';");
this.c.destroy();
}
if (this.x != null) {
this.x.b();
this.x = null;
}
if (this.y != null) {
this.y.removeAllViews();
}
super.onDestroy();
}
@Override
public boolean onKeyDown(int i, KeyEvent keyEvent) {
return i == 4 ? a() : super.onKeyDown(i, keyEvent);
}
@Override
public void onPause() {
super.onPause();
if (this.c != null) {
this.c.clearFocus();
this.c.g();
}
}
@Override
public void onResume() {
super.onResume();
if (this.p) {
d();
this.p = false;
} else if (this.q) {
this.d.setVisibility(8);
d();
this.q = false;
}
if (this.c != null) {
this.c.requestFocus();
}
this.c.f();
}
@Override
public void onStart() {
this.u = true;
super.onStart();
}
@Override
public void onStop() {
this.u = false;
super.onStop();
}
}