Update UI'
This commit is contained in:
parent
742e6fe6e5
commit
07086316f7
8 changed files with 52 additions and 56 deletions
|
@ -1,4 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@drawable/btn_inset_circle_p"/>
|
||||
|
||||
<item android:state_pressed="true"><inset android:insetBottom="@dimen/map_button_inset" android:insetLeft="@dimen/map_button_inset" android:insetRight="@dimen/map_button_inset" android:insetTop="@dimen/map_button_inset">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/map_widget_light_pressed" />
|
||||
</shape>
|
||||
</inset></item>
|
||||
|
||||
</selector>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:top="6dp"
|
||||
android:right="2dp">
|
||||
<bitmap
|
||||
android:src="@drawable/ic_overflow_menu_dark"
|
||||
android:gravity="top|end" />
|
||||
</item>
|
||||
</layer-list>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:top="6dp"
|
||||
android:right="2dp">
|
||||
<bitmap
|
||||
android:src="@drawable/ic_overflow_menu_light"
|
||||
android:gravity="top|end" />
|
||||
</item>
|
||||
</layer-list>
|
|
@ -238,7 +238,7 @@ public class MapActivityLayers {
|
|||
mapView.getZoom(), true);
|
||||
}
|
||||
mapView.refreshMap();
|
||||
activity.getDashboard().refreshContent();
|
||||
activity.getDashboard().refreshContent(true);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -390,7 +390,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
scrollView.setVisibility(View.GONE);
|
||||
listViewLayout.setVisibility(View.VISIBLE);
|
||||
if(refresh) {
|
||||
refreshContent();
|
||||
refreshContent(false);
|
||||
} else {
|
||||
updateListAdapter();
|
||||
updateListBackgroundHeight();
|
||||
|
@ -423,14 +423,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(false, deletedPoints, mapActivity, running,
|
||||
DashboardType.WAYPOINTS_FLAT == visibleType);
|
||||
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
|
||||
listAdapter, null);
|
||||
listAdapter);
|
||||
updateListAdapter(listAdapter, listener);
|
||||
} else if (DashboardType.WAYPOINTS_EDIT == visibleType) {
|
||||
deletedPoints.clear();
|
||||
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running,
|
||||
DashboardType.WAYPOINTS_FLAT == visibleType);
|
||||
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
|
||||
listAdapter, null);
|
||||
listAdapter);
|
||||
updateListAdapter(listAdapter, listener);
|
||||
|
||||
} else {
|
||||
|
@ -454,8 +454,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
updateListAdapter(listAdapter, listener);
|
||||
}
|
||||
|
||||
public void refreshContent() {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
public void refreshContent(boolean force) {
|
||||
if(visibleType == DashboardType.WAYPOINTS || force) {
|
||||
updateListAdapter();
|
||||
} else {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ public class ConfigureMapMenu {
|
|||
if(selected[0] == null) {
|
||||
settings.SHOW_POI_OVER_MAP.set(selected[0] != null);
|
||||
}
|
||||
ma.getDashboard().refreshContent(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -59,14 +60,14 @@ public class WaypointDialogHelper {
|
|||
}
|
||||
|
||||
public static void updatePointInfoView(final OsmandApplication app, final Activity activity,
|
||||
View localView, final LocationPointWrapper ps, final DialogFragment dialog) {
|
||||
View localView, final LocationPointWrapper ps, final boolean mapCenter) {
|
||||
WaypointHelper wh = app.getWaypointHelper();
|
||||
final LocationPoint point = ps.getPoint();
|
||||
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
||||
localView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showOnMap(app, activity, point, dialog);
|
||||
showOnMap(app, activity, point, mapCenter);
|
||||
}
|
||||
});
|
||||
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
|
||||
|
@ -127,7 +128,7 @@ public class WaypointDialogHelper {
|
|||
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter);
|
||||
} else {
|
||||
LocationPointWrapper point = (LocationPointWrapper) getItem(position);
|
||||
v = updateWaypointItemView(edit, deletedPoints, ctx, null, v, point, this);
|
||||
v = updateWaypointItemView(edit, deletedPoints, ctx, v, point, this);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
@ -139,12 +140,12 @@ public class WaypointDialogHelper {
|
|||
|
||||
|
||||
private View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
|
||||
final Activity ctx, final DialogFragment dialogFragment, View v, final LocationPointWrapper point,
|
||||
final Activity ctx, View v, final LocationPointWrapper point,
|
||||
final ArrayAdapter adapter) {
|
||||
if (v == null || v.findViewById(R.id.info_close) == null) {
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||
}
|
||||
updatePointInfoView(app, ctx, v, point, dialogFragment);
|
||||
updatePointInfoView(app, ctx, v, point, false);
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
if (!edit) {
|
||||
remove.setVisibility(View.GONE);
|
||||
|
@ -295,16 +296,13 @@ public class WaypointDialogHelper {
|
|||
}
|
||||
|
||||
public AdapterView.OnItemClickListener getDrawerItemClickListener(final FragmentActivity ctx, final int[] running,
|
||||
final ArrayAdapter<Object> listAdapter, final DialogFragment dialog) {
|
||||
final ArrayAdapter<Object> listAdapter) {
|
||||
return new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
||||
if (item == 0) {
|
||||
// TODO
|
||||
//mapActivity.getMapActions().onDrawerBack();
|
||||
} else if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
|
||||
if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
|
||||
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
|
||||
showOnMap(app, ctx, ps.getPoint(), dialog);
|
||||
showOnMap(app, ctx, ps.getPoint(), false);
|
||||
} else if (new Integer(WaypointHelper.TARGETS).equals(listAdapter.getItem(item))) {
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
|
||||
} else if (listAdapter.getItem(item) instanceof RadiusItem) {
|
||||
|
@ -412,17 +410,25 @@ public class WaypointDialogHelper {
|
|||
return points;
|
||||
}
|
||||
|
||||
public static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, DialogFragment dialog) {
|
||||
public static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, boolean center) {
|
||||
if (!(a instanceof MapActivity)) {
|
||||
return;
|
||||
}
|
||||
MapActivity ctx = (MapActivity) a;
|
||||
AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
|
||||
int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
|
||||
boolean di = dialog != null;
|
||||
double flat = locationPoint.getLatitude();
|
||||
double flon = locationPoint.getLongitude();
|
||||
if(!center) {
|
||||
RotatedTileBox cp = ctx.getMapView().getCurrentRotatedTileBox().copy();
|
||||
cp.setCenterLocation(0.5f, 0.25f);
|
||||
cp.setLatLonCenter(flat, flon);
|
||||
flat = cp.getLatFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
|
||||
flon = cp.getLonFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
|
||||
}
|
||||
if (thread.isAnimating()) {
|
||||
ctx.getMapView().setIntZoom(fZoom);
|
||||
ctx.getMapView().setLatLon(locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||
ctx.getMapView().setLatLon(flat, flon);
|
||||
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
||||
} else {
|
||||
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
||||
|
@ -431,16 +437,13 @@ public class WaypointDialogHelper {
|
|||
if (dist < t) {
|
||||
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
||||
} else {
|
||||
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
||||
}
|
||||
if (di) {
|
||||
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
||||
ctx.getMapLayers()
|
||||
.getContextMenuLayer()
|
||||
.setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
|
||||
PointDescription.getSimpleName(locationPoint, ctx));
|
||||
dialog.dismiss();
|
||||
thread.startMoving(flat, flon, fZoom, true);
|
||||
}
|
||||
// ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
||||
// ctx.getMapLayers()
|
||||
// .getContextMenuLayer()
|
||||
// .setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
|
||||
// PointDescription.getSimpleName(locationPoint, ctx));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ public class MapInfoWidgetsFactory {
|
|||
ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more);
|
||||
ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close);
|
||||
all.setImageDrawable(map.getMyApplication().getIconsCache()
|
||||
.getActionBarIcon(R.drawable.ic_overflow_menu_dark, !nightMode));
|
||||
.getActionBarIcon(R.drawable.ic_overflow_menu_white, !nightMode));
|
||||
remove.setImageDrawable(map.getMyApplication().getIconsCache()
|
||||
.getActionBarIcon(R.drawable.ic_action_remove_dark, !nightMode));
|
||||
}
|
||||
|
@ -395,8 +395,10 @@ public class MapInfoWidgetsFactory {
|
|||
}
|
||||
|
||||
public boolean updateWaypoint() {
|
||||
lastPoint = waypointHelper.getMostImportantLocationPoint(null);
|
||||
if (lastPoint == null) {
|
||||
final LocationPointWrapper pnt = waypointHelper.getMostImportantLocationPoint(null);
|
||||
boolean changed = this.lastPoint != pnt;
|
||||
this.lastPoint = pnt;
|
||||
if (pnt == null) {
|
||||
topBar.setOnClickListener(null);
|
||||
updateVisibility(waypointInfoBar, false);
|
||||
return false;
|
||||
|
@ -405,8 +407,8 @@ public class MapInfoWidgetsFactory {
|
|||
boolean updated = updateVisibility(waypointInfoBar, true);
|
||||
// pass top bar to make it clickable
|
||||
WaypointDialogHelper.updatePointInfoView(map.getMyApplication(), map, topBar,
|
||||
lastPoint, null);
|
||||
if (updated) {
|
||||
pnt, true);
|
||||
if (updated || changed) {
|
||||
ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more);
|
||||
ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close);
|
||||
all.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -418,7 +420,7 @@ public class MapInfoWidgetsFactory {
|
|||
remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
waypointHelper.removeVisibleLocationPoint(lastPoint);
|
||||
waypointHelper.removeVisibleLocationPoint(pnt);
|
||||
map.refreshMap();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue