diff options
author | Tom Hennen <tom.hennen@gmail.com> | 2015-04-03 10:47:01 -0400 |
---|---|---|
committer | Tom Hennen <tom.hennen@gmail.com> | 2015-04-03 10:47:01 -0400 |
commit | c277166f77351bdeda7c2dc10db21df420fb2987 (patch) | |
tree | 676e7bfd60d1104f4ec59aacb805f041eaba8055 /app/src/main/java/de/danoeh | |
parent | b8d25d412312d2acff6d266655e8ab179896e9a0 (diff) | |
download | AntennaPod-c277166f77351bdeda7c2dc10db21df420fb2987.zip |
Can now undo swipe to mark as read.
Behavior isn't ideal when the user is displaying all the items in their feed.
(you can swipe new and read items and they don't go away (obviously)).
Diffstat (limited to 'app/src/main/java/de/danoeh')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java index e96c428fe..715222295 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java @@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; +import android.os.Parcelable; import android.support.v4.app.Fragment; import android.support.v7.widget.SearchView; import android.util.Log; @@ -45,6 +46,7 @@ import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.QueueAccess; import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken; +import de.danoeh.antennapod.core.util.gui.UndoBarController; import de.danoeh.antennapod.menuhandler.MenuItemUtils; import de.danoeh.antennapod.menuhandler.NavDrawerActivity; @@ -68,6 +70,8 @@ public class NewEpisodesFragment extends Fragment { private TextView txtvEmpty; private ProgressBar progLoading; + private UndoBarController undoBarController; + private List<FeedItem> unreadItems; private List<FeedItem> recentItems; private QueueAccess queueAccess; @@ -135,6 +139,7 @@ public class NewEpisodesFragment extends Fragment { listAdapter = null; activity.set(null); viewsCreated = false; + undoBarController = null; if (downloadObserver != null) { downloadObserver.onPause(); } @@ -262,6 +267,10 @@ public class NewEpisodesFragment extends Fragment { stopItemLoader(); FeedItem item = (FeedItem) listView.getAdapter().getItem(which); DBWriter.markItemRead(getActivity(), item.getId(), true); + undoBarController.showUndoBar(false, + getString(R.string.marked_as_read_label), new FeedItemUndoToken(item, + which) + ); // TODO: provide undo? /* undoBarController.showUndoBar(false, @@ -272,6 +281,19 @@ public class NewEpisodesFragment extends Fragment { } }); + undoBarController = new UndoBarController(root.findViewById(R.id.undobar), new UndoBarController.UndoListener() { + @Override + public void onUndo(Parcelable token) { + // Perform the undo + FeedItemUndoToken undoToken = (FeedItemUndoToken) token; + if (token != null) { + long itemId = undoToken.getFeedItemId(); + int position = undoToken.getPosition(); + DBWriter.markItemRead(getActivity(), itemId, false); + } + } + }); + final int secondColor = (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) ? R.color.swipe_refresh_secondary_color_dark : R.color.swipe_refresh_secondary_color_light; if (!itemsLoaded) { |