Open mapActivity

This commit is contained in:
Dima-1 2021-01-27 10:20:55 +02:00
parent fea90fd37e
commit ea1c439cd1
3 changed files with 18 additions and 8 deletions

View file

@ -177,6 +177,8 @@ public class TravelObfHelper implements TravelHelper {
res.file = file;
String title = amenity.getName("en");
res.title = capitalizeFirstLetter(getGpxTitle(Algorithms.isEmpty(title) ? amenity.getName() : title));
res.lat = amenity.getLocation().getLatitude();
res.lon = amenity.getLocation().getLongitude();
res.routeId = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID));
try {
res.totalDistance = Float.parseFloat(Algorithms.emptyIfNull(amenity.getTagContent(DISTANCE)));
@ -319,6 +321,7 @@ public class TravelObfHelper implements TravelHelper {
gpxFile.tracks = new ArrayList<>();
gpxFile.tracks.add(track);
}
article.gpxFile = gpxFile;
return gpxFile;
}

View file

@ -181,7 +181,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
List<TravelArticle> popularArticles = app.getTravelHelper().getPopularArticles();
for (TravelArticle article : popularArticles) {
if (article instanceof TravelGpx) {
items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, activity.getSupportFragmentManager()));
items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, getActivity()));
} else {
items.add(new ArticleTravelCard(app, nightMode, article, activity.getSupportFragmentManager()));
}

View file

@ -5,13 +5,15 @@ import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.AndroidUtils;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.wikipedia.WikiArticleHelper;
import net.osmand.plus.wikivoyage.data.TravelGpx;
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
@ -22,15 +24,15 @@ public class TravelGpxCard extends BaseTravelCard {
private final TravelGpx article;
private final Drawable readIcon;
private final FragmentManager fragmentManager;
private final FragmentActivity activity;
private boolean isLastItem;
public TravelGpxCard(@NonNull OsmandApplication app, boolean nightMode, @NonNull TravelGpx article,
@NonNull FragmentManager fragmentManager) {
@NonNull FragmentActivity activity) {
super(app, nightMode);
this.article = article;
readIcon = getActiveIcon(R.drawable.ic_action_read_article);
this.fragmentManager = fragmentManager;
this.activity = activity;
}
@Override
@ -49,10 +51,15 @@ public class TravelGpxCard extends BaseTravelCard {
View.OnClickListener readClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (fragmentManager != null) {
// WikivoyageArticleDialogFragment.showInstance(app, fragmentManager,
// article.generateIdentifier(), article.getLang());
if (activity != null) {
app.getTravelHelper().createGpxFile(article);
final OsmandSettings settings = app.getSettings();
settings.setMapLocationToShow(article.getLat(), article.getLon(),
settings.getLastKnownMapZoom(),
null,
false,
article.getGpxFile());
MapActivity.launchMapActivityMoveToTop(activity);
}
}
};