mobile: use onConfigurationChanged instead of restoring savedInstanceState
This commit is contained in:
parent
f45ee1162a
commit
529f7fa254
@ -17,6 +17,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -51,30 +52,23 @@ public class IITC_Mobile extends Activity {
|
|||||||
};
|
};
|
||||||
sharedPref.registerOnSharedPreferenceChangeListener(listener);
|
sharedPref.registerOnSharedPreferenceChangeListener(listener);
|
||||||
|
|
||||||
// we do not want to reload our page every time we switch orientations...
|
// load new iitc web view with ingress intel page
|
||||||
// so restore state if activity was already created
|
Intent intent = getIntent();
|
||||||
if(savedInstanceState != null) {
|
String action = intent.getAction();
|
||||||
iitc_view.restoreState(savedInstanceState);
|
if (Intent.ACTION_VIEW.equals(action)) {
|
||||||
|
Uri uri = intent.getData();
|
||||||
|
String url = uri.toString();
|
||||||
|
if (intent.getScheme().equals("http://"))
|
||||||
|
url = url.replace("http://", "https://");
|
||||||
|
Log.d("Intent received", "url: " + url);
|
||||||
|
if (url.contains("ingress.com")) {
|
||||||
|
Log.d("Intent received", "loading url...");
|
||||||
|
iitc_view.loadUrl(addUrlParam(url));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// load new iitc web view with ingress intel page
|
Log.d("No Intent call", "loading https://www.ingress.com/intel");
|
||||||
Intent intent = getIntent();
|
iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel"));
|
||||||
String action = intent.getAction();
|
|
||||||
if (Intent.ACTION_VIEW.equals(action)) {
|
|
||||||
Uri uri = intent.getData();
|
|
||||||
String url = uri.toString();
|
|
||||||
if (intent.getScheme().equals("http://"))
|
|
||||||
url = url.replace("http://", "https://");
|
|
||||||
Log.d("Intent received", "url: " + url);
|
|
||||||
if (url.contains("ingress.com")) {
|
|
||||||
Log.d("Intent received", "loading url...");
|
|
||||||
iitc_view.loadUrl(addUrlParam(url));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Log.d("No Intent call", "loading https://www.ingress.com/intel");
|
|
||||||
iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,10 +98,10 @@ public class IITC_Mobile extends Activity {
|
|||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// save instance state to avoid reloading on orientation change
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
iitc_view.saveState(outState);
|
Log.d("iitcm", "configuration changed...restoring...");
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we want a self defined behavior for the back button
|
// we want a self defined behavior for the back button
|
||||||
|
Loading…
x
Reference in New Issue
Block a user