Bookmarking article without viewing it, adds empty GPX to My Places.
This commit is contained in:
parent
290f3af026
commit
ab605a035b
1 changed files with 12 additions and 11 deletions
|
@ -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,17 +104,15 @@ 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) {
|
GPXFile gpxFile = article.getGpxFile();
|
||||||
GPXUtilities.GPXFile gpxFile = article.getGpxFile();
|
app.getSelectedGpxHelper().selectGpxFile(gpxFile, false, true);
|
||||||
app.getSelectedGpxHelper().selectGpxFile(gpxFile, false, true);
|
helper.removeArticleFromSaved(article);
|
||||||
helper.removeArticleFromSaved(article);
|
} else {
|
||||||
} else {
|
helper.addArticleToSaved(article);
|
||||||
helper.addArticleToSaved(article);
|
app.getTravelHelper().createGpxFile(article);
|
||||||
app.getTravelHelper().createGpxFile(article);
|
|
||||||
}
|
|
||||||
updateSaveButton(holder);
|
|
||||||
}
|
}
|
||||||
|
updateSaveButton(holder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue