now removing items from favorites by swiping

This commit is contained in:
Tom Hennen 2015-09-20 16:31:44 -04:00
parent 05c64eb063
commit 721bfc064a
3 changed files with 9 additions and 8 deletions

View File

@ -13,8 +13,8 @@ import java.util.List;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.event.FavoritesEvent;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.event.QueueEvent;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.util.LongList;
import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken;
import de.danoeh.antennapod.core.util.gui.UndoBarController;
@ -73,14 +73,12 @@ public class FavoriteEpisodesFragment extends AllEpisodesFragment {
}
FeedItem item = (FeedItem) listView.getAdapter().getItem(which);
// TODO: actually remove the item from favorites
DBWriter.removeFavoriteItem(item);
undoBarController.showUndoBar(false,
getString(R.string.removed_from_favorites), new FeedItemUndoToken(item,
getString(R.string.removed_item), new FeedItemUndoToken(item,
which)
);
throw new RuntimeException("can't remove yet");
});
undoBarController = new UndoBarController<FeedItemUndoToken>(root.findViewById(R.id.undobar), new UndoBarController.UndoListener<FeedItemUndoToken>() {
@ -91,8 +89,7 @@ public class FavoriteEpisodesFragment extends AllEpisodesFragment {
public void onUndo(FeedItemUndoToken token) {
if (token != null) {
long itemId = token.getFeedItemId();
// TODO: put it back DBWriter.markItemPlayed(FeedItem.NEW, itemId);
throw new RuntimeException("can't undo remove yet");
DBWriter.addFavoriteItemById(itemId);
}
}

View File

@ -461,6 +461,10 @@ public class DBWriter {
});
}
public static Future<?> addFavoriteItemById(final long itemId) {
return addFavoriteItem(DBReader.getFeedItem(itemId));
}
public static Future<?> removeFavoriteItem(final FeedItem item) {
return dbExec.submit(() -> {
final PodDBAdapter adapter = PodDBAdapter.getInstance().open();

View File

@ -148,7 +148,7 @@
<string name="activate_auto_download">Activate Auto Download</string>
<string name="deactivate_auto_download">Deactivate Auto Download</string>
<string name="reset_position">Reset Playback Position</string>
<string name="removed_from_favorites">Removed from favorites</string>
<string name="removed_item">Item removed</string>
<!-- Download messages and labels -->
<string name="download_successful">successful</string>