From f85a67beec4b5e7dbfa5f763c8d7d769264ae278 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Wed, 11 Apr 2018 14:30:50 +0300 Subject: [PATCH] Add the ability to undo deletion from saved articles list --- .../fragment_wikivoyage_explore_dialog.xml | 13 ++++++++++--- OsmAnd/res/values/strings.xml | 1 + .../data/WikivoyageLocalDataHelper.java | 8 ++++++++ .../explore/SavedArticlesRvAdapter.java | 16 ++++++++++++++-- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/layout/fragment_wikivoyage_explore_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_explore_dialog.xml index a86d95c526..4aebb85196 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_explore_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_explore_dialog.xml @@ -103,10 +103,17 @@ - + + android:layout_height="wrap_content"> + + + + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 93caea7dd7..5df3842b5d 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Article removed Search: Country, City, Province Read Saved articles diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java index 86b35bdca7..cea8117ebf 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java @@ -109,6 +109,14 @@ public class WikivoyageLocalDataHelper { } } + public void restoreSavedArticle(@NonNull WikivoyageArticle article) { + if (!isArticleSaved(article)) { + savedArticles.add(article); + dbHelper.addSavedArticle(article); + notifySavedUpdated(); + } + } + public void removeArticleFromSaved(@NonNull WikivoyageArticle article) { WikivoyageArticle savedArticle = getArticle(article.cityId, article.lang); if (savedArticle != null) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 4984d2102b..2c1bb0709c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -3,6 +3,7 @@ package net.osmand.plus.wikivoyage.explore; import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.design.widget.Snackbar; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -10,6 +11,7 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -129,7 +131,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter