diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-02-27 20:15:27 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-02-27 20:15:27 +0100 |
commit | 7c6c3ef1019e93001ee5fca9093ba21443c5cae6 (patch) | |
tree | 1ff10392255ab6d5ea54db5ee30bb6979bfd8166 /src/de/danoeh/antennapod/storage/DBTasks.java | |
parent | bece620c4355363ec3a6b49d58ec1b3ab79c20db (diff) | |
download | AntennaPod-7c6c3ef1019e93001ee5fca9093ba21443c5cae6.zip |
Do not add things to the flattr queue if the user isn't logged in
- Bugfix: The no-token dialog was shown every time a feed was refreshed if the user wasn't logged in and had clicked the "flattr this" button before
Diffstat (limited to 'src/de/danoeh/antennapod/storage/DBTasks.java')
-rw-r--r-- | src/de/danoeh/antennapod/storage/DBTasks.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/de/danoeh/antennapod/storage/DBTasks.java b/src/de/danoeh/antennapod/storage/DBTasks.java index c6a0dad17..8ef5f0888 100644 --- a/src/de/danoeh/antennapod/storage/DBTasks.java +++ b/src/de/danoeh/antennapod/storage/DBTasks.java @@ -17,6 +17,7 @@ import de.danoeh.antennapod.util.NetworkUtils; import de.danoeh.antennapod.util.QueueAccess; import de.danoeh.antennapod.util.comparator.FeedItemPubdateComparator; import de.danoeh.antennapod.util.exception.MediaFileNotFoundException; +import de.danoeh.antennapod.util.flattr.FlattrUtils; import java.util.*; import java.util.concurrent.*; @@ -805,4 +806,34 @@ public final class DBTasks { } } + /** + * Adds the given FeedItem to the flattr queue if the user is logged in. Otherwise, a dialog + * will be opened that lets the user go either to the login screen or the website of the flattr thing. + * @param context + * @param item + */ + public static void flattrItemIfLoggedIn(Context context, FeedItem item) { + if (FlattrUtils.hasToken()) { + item.getFlattrStatus().setFlattrQueue(); + DBWriter.setFlattredStatus(context, item, true); + } else { + FlattrUtils.showNoTokenDialog(context, item.getPaymentLink()); + } + } + + /** + * Adds the given Feed to the flattr queue if the user is logged in. Otherwise, a dialog + * will be opened that lets the user go either to the login screen or the website of the flattr thing. + * @param context + * @param feed + */ + public static void flattrFeedIfLoggedIn(Context context, Feed feed) { + if (FlattrUtils.hasToken()) { + feed.getFlattrStatus().setFlattrQueue(); + DBWriter.setFlattredStatus(context, feed, true); + } else { + FlattrUtils.showNoTokenDialog(context, feed.getPaymentLink()); + } + } + } |