Fix crashes

This commit is contained in:
Victor Shcherb 2018-05-22 23:57:39 +02:00
parent 40b857a6a1
commit ff5b795694
2 changed files with 13 additions and 10 deletions

View file

@ -13,7 +13,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.map.ITileSource; import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager;
@ -230,14 +229,18 @@ public class MapillaryPlugin extends OsmandPlugin {
boolean success = false; boolean success = false;
OsmandApplication app = (OsmandApplication) activity.getApplication(); OsmandApplication app = (OsmandApplication) activity.getApplication();
if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) { if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) {
if (imageKey != null) { try {
Intent intent = new Intent(ACTION_VIEW, Uri.parse(MessageFormat.format("mapillary://mapillary/photo/{0}?image_key={0}", imageKey))); if (imageKey != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Intent intent = new Intent(ACTION_VIEW, Uri.parse(MessageFormat.format("mapillary://mapillary/photo/{0}?image_key={0}", imageKey)));
app.startActivity(intent); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
} else { app.startActivity(intent);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mapillary://mapillary/capture")); } else {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mapillary://mapillary/capture"));
app.startActivity(intent); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent);
}
} catch (ActivityNotFoundException e) {
new MapillaryInstallDialogFragment().show(activity.getSupportFragmentManager(), MapillaryInstallDialogFragment.TAG);
} }
success = true; success = true;
} else { } else {

View file

@ -769,7 +769,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (dialog == null) { if (dialog == null) {
return; return;
} }
if (useMapCenter) { if (useMapCenter && getMapActivity() != null) {
LatLon mapCenter = getMapActivity().getMapView().getCurrentRotatedTileBox().getCenterLatLon(); LatLon mapCenter = getMapActivity().getMapView().getCurrentRotatedTileBox().getCenterLatLon();
SearchSettings ss = searchUICore.getSearchSettings().setOriginalLocation( SearchSettings ss = searchUICore.getSearchSettings().setOriginalLocation(
new LatLon(mapCenter.getLatitude(), mapCenter.getLongitude())); new LatLon(mapCenter.getLatitude(), mapCenter.getLongitude()));