Bookmarking article without viewing it, adds empty GPX to My Places.

This commit is contained in:
androiddevkotlin 2021-04-12 19:22:55 +03:00
parent 290f3af026
commit ab605a035b

View file

@ -13,7 +13,6 @@ import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator; import com.squareup.picasso.RequestCreator;
import net.osmand.GPXUtilities;
import net.osmand.PicassoUtils; import net.osmand.PicassoUtils;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -24,6 +23,8 @@ import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelArticle;
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
import static net.osmand.GPXUtilities.GPXFile;
public class ArticleTravelCard extends BaseTravelCard { public class ArticleTravelCard extends BaseTravelCard {
public static final int TYPE = 2; public static final int TYPE = 2;
@ -93,6 +94,8 @@ public class ArticleTravelCard extends BaseTravelCard {
private void updateSaveButton(final ArticleTravelVH holder) { private void updateSaveButton(final ArticleTravelVH holder) {
if (article != null) { if (article != null) {
article = app.getTravelHelper().getArticleById(article.generateIdentifier(), article.getLang(), true,
null);
final TravelLocalDataHelper helper = app.getTravelHelper().getBookmarksHelper(); final TravelLocalDataHelper helper = app.getTravelHelper().getBookmarksHelper();
final boolean saved = helper.isArticleSaved(article); final boolean saved = helper.isArticleSaved(article);
Drawable icon = getActiveIcon(saved ? R.drawable.ic_action_read_later_fill : R.drawable.ic_action_read_later); Drawable icon = getActiveIcon(saved ? R.drawable.ic_action_read_later_fill : R.drawable.ic_action_read_later);
@ -101,9 +104,8 @@ public class ArticleTravelCard extends BaseTravelCard {
holder.rightButton.setOnClickListener(new View.OnClickListener() { holder.rightButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (article != null) {
if (saved) { if (saved) {
GPXUtilities.GPXFile gpxFile = article.getGpxFile(); GPXFile gpxFile = article.getGpxFile();
app.getSelectedGpxHelper().selectGpxFile(gpxFile, false, true); app.getSelectedGpxHelper().selectGpxFile(gpxFile, false, true);
helper.removeArticleFromSaved(article); helper.removeArticleFromSaved(article);
} else { } else {
@ -112,7 +114,6 @@ public class ArticleTravelCard extends BaseTravelCard {
} }
updateSaveButton(holder); updateSaveButton(holder);
} }
}
}); });
} }
} }