But ActionBar related stuff into new class ActionBarHelper

This commit is contained in:
fkloft
2013-09-18 15:31:50 +02:00
parent cdc98de350
commit eee9ce78e0
3 changed files with 174 additions and 105 deletions

View File

@ -96,46 +96,20 @@ public class IITC_JSInterface {
}
@JavascriptInterface
public void switchToPane(String id) {
public void switchToPane(final String id) {
final IITC_Mobile iitcm = (IITC_Mobile) mContext;
final int button_id;
final String title;
if (id.equals("map")) {
button_id = android.R.id.home;
title = iitcm.getString(R.string.app_name);
} else if (id.equals("info")) {
button_id = R.id.menu_info;
title = "Info";
} else if (id.equals("full")) {
button_id = R.id.menu_full;
title = "Full";
} else if (id.equals("compact")) {
button_id = R.id.menu_compact;
title = "Compact";
} else if (id.equals("public")) {
button_id = R.id.menu_public;
title = "Public";
} else if (id.equals("faction")) {
button_id = R.id.menu_faction;
title = "Faction";
} else if (id.equals("debug")) {
button_id = R.id.menu_debug;
title = "Debug";
}
// default
else {
button_id = android.R.id.home;
title = iitcm.getString(R.string.app_name);
}
Log.d("iitcm", "switch to pane " + id);
iitcm.runOnUiThread(new Runnable() {
@Override
public void run() {
iitcm.getActionBar().setTitle(title);
iitcm.backStackUpdate(button_id);
ActionBarHelper actionbar = iitcm.getActionBarHelper();
Integer button = IITC_Mobile.PANES.get(id);
if (button == null)
button = android.R.id.home;
actionbar.switchTo(button);
iitcm.backStackUpdate(button);
}
});
}
@ -169,10 +143,10 @@ public class IITC_JSInterface {
public void setLayers(String base_layer, String overlay_layer) {
/*
* the layer strings have a form like:
* [{"layerId":27,"name":"MapQuest OSM","active":true},
* {"layerId":28,"name":"Default Ingress Map","active":false}]
* Put it in a JSONArray and parse it
* the layer strings have a form like:
* [{"layerId":27,"name":"MapQuest OSM","active":true},
* {"layerId":28,"name":"Default Ingress Map","active":false}]
* Put it in a JSONArray and parse it
*/
JSONArray base_layersJSON = null;
JSONArray overlay_layersJSON = null;
@ -287,6 +261,7 @@ public class IITC_JSInterface {
final ListView list = dialog.getListView();
list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
boolean disable = false;
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
int j = 0;