moved some listeners from field attribute to class
This commit is contained in:
parent
eeb24315fb
commit
26754ac8c0
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cradle.iitc_mobile"
|
||||
android:versionCode="51"
|
||||
android:versionName="0.7.1">
|
||||
android:versionCode="52"
|
||||
android:versionName="0.7.2">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
|
@ -24,7 +24,6 @@ import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.Toast;
|
||||
@ -36,17 +35,15 @@ import java.net.URISyntaxException;
|
||||
import java.util.Locale;
|
||||
import java.util.Stack;
|
||||
|
||||
public class IITC_Mobile extends Activity {
|
||||
public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeListener, LocationListener {
|
||||
|
||||
private static final int REQUEST_LOGIN = 1;
|
||||
|
||||
private IITC_WebView mIitcWebView;
|
||||
private OnSharedPreferenceChangeListener mSharedPrefChangeListener;
|
||||
private final String mIntelUrl = "https://www.ingress.com/intel";
|
||||
private boolean mIsLocEnabled = false;
|
||||
private Location mLastLocation = null;
|
||||
private LocationManager mLocMngr = null;
|
||||
private LocationListener mLocListener = null;
|
||||
private boolean mFullscreenMode = false;
|
||||
private IITC_DeviceAccountLogin mLogin;
|
||||
private MenuItem mSearchMenuItem;
|
||||
@ -81,10 +78,37 @@ public class IITC_Mobile extends Activity {
|
||||
|
||||
// do something if user changed something in the settings
|
||||
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
mSharedPrefChangeListener = new OnSharedPreferenceChangeListener() {
|
||||
mSharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
// enable/disable mDesktopMode mode on menu create and url load
|
||||
mDesktopMode = mSharedPrefs.getBoolean("pref_force_desktop", false);
|
||||
|
||||
// enable/disable advance menu
|
||||
mAdvancedMenu = mSharedPrefs.getBoolean("pref_advanced_menu", false);
|
||||
|
||||
// Acquire a reference to the system Location Manager
|
||||
mLocMngr = (LocationManager) this
|
||||
.getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
mIsLocEnabled = mSharedPrefs.getBoolean("pref_user_loc", false);
|
||||
if (mIsLocEnabled) {
|
||||
// Register the mSharedPrefChangeListener with the Location Manager to receive
|
||||
// location updates
|
||||
mLocMngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
||||
0, 0, this);
|
||||
mLocMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
|
||||
this);
|
||||
}
|
||||
|
||||
// Clear the back stack
|
||||
mBackStack.clear();
|
||||
|
||||
handleIntent(getIntent(), true);
|
||||
}
|
||||
|
||||
// --------------------- onSharedPreferenceListener -----------------------
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(
|
||||
SharedPreferences sharedPreferences, String key) {
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals("pref_force_desktop")) {
|
||||
mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
|
||||
mNavigationHelper.onPrefChanged();
|
||||
@ -112,21 +136,10 @@ public class IITC_Mobile extends Activity {
|
||||
|
||||
mReloadNeeded = true;
|
||||
}
|
||||
};
|
||||
mSharedPrefs.registerOnSharedPreferenceChangeListener(mSharedPrefChangeListener);
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// enable/disable mDesktopMode mode on menu create and url load
|
||||
mDesktopMode = mSharedPrefs.getBoolean("pref_force_desktop", false);
|
||||
|
||||
// enable/disable advance menu
|
||||
mAdvancedMenu = mSharedPrefs.getBoolean("pref_advanced_menu", false);
|
||||
|
||||
// Acquire a reference to the system Location Manager
|
||||
mLocMngr = (LocationManager) this
|
||||
.getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
// Define a mSharedPrefChangeListener that responds to location updates
|
||||
mLocListener = new LocationListener() {
|
||||
// ------------------------ LocationListener ------------------------------
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// Called when a new location is found by the network location
|
||||
// provider.
|
||||
@ -134,31 +147,21 @@ public class IITC_Mobile extends Activity {
|
||||
mLastLocation = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
}
|
||||
};
|
||||
|
||||
mIsLocEnabled = mSharedPrefs.getBoolean("pref_user_loc", false);
|
||||
if (mIsLocEnabled) {
|
||||
// Register the mSharedPrefChangeListener with the Location Manager to receive
|
||||
// location updates
|
||||
mLocMngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
||||
0, 0, mLocListener);
|
||||
mLocMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
|
||||
mLocListener);
|
||||
}
|
||||
|
||||
// Clear the back stack
|
||||
mBackStack.clear();
|
||||
|
||||
handleIntent(getIntent(), true);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
@ -273,8 +276,8 @@ public class IITC_Mobile extends Activity {
|
||||
if (mIsLocEnabled) {
|
||||
// Register the mSharedPrefChangeListener with the Location Manager to receive
|
||||
// location updates
|
||||
mLocMngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, mLocListener);
|
||||
mLocMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mLocListener);
|
||||
mLocMngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
|
||||
mLocMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
|
||||
}
|
||||
|
||||
if (mReloadNeeded) {
|
||||
@ -295,7 +298,7 @@ public class IITC_Mobile extends Activity {
|
||||
mIitcWebView.loadUrl("javascript: window.idleSet();");
|
||||
|
||||
if (mIsLocEnabled)
|
||||
mLocMngr.removeUpdates(mLocListener);
|
||||
mLocMngr.removeUpdates(this);
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user