[android] Added showing PP from discovery screen

This commit is contained in:
Александр Зацепин 2017-12-06 18:11:44 +03:00 committed by Ilya Grechuhin
parent 9c5facf6bd
commit 2b0aa4ef2a
3 changed files with 49 additions and 14 deletions

View file

@ -1053,16 +1053,37 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (destination == null)
return;
addTask(new MapTask()
String action = data.getAction();
if (TextUtils.isEmpty(action))
return;
MapTask task;
if (action.equals(DiscoveryActivity.ACTION_ROUTE_TO))
{
@Override
public boolean run(MwmActivity target)
task = new MapTask()
{
RoutingController.get().setRouterType(Framework.ROUTER_TYPE_PEDESTRIAN);
RoutingController.get().prepare(true, destination);
return false;
}
});
@Override
public boolean run(MwmActivity target)
{
RoutingController.get().setRouterType(Framework.ROUTER_TYPE_PEDESTRIAN);
RoutingController.get().prepare(true, destination);
return false;
}
};
}
else
{
task = new MapTask()
{
@Override
public boolean run(MwmActivity target)
{
Framework.nativeShowFeatureByLatLon(destination.getLat(), destination.getLon());
return false;
}
};
}
addTask(task);
}
@Override

View file

@ -7,6 +7,8 @@ import com.mapswithme.maps.base.BaseMwmFragmentActivity;
public class DiscoveryActivity extends BaseMwmFragmentActivity
{
public static final String EXTRA_DISCOVERY_OBJECT = "extra_discovery_object";
public static final String ACTION_ROUTE_TO = "action_route_to";
public static final String ACTION_SHOW_ON_MAP = "action_show_on_map";
@Override
protected Class<? extends Fragment> getFragmentClass()

View file

@ -301,20 +301,32 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements UICallb
@Override
public void onItemSelected(@NonNull Items.SearchItem item)
{
// TODO: Show point on the map. Coming soon.
Intent intent = new Intent(DiscoveryActivity.ACTION_SHOW_ON_MAP);
setResult(item, intent);
}
@Override
public void onActionButtonSelected(@NonNull Items.SearchItem item)
{
Intent intent = new Intent();
String title = TextUtils.isEmpty(item.getTitle()) ? "" : item.getTitle();
String subtitle = TextUtils.isEmpty(item.getSubtitle()) ? "" : item.getSubtitle();
MapObject poi = MapObject.createMapObject(FeatureId.EMPTY, MapObject.SEARCH, title, subtitle,
item.getLat(), item.getLon());
Intent intent = new Intent(DiscoveryActivity.ACTION_ROUTE_TO);
setResult(item, intent);
}
private void setResult(@NonNull Items.SearchItem item, @NonNull Intent intent)
{
MapObject poi = createMapObject(item);
intent.putExtra(DiscoveryActivity.EXTRA_DISCOVERY_OBJECT, poi);
getContext().setResult(Activity.RESULT_OK, intent);
getContext().finish();
}
@NonNull
private static MapObject createMapObject(@NonNull Items.SearchItem item)
{
String title = TextUtils.isEmpty(item.getTitle()) ? "" : item.getTitle();
String subtitle = TextUtils.isEmpty(item.getSubtitle()) ? "" : item.getSubtitle();
return MapObject.createMapObject(FeatureId.EMPTY, MapObject.SEARCH, title, subtitle,
item.getLat(), item.getLon());
}
}
}