From e75dfc58e84fc87576aceb7ceef00332464087ca Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 8 May 2018 16:48:27 +0300 Subject: [PATCH] fix calling startActivity() from outside of an Activity --- .../plus/wikivoyage/explore/ExploreTabFragment.java | 2 +- .../explore/travelcards/StartEditingTravelCard.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 87ade48c39..12c0507a75 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -133,7 +133,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn } } } - items.add(new StartEditingTravelCard(app, nightMode)); + items.add(new StartEditingTravelCard(app, getContext(), nightMode)); adapter.setItems(items); final DownloadIndexesThread downloadThread = app.getDownloadThread(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/StartEditingTravelCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/StartEditingTravelCard.java index 7b57c7a51a..ca742c8d71 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/StartEditingTravelCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/StartEditingTravelCard.java @@ -1,5 +1,6 @@ package net.osmand.plus.wikivoyage.explore.travelcards; +import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.support.customtabs.CustomTabsIntent; @@ -16,8 +17,11 @@ public class StartEditingTravelCard extends BaseTravelCard { public static final int TYPE = 1; - public StartEditingTravelCard(OsmandApplication app, boolean nightMode) { + private Context context; + + public StartEditingTravelCard(OsmandApplication app, Context context, boolean nightMode) { super(app, nightMode); + this.context = context; } @Override @@ -35,7 +39,7 @@ public class StartEditingTravelCard extends BaseTravelCard { .setToolbarColor(ContextCompat.getColor(app, nightMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color)) .build(); String text = "https://" + app.getLanguage().toLowerCase() + ".m.wikivoyage.org"; - customTabsIntent.launchUrl(app, Uri.parse(text)); + customTabsIntent.launchUrl(context, Uri.parse(text)); } }); }