Fix crashes
This commit is contained in:
parent
005bae6db9
commit
ef031d7ec9
13 changed files with 115 additions and 79 deletions
|
@ -536,7 +536,7 @@ public class BinaryMapIndexReader {
|
|||
return r;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<City> getCities(String region, SearchRequest<City> resultMatcher,
|
||||
|
@ -547,6 +547,9 @@ public class BinaryMapIndexReader {
|
|||
int cityType) throws IOException {
|
||||
List<City> cities = new ArrayList<City>();
|
||||
AddressRegion r = getRegionByName(region);
|
||||
if(r == null) {
|
||||
return cities;
|
||||
}
|
||||
for(CitiesBlock block : r.cities) {
|
||||
if(block.type == cityType) {
|
||||
codedIS.seek(block.filePointer);
|
||||
|
|
|
@ -117,7 +117,13 @@ public class PointDescription {
|
|||
return pnt.zone_number + "" + pnt.zone_letter + " " + ((long) pnt.northing) + " "
|
||||
+ ((long) pnt.easting);
|
||||
} else {
|
||||
return ctx.getString( sh? R.string.short_location_on_map : R.string.location_on_map, convert(lat, f), convert(lon, f));
|
||||
try {
|
||||
return ctx.getString(sh ? R.string.short_location_on_map : R.string.location_on_map, convert(lat, f),
|
||||
convert(lon, f));
|
||||
} catch(RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
return ctx.getString(sh ? R.string.short_location_on_map : R.string.location_on_map, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -433,7 +433,7 @@ public class OsmandSettings {
|
|||
|
||||
@Override
|
||||
protected boolean setValue(Object prefs, Integer val) {
|
||||
return settingsAPI.edit( prefs).putInt(getId(), val).commit();
|
||||
return settingsAPI.edit(prefs).putInt(getId(), val).commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import net.osmand.plus.views.PointNavigationLayer;
|
|||
import net.osmand.plus.views.RouteLayer;
|
||||
import net.osmand.plus.views.TransportInfoLayer;
|
||||
import net.osmand.plus.views.TransportStopsLayer;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -76,9 +77,15 @@ public class MapActivityLayers {
|
|||
private ContextMenuLayer contextMenuLayer;
|
||||
private MapControlsLayer mapControlsLayer;
|
||||
private DownloadedRegionsLayer downloadedRegionsLayer;
|
||||
|
||||
private MapWidgetRegistry mapWidgetRegistry;
|
||||
|
||||
public MapActivityLayers(MapActivity activity) {
|
||||
this.activity = activity;
|
||||
this.mapWidgetRegistry = new MapWidgetRegistry(activity.getMyApplication().getSettings());
|
||||
}
|
||||
|
||||
public MapWidgetRegistry getMapWidgetRegistry() {
|
||||
return mapWidgetRegistry;
|
||||
}
|
||||
|
||||
public OsmandApplication getApplication(){
|
||||
|
|
|
@ -72,7 +72,6 @@ public class TrackActivity extends TabActivity {
|
|||
|
||||
setViewPagerAdapter(mViewPager, new ArrayList<TabActivity.TabItem>());
|
||||
mSlidingTabLayout.setViewPager(mViewPager);
|
||||
|
||||
new AsyncTask<Void, Void, GPXFile>() {
|
||||
|
||||
protected void onPreExecute() {
|
||||
|
@ -114,6 +113,9 @@ public class TrackActivity extends TabActivity {
|
|||
}
|
||||
|
||||
public List<GpxSelectionHelper.GpxDisplayGroup> getResult() {
|
||||
if(result == null) {
|
||||
return new ArrayList<GpxSelectionHelper.GpxDisplayGroup>();
|
||||
}
|
||||
if (result.modifiedTime != modifiedTime) {
|
||||
modifiedTime = result.modifiedTime;
|
||||
GpxSelectionHelper selectedGpxHelper = ((OsmandApplication) getApplication()).getSelectedGpxHelper();
|
||||
|
@ -171,11 +173,11 @@ public class TrackActivity extends TabActivity {
|
|||
}
|
||||
|
||||
boolean isHavingWayPoints(){
|
||||
return getGpx().hasWptPt();
|
||||
return getGpx() != null && getGpx().hasWptPt();
|
||||
}
|
||||
|
||||
boolean isHavingRoutePoints(){
|
||||
return getGpx().hasRtePt();
|
||||
return getGpx() != null && getGpx().hasRtePt();
|
||||
}
|
||||
|
||||
public GPXFile getGpx() {
|
||||
|
|
|
@ -44,6 +44,7 @@ public class SearchRegionByNameActivity extends SearchByNameAbstractActivity<Reg
|
|||
protected LatLon getLocation(RegionAddressRepository item) {
|
||||
return item.getEstimatedRegionCenter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.osmand.plus.osmo.DashOsMoFragment;
|
|||
import net.osmand.plus.parkingpoint.DashParkingFragment;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.DownloadedRegionsLayer;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
|
@ -422,8 +423,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
} else {
|
||||
scrollView.setVisibility(View.GONE);
|
||||
listViewLayout.setVisibility(View.VISIBLE);
|
||||
if(listView instanceof ObservableListView) {
|
||||
onScrollChanged(((ObservableListView)listView).getScrollY(), false, false);
|
||||
if (listView instanceof ObservableListView) {
|
||||
onScrollChanged(((ObservableListView) listView).getScrollY(), false, false);
|
||||
}
|
||||
if(refresh) {
|
||||
refreshContent(false);
|
||||
|
@ -471,7 +472,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
|
||||
} else {
|
||||
if (DashboardType.CONFIGURE_SCREEN == visibleType) {
|
||||
cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
|
||||
cm = mapActivity.getMapLayers().getMapWidgetRegistry().getViewConfigureMenuAdapter(mapActivity);
|
||||
} else if(DashboardType.CONFIGURE_MAP == visibleType) {
|
||||
cm = new ConfigureMapMenu().createListAdapter(mapActivity);
|
||||
} else if(DashboardType.LIST_MENU == visibleType) {
|
||||
|
@ -779,7 +780,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
|
||||
// Translate list background
|
||||
if (portrait) {
|
||||
setTranslationY(listBackgroundView, Math.max(0, -scrollY + mFlexibleSpaceImageHeight));
|
||||
if(listBackgroundView != null) {
|
||||
setTranslationY(listBackgroundView, Math.max(0, -scrollY + mFlexibleSpaceImageHeight));
|
||||
}
|
||||
}
|
||||
if (portrait) {
|
||||
setTranslationY(toolbar, Math.min(0, -scrollY + mFlexibleSpaceImageHeight - mFlexibleBlurSpaceHeight));
|
||||
|
@ -839,7 +842,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
private void updateListAdapter(ArrayAdapter<?> listAdapter, OnItemClickListener listener) {
|
||||
this.listAdapter = listAdapter;
|
||||
this.listAdapterOnClickListener = listener;
|
||||
if(this.listView != null) {
|
||||
if (this.listView != null) {
|
||||
listView.setAdapter(listAdapter);
|
||||
if(!portrait) {
|
||||
listView.setOnItemClickListener(this.listAdapterOnClickListener);
|
||||
|
|
|
@ -106,7 +106,7 @@ public class SelectedGPXFragment extends ListFragment {
|
|||
super.onResume();
|
||||
updateContent();
|
||||
updateEnable = true;
|
||||
if(getGpx().showCurrentTrack && filterType() == GpxDisplayItemType.TRACK_POINTS) {
|
||||
if(getGpx() != null && getGpx().showCurrentTrack && filterType() == GpxDisplayItemType.TRACK_POINTS) {
|
||||
startHandler();
|
||||
}
|
||||
}
|
||||
|
@ -121,8 +121,8 @@ public class SelectedGPXFragment extends ListFragment {
|
|||
|
||||
|
||||
protected List<GpxDisplayGroup> filterGroups(GpxDisplayItemType type) {
|
||||
List<GpxDisplayGroup> result = ((TrackActivity)getActivity()).getResult();
|
||||
List<GpxDisplayGroup> groups = new ArrayList<GpxSelectionHelper.GpxDisplayGroup>();
|
||||
List<GpxDisplayGroup> result = ((TrackActivity) getActivity()).getResult();
|
||||
List<GpxDisplayGroup> groups = new ArrayList<GpxSelectionHelper.GpxDisplayGroup>();
|
||||
for (GpxDisplayGroup group : result) {
|
||||
boolean add = group.getType() == type || type == null;
|
||||
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
|
||||
|
@ -238,7 +238,7 @@ public class SelectedGPXFragment extends ListFragment {
|
|||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
menu.clear();
|
||||
((TrackActivity) getActivity()).getClearToolbar(false);
|
||||
if (getGpx().path != null && !getGpx().showCurrentTrack) {
|
||||
if (getGpx() != null && getGpx().path != null && !getGpx().showCurrentTrack) {
|
||||
MenuItem item = menu.add(R.string.shared_string_share).setIcon(R.drawable.ic_action_gshare_dark)
|
||||
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.osmo;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.Location;
|
||||
|
@ -201,13 +202,16 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
|
|||
}
|
||||
|
||||
//remove all inactive devices
|
||||
for (OsMoGroupsStorage.OsMoDevice device : devices) {
|
||||
if (!device.isActive() && !device.isEnabled() && devices.size() > 2) {
|
||||
devices.remove(device);
|
||||
}
|
||||
Iterator<OsMoDevice> it = devices.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (devices.size() < 4) {
|
||||
break;
|
||||
}
|
||||
OsMoGroupsStorage.OsMoDevice device = it.next();
|
||||
if (!device.isActive() && !device.isEnabled() && devices.size() > 2) {
|
||||
it.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sortDevices(devices);
|
||||
|
|
|
@ -126,8 +126,10 @@ public class PoiFiltersHelper {
|
|||
AbstractPoiType tp = application.getPoiTypes().getAnyPoiTypeByKey(typeId);
|
||||
if(tp != null) {
|
||||
PoiLegacyFilter lf = new PoiLegacyFilter(tp, application);
|
||||
cacheTopStandardFilters.add(lf);
|
||||
sortListOfFilters(cacheTopStandardFilters);
|
||||
ArrayList<PoiLegacyFilter> copy = new ArrayList<PoiLegacyFilter>(cacheTopStandardFilters);
|
||||
copy.add(lf);
|
||||
sortListOfFilters(copy);
|
||||
cacheTopStandardFilters = copy;
|
||||
return lf;
|
||||
}
|
||||
}
|
||||
|
@ -136,9 +138,9 @@ public class PoiFiltersHelper {
|
|||
|
||||
|
||||
public void reloadAllPoiFilters() {
|
||||
cacheTopStandardFilters = null;
|
||||
showAllPOIFilter = null;
|
||||
getShowAllPOIFilter();
|
||||
cacheTopStandardFilters = null;
|
||||
getTopDefinedPoiFilters();
|
||||
}
|
||||
|
||||
|
@ -168,15 +170,16 @@ public class PoiFiltersHelper {
|
|||
|
||||
public List<PoiLegacyFilter> getTopDefinedPoiFilters() {
|
||||
if (cacheTopStandardFilters == null) {
|
||||
cacheTopStandardFilters = new ArrayList<PoiLegacyFilter>();
|
||||
List<PoiLegacyFilter> top = new ArrayList<PoiLegacyFilter>();
|
||||
// user defined
|
||||
cacheTopStandardFilters.addAll(getUserDefinedPoiFilters());
|
||||
top.addAll(getUserDefinedPoiFilters());
|
||||
// default
|
||||
MapPoiTypes poiTypes = application.getPoiTypes();
|
||||
for (PoiFilter t : poiTypes.getTopVisibleFilters()) {
|
||||
cacheTopStandardFilters.add(new PoiLegacyFilter(t, application));
|
||||
top.add(new PoiLegacyFilter(t, application));
|
||||
}
|
||||
sortListOfFilters(cacheTopStandardFilters);
|
||||
sortListOfFilters(top);
|
||||
cacheTopStandardFilters = top;
|
||||
}
|
||||
List<PoiLegacyFilter> result = new ArrayList<PoiLegacyFilter>();
|
||||
if(OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) != null) {
|
||||
|
@ -205,7 +208,9 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
boolean res = helper.deleteFilter(helper.getWritableDatabase(), filter);
|
||||
if(res){
|
||||
cacheTopStandardFilters.remove(filter);
|
||||
ArrayList<PoiLegacyFilter> copy = new ArrayList<>(cacheTopStandardFilters);
|
||||
copy.remove(filter);
|
||||
cacheTopStandardFilters = copy;
|
||||
}
|
||||
helper.close();
|
||||
return res;
|
||||
|
@ -225,8 +230,10 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
res = helper.addFilter(filter, helper.getWritableDatabase(), false);
|
||||
if(res){
|
||||
cacheTopStandardFilters.add(filter);
|
||||
sortListOfFilters(cacheTopStandardFilters);
|
||||
ArrayList<PoiLegacyFilter> copy = new ArrayList<>(cacheTopStandardFilters);
|
||||
copy.add(filter);
|
||||
sortListOfFilters(copy);
|
||||
cacheTopStandardFilters = copy;
|
||||
}
|
||||
helper.close();
|
||||
return res;
|
||||
|
|
|
@ -216,9 +216,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
};
|
||||
adapter.item(R.string.layer_map).iconColor(R.drawable.ic_world_globe_dark)
|
||||
.listen(listener).position(3).reg();
|
||||
adapter.item(R.string.layer_overlay).selected(overlayLayer.getMap() != null ? 1 : 0).
|
||||
adapter.item(R.string.layer_overlay).selected(overlayLayer != null && overlayLayer.getMap() != null ? 1 : 0).
|
||||
iconColor(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
|
||||
adapter.item(R.string.layer_underlay).selected(underlayLayer.getMap() != null ? 1 : 0)
|
||||
adapter.item(R.string.layer_underlay).selected(underlayLayer != null && underlayLayer.getMap() != null ? 1 : 0)
|
||||
.iconColor(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,10 @@ package net.osmand.plus.views;
|
|||
import java.lang.reflect.Field;
|
||||
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
|
||||
|
@ -28,7 +24,6 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
|
@ -71,8 +66,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void initLayer(final OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
mapInfoControls = new MapWidgetRegistry(map.getMyApplication().getSettings());
|
||||
|
||||
mapInfoControls = map.getMapLayers().getMapWidgetRegistry() ;
|
||||
leftStack = (LinearLayout) map.findViewById(R.id.map_left_widgets_panel);
|
||||
rightStack = (LinearLayout) map.findViewById(R.id.map_right_widgets_panel);
|
||||
expand = (ImageButton) map.findViewById(R.id.map_collapse_button);
|
||||
|
@ -307,32 +301,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
|
||||
|
||||
public ContextMenuAdapter getViewConfigureMenuAdapter() {
|
||||
ContextMenuAdapter cm = new ContextMenuAdapter(view.getContext());
|
||||
cm.setDefaultLayoutId(R.layout.drawer_list_item);
|
||||
cm.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
||||
cm.setChangeAppModeListener(new ConfigureMapMenu.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(boolean allModes) {
|
||||
map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter());
|
||||
}
|
||||
});
|
||||
cm.item(R.string.map_widget_reset)
|
||||
.iconColor(R.drawable.ic_action_reset_to_default_dark).listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
mapInfoControls.resetToDefault();
|
||||
recreateControls();
|
||||
adapter.notifyDataSetInvalidated();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
final ApplicationMode mode = settings.getApplicationMode();
|
||||
mapInfoControls.addControls(this, cm, mode);
|
||||
return cm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import android.content.Context;
|
||||
|
@ -214,21 +215,21 @@ public class MapWidgetRegistry {
|
|||
settings.CENTER_POSITION_ON_MAP.resetToDefault();
|
||||
}
|
||||
|
||||
public void addControlsAppearance(final MapInfoLayer mil, ContextMenuAdapter cm, ApplicationMode mode) {
|
||||
public void addControlsAppearance(final MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
|
||||
// addControlId(mil, cm, R.string.map_widget_show_ruler, settings.SHOW_RULER);
|
||||
addControlId(mil, cm, R.string.map_widget_show_destination_arrow, settings.SHOW_DESTINATION_ARROW);
|
||||
addControlId(mil, cm, R.string.map_widget_transparent, settings.TRANSPARENT_MAP_THEME);
|
||||
addControlId(mil, cm, R.string.always_center_position_on_map, settings.CENTER_POSITION_ON_MAP);
|
||||
addControlId(map, cm, R.string.map_widget_show_destination_arrow, settings.SHOW_DESTINATION_ARROW);
|
||||
addControlId(map, cm, R.string.map_widget_transparent, settings.TRANSPARENT_MAP_THEME);
|
||||
addControlId(map, cm, R.string.always_center_position_on_map, settings.CENTER_POSITION_ON_MAP);
|
||||
if(mode != ApplicationMode.DEFAULT) {
|
||||
addControlId(mil, cm, R.string.map_widget_top_text, settings.SHOW_STREET_NAME);
|
||||
addControlId(map, cm, R.string.map_widget_top_text, settings.SHOW_STREET_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addControlId(final MapInfoLayer mil, ContextMenuAdapter cm, int stringId, OsmandPreference<Boolean> pref) {
|
||||
private void addControlId(final MapActivity map, ContextMenuAdapter cm, int stringId, OsmandPreference<Boolean> pref) {
|
||||
cm.item(stringId).selected( pref.get() ? 1 : 0)
|
||||
// .icons(r.drawableDark, r.drawableLight)
|
||||
.listen(new ApearanceOnContextMenuClick(pref, mil.getMapActivity())).reg();
|
||||
.listen(new ApearanceOnContextMenuClick(pref, map)).reg();
|
||||
}
|
||||
|
||||
class ApearanceOnContextMenuClick implements OnContextMenuClick {
|
||||
|
@ -259,15 +260,15 @@ public class MapWidgetRegistry {
|
|||
}
|
||||
|
||||
|
||||
public void addControls(MapInfoLayer mil, ContextMenuAdapter cm, ApplicationMode mode) {
|
||||
public void addControls(MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
|
||||
cm.item(R.string.map_widget_right).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
addControls(mil, cm, right, mode);
|
||||
addControls(map, cm, right, mode);
|
||||
if(mode != ApplicationMode.DEFAULT) {
|
||||
cm.item(R.string.map_widget_left).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
addControls(mil, cm, left, mode);
|
||||
addControls(map, cm, left, mode);
|
||||
}
|
||||
cm.item(R.string.map_widget_appearance_rem).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
addControlsAppearance(mil, cm, mode);
|
||||
addControlsAppearance(map, cm, mode);
|
||||
}
|
||||
|
||||
public String getText(Context ctx, final ApplicationMode mode, final MapWidgetRegInfo r) {
|
||||
|
@ -282,7 +283,7 @@ public class MapWidgetRegistry {
|
|||
return left;
|
||||
}
|
||||
|
||||
private void addControls(final MapInfoLayer mil, final ContextMenuAdapter adapter, Set<MapWidgetRegInfo> top, final ApplicationMode mode) {
|
||||
private void addControls(final MapActivity map, final ContextMenuAdapter adapter, Set<MapWidgetRegInfo> top, final ApplicationMode mode) {
|
||||
for(final MapWidgetRegInfo r : top){
|
||||
adapter.item(r.messageId).selected(r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0)
|
||||
.iconColor(r.drawableMenu).listen(new OnContextMenuClick() {
|
||||
|
@ -290,14 +291,17 @@ public class MapWidgetRegistry {
|
|||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
|
||||
changeVisibility(r);
|
||||
mil.recreateControls();
|
||||
MapInfoLayer mil = map.getMapLayers().getMapInfoLayer();
|
||||
if (mil != null) {
|
||||
mil.recreateControls();
|
||||
}
|
||||
adapter.setItemName(pos, getText(mil.getMapActivity(), mode, r));
|
||||
adapter.setSelection(pos, r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0);
|
||||
a.notifyDataSetInvalidated();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
adapter.setItemName(adapter.length() - 1, getText(mil.getMapActivity(), mode, r));
|
||||
adapter.setItemName(adapter.length() - 1, getText(map, mode, r));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,5 +376,35 @@ public class MapWidgetRegistry {
|
|||
return priorityOrder - another.priorityOrder;
|
||||
}
|
||||
}
|
||||
|
||||
public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) {
|
||||
ContextMenuAdapter cm = new ContextMenuAdapter(map);
|
||||
cm.setDefaultLayoutId(R.layout.drawer_list_item);
|
||||
cm.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
||||
cm.setChangeAppModeListener(new ConfigureMapMenu.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(boolean allModes) {
|
||||
map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter(map));
|
||||
}
|
||||
});
|
||||
cm.item(R.string.map_widget_reset).iconColor(R.drawable.ic_action_reset_to_default_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
resetToDefault();
|
||||
MapInfoLayer mil = map.getMapLayers().getMapInfoLayer();
|
||||
if (mil != null) {
|
||||
mil.recreateControls();
|
||||
}
|
||||
adapter.notifyDataSetInvalidated();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
final ApplicationMode mode = settings.getApplicationMode();
|
||||
addControls(map, cm, mode);
|
||||
return cm;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue