use of net.osmand.plus.views.mapwidgets.MapWidgetRegistry in project Osmand by osmandapp.
the class DashboardOnMap method updateToolbarActions.
private void updateToolbarActions() {
TextView tv = (TextView) dashboardView.findViewById(R.id.toolbar_text);
tv.setText("");
boolean waypointsVisible = visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT;
if (waypointsVisible) {
tv.setText(R.string.waypoints);
} else if (visibleType == DashboardType.CONFIGURE_MAP) {
tv.setText(R.string.configure_map);
} else if (visibleType == DashboardType.CONFIGURE_SCREEN) {
tv.setText(R.string.layer_map_appearance);
} else if (visibleType == DashboardType.ROUTE_PREFERENCES) {
tv.setText(R.string.shared_string_settings);
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
tv.setText(R.string.map_underlay);
} else if (visibleType == DashboardType.OVERLAY_MAP) {
tv.setText(R.string.map_overlay);
} else if (visibleType == DashboardType.MAPILLARY) {
tv.setText(R.string.mapillary);
} else if (visibleType == DashboardType.CONTOUR_LINES) {
tv.setText(R.string.srtm_plugin_name);
} else if (visibleType == DashboardType.HILLSHADE) {
tv.setText(R.string.layer_hillshade);
} else if (visibleType == DashboardType.OSM_NOTES) {
tv.setText(R.string.osm_notes);
}
ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit);
edit.setVisibility(View.GONE);
ImageView sort = (ImageView) dashboardView.findViewById(R.id.toolbar_sort);
sort.setVisibility(View.GONE);
ImageView ok = (ImageView) dashboardView.findViewById(R.id.toolbar_ok);
ok.setVisibility(View.GONE);
ImageView flat = (ImageView) dashboardView.findViewById(R.id.toolbar_flat);
flat.setVisibility(View.GONE);
ImageView settingsButton = (ImageView) dashboardView.findViewById(R.id.toolbar_settings);
settingsButton.setVisibility(View.GONE);
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list);
lst.setVisibility(View.GONE);
ImageView back = (ImageView) dashboardView.findViewById(R.id.toolbar_back);
back.setImageDrawable(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
backPressed();
}
});
if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) {
if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
flat.setVisibility(View.VISIBLE);
final boolean flatNow = visibleType == DashboardType.WAYPOINTS_FLAT;
flat.setImageDrawable(iconsCache.getIcon(flatNow ? R.drawable.ic_tree_list_dark : R.drawable.ic_flat_list_dark));
flat.setContentDescription(mapActivity.getString(flatNow ? R.string.access_tree_list : R.string.drawer));
flat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS : DashboardType.WAYPOINTS_FLAT, previousVisibleType, false, AndroidUtils.getCenterViewCoordinates(v));
}
});
}
}
if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) {
settingsButton.setVisibility(View.VISIBLE);
settingsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new DashboardSettingsDialogFragment().show(mapActivity.getSupportFragmentManager(), "dashboard_settings");
}
});
lst.setVisibility(View.VISIBLE);
lst.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideDashboard(false);
mapActivity.openDrawer();
}
});
}
toolbar.getMenu().clear();
if (visibleType == DashboardType.CONFIGURE_SCREEN) {
toolbar.inflateMenu(R.menu.refresh_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.action_refresh) {
MapWidgetRegistry registry = mapActivity.getMapLayers().getMapWidgetRegistry();
registry.resetToDefault();
MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
updateListAdapter(registry.getViewConfigureMenuAdapter(mapActivity));
}
return false;
}
});
}
}
Aggregations