fix calling startActivity() from outside of an Activity

This commit is contained in:
Chumva 2018-05-08 16:48:27 +03:00
parent 0d777ad3d8
commit e75dfc58e8
2 changed files with 7 additions and 3 deletions

View file

@ -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();

View file

@ -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));
}
});
}