Replaced RESULT_OK with standard value in external API.

This commit is contained in:
GaidamakUA 2016-04-15 14:41:56 +03:00
parent 6486387a91
commit 9d71ccc37d

View file

@ -1,8 +1,10 @@
package net.osmand.plus.helpers; package net.osmand.plus.helpers;
import java.io.ByteArrayInputStream; import android.app.Activity;
import java.io.File; import android.content.DialogInterface;
import java.util.Arrays; import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AlertDialog;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
@ -29,10 +31,10 @@ import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.router.TurnType; import net.osmand.router.TurnType;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import android.content.DialogInterface;
import android.content.Intent; import java.io.ByteArrayInputStream;
import android.net.Uri; import java.io.File;
import android.support.v7.app.AlertDialog; import java.util.Arrays;
public class ExternalApiHelper { public class ExternalApiHelper {
@ -99,9 +101,11 @@ public class ExternalApiHelper {
public static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR; public static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR;
// RESULT_OK == -1
public static final int RESULT_CODE_OK = 0; // RESULT_CANCELED == 0
public static final int RESULT_CODE_ERROR_UNKNOWN = -1; // RESULT_FIRST_USER == 1
// from Activity
public static final int RESULT_CODE_ERROR_UNKNOWN = -3;
public static final int RESULT_CODE_ERROR_NOT_IMPLEMENTED = -2; public static final int RESULT_CODE_ERROR_NOT_IMPLEMENTED = -2;
public static final int RESULT_CODE_ERROR_PLUGIN_INACTIVE = 10; public static final int RESULT_CODE_ERROR_PLUGIN_INACTIVE = 10;
public static final int RESULT_CODE_ERROR_GPX_NOT_FOUND = 20; public static final int RESULT_CODE_ERROR_GPX_NOT_FOUND = 20;
@ -173,7 +177,7 @@ public class ExternalApiHelper {
} else { } else {
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx); app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
} }
resultCode = RESULT_CODE_OK; resultCode = Activity.RESULT_OK;
} else { } else {
resultCode = RESULT_CODE_ERROR_GPX_NOT_FOUND; resultCode = RESULT_CODE_ERROR_GPX_NOT_FOUND;
} }
@ -261,7 +265,7 @@ public class ExternalApiHelper {
} }
} }
resultCode = RESULT_CODE_OK; resultCode = Activity.RESULT_OK;
} }
} else if (API_CMD_GET_INFO.equals(cmd)) { } else if (API_CMD_GET_INFO.equals(cmd)) {
@ -296,7 +300,7 @@ public class ExternalApiHelper {
result.putExtra(PARAM_VERSION, VERSION_CODE); result.putExtra(PARAM_VERSION, VERSION_CODE);
finish = true; finish = true;
resultCode = RESULT_CODE_OK; resultCode = Activity.RESULT_OK;
} else if (API_CMD_ADD_FAVORITE.equals(cmd)) { } else if (API_CMD_ADD_FAVORITE.equals(cmd)) {
String name = uri.getQueryParameter(PARAM_NAME); String name = uri.getQueryParameter(PARAM_NAME);
@ -334,7 +338,7 @@ public class ExternalApiHelper {
helper.addFavourite(fav); helper.addFavourite(fav);
showOnMap(lat, lon, fav, mapActivity.getMapLayers().getFavoritesLayer().getObjectName(fav)); showOnMap(lat, lon, fav, mapActivity.getMapLayers().getFavoritesLayer().getObjectName(fav));
resultCode = RESULT_CODE_OK; resultCode = Activity.RESULT_OK;
} else if (API_CMD_ADD_MAP_MARKER.equals(cmd)) { } else if (API_CMD_ADD_MAP_MARKER.equals(cmd)) {
double lat = Double.parseDouble(uri.getQueryParameter(PARAM_LAT)); double lat = Double.parseDouble(uri.getQueryParameter(PARAM_LAT));
@ -351,7 +355,7 @@ public class ExternalApiHelper {
if (marker != null) { if (marker != null) {
showOnMap(lat, lon, marker, mapActivity.getMapLayers().getMapMarkersLayer().getObjectName(marker)); showOnMap(lat, lon, marker, mapActivity.getMapLayers().getMapMarkersLayer().getObjectName(marker));
} }
resultCode = RESULT_CODE_OK; resultCode = Activity.RESULT_OK;
} else if (API_CMD_START_GPX_REC.equals(cmd)) { } else if (API_CMD_START_GPX_REC.equals(cmd)) {
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
@ -361,7 +365,7 @@ public class ExternalApiHelper {
plugin.startGPXMonitoring(null); plugin.startGPXMonitoring(null);
} }
resultCode = RESULT_CODE_OK; resultCode = Activity.RESULT_OK;
} else if (API_CMD_STOP_GPX_REC.equals(cmd)) { } else if (API_CMD_STOP_GPX_REC.equals(cmd)) {
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
@ -371,7 +375,7 @@ public class ExternalApiHelper {
plugin.stopRecording(); plugin.stopRecording();
} }
resultCode = RESULT_CODE_OK; resultCode = Activity.RESULT_OK;
} else if (API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS.equals(cmd)) { } else if (API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS.equals(cmd)) {
// not implemented yet // not implemented yet