Make new explicit
This commit is contained in:
parent
cff363e474
commit
5178de8681
|
@ -2,15 +2,9 @@ package de.test.antennapod.handler;
|
|||
|
||||
import android.content.Context;
|
||||
import android.test.InstrumentationTestCase;
|
||||
import de.danoeh.antennapod.core.feed.*;
|
||||
import de.danoeh.antennapod.core.syndication.handler.FeedHandler;
|
||||
import de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException;
|
||||
import de.test.antennapod.util.syndication.feedgenerator.AtomGenerator;
|
||||
import de.test.antennapod.util.syndication.feedgenerator.FeedGenerator;
|
||||
import de.test.antennapod.util.syndication.feedgenerator.RSS2Generator;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -19,6 +13,19 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.Chapter;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedImage;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.syndication.handler.FeedHandler;
|
||||
import de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException;
|
||||
import de.test.antennapod.util.syndication.feedgenerator.AtomGenerator;
|
||||
import de.test.antennapod.util.syndication.feedgenerator.FeedGenerator;
|
||||
import de.test.antennapod.util.syndication.feedgenerator.RSS2Generator;
|
||||
|
||||
/**
|
||||
* Tests for FeedHandler
|
||||
*/
|
||||
|
@ -162,7 +169,7 @@ public class FeedHandlerTest extends InstrumentationTestCase {
|
|||
|
||||
for (int i = 0; i < numItems; i++) {
|
||||
FeedItem item = new FeedItem(0, "item-" + i, "http://example.com/item-" + i,
|
||||
"http://example.com/items/" + i, new Date(i*60000), false, feed);
|
||||
"http://example.com/items/" + i, new Date(i*60000), FeedItem.UNPLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
if (withFeedMedia) {
|
||||
item.setMedia(new FeedMedia(0, item, 4711, 0, 100, "audio/mp3", null, "http://example.com/media-" + i,
|
||||
|
|
|
@ -3,15 +3,9 @@ package de.test.antennapod.service.playback;
|
|||
import android.content.Context;
|
||||
import android.media.RemoteControlClient;
|
||||
import android.test.InstrumentationTestCase;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackServiceMediaPlayer;
|
||||
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.test.antennapod.util.service.download.HTTPBin;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -23,6 +17,15 @@ import java.util.Date;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackServiceMediaPlayer;
|
||||
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.test.antennapod.util.service.download.HTTPBin;
|
||||
|
||||
/**
|
||||
* Test class for PlaybackServiceMediaPlayer
|
||||
*/
|
||||
|
@ -114,7 +117,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
|
|||
final Context c = getInstrumentation().getTargetContext();
|
||||
Feed f = new Feed(0, new Date(), "f", "l", "d", null, null, null, null, "i", null, null, "l", false);
|
||||
f.setItems(new ArrayList<FeedItem>());
|
||||
FeedItem i = new FeedItem(0, "t", "i", "l", new Date(), false, f);
|
||||
FeedItem i = new FeedItem(0, "t", "i", "l", new Date(), FeedItem.UNPLAYED, f);
|
||||
f.getItems().add(i);
|
||||
FeedMedia media = new FeedMedia(0, i, 0, 0, 0, "audio/wav", fileUrl, downloadUrl, fileUrl != null, null, 0);
|
||||
i.setMedia(media);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class PlaybackServiceTaskManagerTest extends InstrumentationTestCase {
|
|||
Feed f = new Feed(0, new Date(), "title", "link", "d", null, null, null, null, "id", null, "null", "url", false);
|
||||
f.setItems(new ArrayList<FeedItem>());
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
f.getItems().add(new FeedItem(0, pref + i, pref + i, "link", new Date(), true, f));
|
||||
f.getItems().add(new FeedItem(0, pref + i, pref + i, "link", new Date(), FeedItem.PLAYED, f));
|
||||
}
|
||||
PodDBAdapter adapter = new PodDBAdapter(c);
|
||||
adapter.open();
|
||||
|
|
|
@ -277,7 +277,7 @@ public class DBReaderTest extends InstrumentationTestCase {
|
|||
int i = random.nextInt(numItems);
|
||||
if (!unread.contains(items.get(i))) {
|
||||
FeedItem item = items.get(i);
|
||||
item.setRead(false);
|
||||
item.setPlayed(false);
|
||||
unread.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ public class DBReaderTest extends InstrumentationTestCase {
|
|||
assertNotNull(unreadSaved);
|
||||
assertTrue(unread.size() == unreadSaved.size());
|
||||
for (FeedItem item : unreadSaved) {
|
||||
assertFalse(item.isRead());
|
||||
assertFalse(item.isPlayed());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ public class DBReaderTest extends InstrumentationTestCase {
|
|||
adapter.open();
|
||||
for (int i = 0; i < NUM_UNREAD; i++) {
|
||||
FeedItem item = feeds.get(0).getItems().get(i);
|
||||
item.setRead(false);
|
||||
item.setPlayed(false);
|
||||
adapter.setSingleFeedItem(item);
|
||||
}
|
||||
List<FeedItem> queue = new ArrayList<FeedItem>();
|
||||
|
|
|
@ -78,7 +78,7 @@ public class DBTasksTest extends InstrumentationTestCase {
|
|||
feed.setItems(items);
|
||||
List<File> files = new ArrayList<File>();
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
|
||||
|
||||
File f = new File(destFolder, "file " + i);
|
||||
assertTrue(f.createNewFile());
|
||||
|
@ -116,7 +116,7 @@ public class DBTasksTest extends InstrumentationTestCase {
|
|||
feed.setItems(items);
|
||||
List<File> files = new ArrayList<File>();
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), false, feed);
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.UNPLAYED, feed);
|
||||
|
||||
File f = new File(destFolder, "file " + i);
|
||||
assertTrue(f.createNewFile());
|
||||
|
@ -151,7 +151,7 @@ public class DBTasksTest extends InstrumentationTestCase {
|
|||
feed.setItems(items);
|
||||
List<File> files = new ArrayList<File>();
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
|
||||
|
||||
File f = new File(destFolder, "file " + i);
|
||||
assertTrue(f.createNewFile());
|
||||
|
@ -208,14 +208,14 @@ public class DBTasksTest extends InstrumentationTestCase {
|
|||
Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
feed.getItems().add(new FeedItem(0, "item " + i, "id " + i, "link " + i, new Date(), false, feed));
|
||||
feed.getItems().add(new FeedItem(0, "item " + i, "id " + i, "link " + i, new Date(), FeedItem.UNPLAYED, feed));
|
||||
}
|
||||
Feed newFeed = DBTasks.updateFeed(context, feed)[0];
|
||||
|
||||
assertTrue(newFeed == feed);
|
||||
assertTrue(feed.getId() != 0);
|
||||
for (FeedItem item : feed.getItems()) {
|
||||
assertFalse(item.isRead());
|
||||
assertFalse(item.isPlayed());
|
||||
assertTrue(item.getId() != 0);
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ public class DBTasksTest extends InstrumentationTestCase {
|
|||
final Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
for (int i = 0; i < NUM_ITEMS_OLD; i++) {
|
||||
feed.getItems().add(new FeedItem(0, "item " + i, "id " + i, "link " + i, new Date(i), true, feed));
|
||||
feed.getItems().add(new FeedItem(0, "item " + i, "id " + i, "link " + i, new Date(i), FeedItem.PLAYED, feed));
|
||||
}
|
||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
adapter.open();
|
||||
|
@ -261,7 +261,7 @@ public class DBTasksTest extends InstrumentationTestCase {
|
|||
}
|
||||
|
||||
for (int i = NUM_ITEMS_OLD; i < NUM_ITEMS_NEW + NUM_ITEMS_OLD; i++) {
|
||||
feed.getItems().add(0, new FeedItem(0, "item " + i, "id " + i, "link " + i, new Date(i), true, feed));
|
||||
feed.getItems().add(0, new FeedItem(0, "item " + i, "id " + i, "link " + i, new Date(i), FeedItem.PLAYED, feed));
|
||||
}
|
||||
|
||||
final Feed newFeed = DBTasks.updateFeed(context, feed)[0];
|
||||
|
@ -285,7 +285,7 @@ public class DBTasksTest extends InstrumentationTestCase {
|
|||
FeedItem item = newFeed.getItems().get(i);
|
||||
assertTrue(item.getFeed() == newFeed);
|
||||
assertTrue(item.getId() == itemIDs.get(i));
|
||||
assertTrue(item.isRead());
|
||||
assertTrue(item.isPlayed());
|
||||
assertTrue(item.getPubDate().getTime() >= lastDate.getTime());
|
||||
lastDate = item.getPubDate();
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ public class DBTasksTest extends InstrumentationTestCase {
|
|||
FeedItem item = newFeed.getItems().get(i);
|
||||
assertTrue(item.getFeed() == newFeed);
|
||||
assertTrue(item.getId() != 0);
|
||||
assertFalse(item.isRead());
|
||||
assertFalse(item.isPlayed());
|
||||
assertTrue(item.getPubDate().getTime() >= lastDate.getTime());
|
||||
lastDate = item.getPubDate();
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class DBTestUtils {
|
|||
f.setItems(new ArrayList<FeedItem>());
|
||||
for (int j = 0; j < numItems; j++) {
|
||||
FeedItem item = new FeedItem(0, "item " + j, "id" + j, "link" + j, new Date(),
|
||||
true, f, withChapters);
|
||||
FeedItem.PLAYED, f, withChapters);
|
||||
if (withMedia) {
|
||||
FeedMedia media = new FeedMedia(item, "url" + j, 1, "audio/mp3");
|
||||
item.setMedia(media);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
Feed feed = new Feed("url", new Date(), "title");
|
||||
List<FeedItem> items = new ArrayList<FeedItem>();
|
||||
feed.setItems(items);
|
||||
FeedItem item = new FeedItem(0, "Item", "Item", "url", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "Item", "Item", "url", new Date(), FeedItem.PLAYED, feed);
|
||||
|
||||
FeedMedia media = new FeedMedia(0, item, 1, 1, 1, "mime_type", dest.getAbsolutePath(), "download_url", true, null, 0);
|
||||
item.setMedia(media);
|
||||
|
@ -104,7 +104,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
List<File> itemFiles = new ArrayList<File>();
|
||||
// create items with downloaded media files
|
||||
for (int i = 0; i < 10; i++) {
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), true, feed, true);
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), FeedItem.PLAYED, feed, true);
|
||||
feed.getItems().add(item);
|
||||
|
||||
File enc = new File(destFolder, "file " + i);
|
||||
|
@ -171,7 +171,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
List<File> itemFiles = new ArrayList<File>();
|
||||
// create items with downloaded media files
|
||||
for (int i = 0; i < 10; i++) {
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
|
||||
File enc = new File(destFolder, "file " + i);
|
||||
|
@ -268,7 +268,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
|
||||
// create items
|
||||
for (int i = 0; i < 10; i++) {
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
|
||||
// create items with images
|
||||
for (int i = 0; i < 10; i++) {
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
File itemImageFile = new File(destFolder, "item-image-" + i);
|
||||
FeedImage itemImage = new FeedImage(0, "item-image" + i, itemImageFile.getAbsolutePath(), "url", true);
|
||||
|
@ -378,7 +378,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
List<File> itemFiles = new ArrayList<File>();
|
||||
// create items with downloaded media files
|
||||
for (int i = 0; i < 10; i++) {
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
|
||||
File enc = new File(destFolder, "file " + i);
|
||||
|
@ -450,7 +450,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
List<File> itemFiles = new ArrayList<File>();
|
||||
// create items with downloaded media files
|
||||
for (int i = 0; i < 10; i++) {
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
|
||||
File enc = new File(destFolder, "file " + i);
|
||||
|
@ -496,7 +496,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
final Context context = getInstrumentation().getTargetContext();
|
||||
Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
|
||||
FeedMedia media = new FeedMedia(0, item, 10, 0, 1, "mime", null, "url", false, playbackCompletionDate, 0);
|
||||
feed.getItems().add(item);
|
||||
item.setMedia(media);
|
||||
|
@ -543,7 +543,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
}
|
||||
|
||||
|
@ -569,7 +569,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
final Context context = getInstrumentation().getTargetContext();
|
||||
Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
|
||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
|
@ -593,7 +593,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
final Context context = getInstrumentation().getTargetContext();
|
||||
Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
|
||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
|
@ -661,7 +661,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
}
|
||||
|
||||
|
@ -707,7 +707,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), FeedItem.PLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
}
|
||||
|
||||
|
@ -754,7 +754,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), false, feed);
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), FeedItem.UNPLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
}
|
||||
|
||||
|
@ -771,7 +771,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
DBWriter.markFeedRead(context, feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
List<FeedItem> loadedItems = DBReader.getFeedItemList(context, feed);
|
||||
for (FeedItem item : loadedItems) {
|
||||
assertTrue(item.isRead());
|
||||
assertTrue(item.isPlayed());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -781,7 +781,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
Feed feed = new Feed("url", new Date(), "title");
|
||||
feed.setItems(new ArrayList<FeedItem>());
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), false, feed);
|
||||
FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), FeedItem.UNPLAYED, feed);
|
||||
feed.getItems().add(item);
|
||||
}
|
||||
|
||||
|
@ -798,7 +798,7 @@ public class DBWriterTest extends InstrumentationTestCase {
|
|||
DBWriter.markAllItemsRead(context).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
List<FeedItem> loadedItems = DBReader.getFeedItemList(context, feed);
|
||||
for (FeedItem item : loadedItems) {
|
||||
assertTrue(item.isRead());
|
||||
assertTrue(item.isPlayed());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ public class UITestUtils {
|
|||
List<FeedItem> items = new ArrayList<FeedItem>();
|
||||
for (int j = 0; j < NUM_ITEMS_PER_FEED; j++) {
|
||||
FeedItem item = new FeedItem(j, "Feed " + (i+1) + ": Item " + (j+1), "item" + j,
|
||||
"http://example.com/feed" + i + "/item/" + j, new Date(), false, feed);
|
||||
"http://example.com/feed" + i + "/item/" + j, new Date(), FeedItem.UNPLAYED, feed);
|
||||
items.add(item);
|
||||
|
||||
File mediaFile = newMediaFile("feed-" + i + "-episode-" + j + ".mp3");
|
||||
|
|
|
@ -31,7 +31,7 @@ public class TimelineTest extends InstrumentationTestCase {
|
|||
}
|
||||
|
||||
private Playable newTestPlayable(List<Chapter> chapters, String shownotes) {
|
||||
FeedItem item = new FeedItem(0, "Item", "item-id", "http://example.com/item", new Date(), true, null);
|
||||
FeedItem item = new FeedItem(0, "Item", "item-id", "http://example.com/item", new Date(), FeedItem.PLAYED, null);
|
||||
item.setChapters(chapters);
|
||||
item.setContentEncoded(shownotes);
|
||||
FeedMedia media = new FeedMedia(item, "http://example.com/episode", 100, "audio/mp3");
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ActionButtonUtils {
|
|||
butSecondary.setContentDescription(context.getString(labels[0]));
|
||||
}
|
||||
} else {
|
||||
if (item.isRead()) {
|
||||
if (item.isPlayed()) {
|
||||
butSecondary.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
butSecondary.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -91,7 +91,7 @@ public class AllEpisodesListAdapter extends BaseAdapter {
|
|||
|
||||
holder.title.setText(item.getTitle());
|
||||
holder.pubDate.setText(DateUtils.formatDateTime(context, item.getPubDate().getTime(), DateUtils.FORMAT_ABBREV_ALL));
|
||||
if (showOnlyNewEpisodes || item.isRead() || false == itemAccess.isNew(item)) {
|
||||
if (showOnlyNewEpisodes || false == item.isNew()) {
|
||||
holder.statusUnread.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
holder.statusUnread.setVisibility(View.VISIBLE);
|
||||
|
@ -179,7 +179,5 @@ public class AllEpisodesListAdapter extends BaseAdapter {
|
|||
|
||||
boolean isInQueue(FeedItem item);
|
||||
|
||||
boolean isNew(FeedItem item);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class DefaultActionButtonCallback implements ActionButtonCallback {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (!item.isRead()) {
|
||||
if (!item.isPlayed()) {
|
||||
DBWriter.markItemRead(context, item, true, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,12 +112,12 @@ public class FeedItemlistAdapter extends BaseAdapter {
|
|||
}
|
||||
holder.title.setText(buffer.toString());
|
||||
|
||||
if(false == item.isRead() && itemAccess.isNew(item)) {
|
||||
if(item.isNew()) {
|
||||
holder.statusUnread.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.statusUnread.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if(item.isRead()) {
|
||||
if(item.isPlayed()) {
|
||||
ViewHelper.setAlpha(convertView, 0.5f);
|
||||
} else {
|
||||
ViewHelper.setAlpha(convertView, 1.0f);
|
||||
|
@ -221,8 +221,6 @@ public class FeedItemlistAdapter extends BaseAdapter {
|
|||
|
||||
FeedItem getItem(int position);
|
||||
|
||||
boolean isNew(FeedItem item);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,13 +8,14 @@ import android.media.MediaMetadataRetriever;
|
|||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.StorageCallbacks;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
|
||||
public class StorageCallbacksImpl implements StorageCallbacks {
|
||||
|
||||
@Override
|
||||
public int getDatabaseVersion() {
|
||||
return 16;
|
||||
return 17;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -181,5 +182,25 @@ public class StorageCallbacksImpl implements StorageCallbacks {
|
|||
}
|
||||
c.close();
|
||||
}
|
||||
if(oldVersion <= 17) {
|
||||
String selectNew = "SELECT " + PodDBAdapter.TABLE_NAME_FEED_ITEMS + "." + PodDBAdapter.KEY_ID
|
||||
+ " FROM " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
|
||||
+ " INNER JOIN " + PodDBAdapter.TABLE_NAME_FEED_MEDIA + " ON "
|
||||
+ PodDBAdapter.TABLE_NAME_FEED_ITEMS + "." + PodDBAdapter.KEY_ID + "="
|
||||
+ PodDBAdapter.TABLE_NAME_FEED_MEDIA + "." + PodDBAdapter.KEY_FEEDITEM
|
||||
+ " LEFT OUTER JOIN " + PodDBAdapter.TABLE_NAME_QUEUE + " ON "
|
||||
+ PodDBAdapter.TABLE_NAME_FEED_ITEMS + "." + PodDBAdapter.KEY_ID + "="
|
||||
+ PodDBAdapter.TABLE_NAME_QUEUE + "." + PodDBAdapter.KEY_FEEDITEM
|
||||
+ " WHERE "
|
||||
+ PodDBAdapter.TABLE_NAME_FEED_ITEMS + "." + PodDBAdapter.KEY_READ + " = 0 AND " // unplayed
|
||||
+ PodDBAdapter.TABLE_NAME_FEED_MEDIA + "." + PodDBAdapter.KEY_DOWNLOADED + " = 0 AND " // undownloaded
|
||||
+ PodDBAdapter.TABLE_NAME_FEED_MEDIA + "." + PodDBAdapter.KEY_POSITION + " = 0 AND " // not partially played
|
||||
+ PodDBAdapter.TABLE_NAME_QUEUE + "." + PodDBAdapter.KEY_ID + " IS NULL"; // not in queue
|
||||
String sql = "UPDATE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
|
||||
+ " SET " + PodDBAdapter.KEY_READ + "=" + FeedItem.NEW
|
||||
+ " WHERE " + PodDBAdapter.KEY_ID + " IN (" + selectNew + ")";
|
||||
Log.d("Migration", "SQL: " + sql);
|
||||
db.execSQL(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ public class AllEpisodesFragment extends Fragment {
|
|||
|
||||
private List<FeedItem> episodes;
|
||||
private LongList queuedItemsIds;
|
||||
private LongList newItemsIds;
|
||||
private List<Downloader> downloaderList;
|
||||
|
||||
private boolean itemsLoaded = false;
|
||||
|
@ -432,18 +431,6 @@ public class AllEpisodesFragment extends Fragment {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(FeedItem item) {
|
||||
if (itemsLoaded) {
|
||||
// should actually never be called in NewEpisodesFragment, but better safe than sorry
|
||||
return showOnlyNewEpisodes || newItemsIds.contains(item.getId());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
@ -508,8 +495,7 @@ public class AllEpisodesFragment extends Fragment {
|
|||
} else {
|
||||
return new Object[]{
|
||||
DBReader.getRecentlyPublishedEpisodes(context, RECENT_EPISODES_LIMIT),
|
||||
DBReader.getQueueIDList(context),
|
||||
DBReader.getNewItemIds(context)
|
||||
DBReader.getQueueIDList(context)
|
||||
};
|
||||
}
|
||||
} else {
|
||||
|
@ -526,7 +512,6 @@ public class AllEpisodesFragment extends Fragment {
|
|||
if (lists != null) {
|
||||
episodes = (List<FeedItem>) lists[0];
|
||||
queuedItemsIds = (LongList) lists[1];
|
||||
newItemsIds = (LongList) lists[2];
|
||||
itemsLoaded = true;
|
||||
if (viewsCreated && activity.get() != null) {
|
||||
onFragmentLoaded();
|
||||
|
|
|
@ -355,7 +355,7 @@ public class ItemFragment extends Fragment implements LoaderManager.LoaderCallba
|
|||
TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.navigation_accept,
|
||||
R.attr.location_web_site});
|
||||
|
||||
if (!item.isRead()) {
|
||||
if (!item.isPlayed()) {
|
||||
butAction1.setCompoundDrawablesWithIntrinsicBounds(drawables.getDrawable(0), null, null, null);
|
||||
butAction1.setText(getActivity().getString(R.string.mark_read_label));
|
||||
butAction1.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -92,8 +92,6 @@ public class ItemlistFragment extends ListFragment {
|
|||
private long feedID;
|
||||
private Feed feed;
|
||||
private LongList queuedItemsIds;
|
||||
private LongList newItemsIds;
|
||||
|
||||
|
||||
private boolean itemsLoaded = false;
|
||||
private boolean viewsCreated = false;
|
||||
|
@ -579,11 +577,6 @@ public class ItemlistFragment extends ListFragment {
|
|||
return (queuedItemsIds != null) && queuedItemsIds.contains(item.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(FeedItem item) {
|
||||
return (newItemsIds != null) && newItemsIds.contains(item.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemDownloadProgressPercent(FeedItem item) {
|
||||
if (downloaderList != null) {
|
||||
|
@ -626,8 +619,7 @@ public class ItemlistFragment extends ListFragment {
|
|||
feed.setItems(filter.filter(context, feed.getItems()));
|
||||
}
|
||||
LongList queuedItemsIds = DBReader.getQueueIDList(context);
|
||||
LongList newItemsIds = DBReader.getNewItemIds(context);
|
||||
return new Object[] { feed, queuedItemsIds, newItemsIds };
|
||||
return new Object[] { feed, queuedItemsIds };
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -639,7 +631,6 @@ public class ItemlistFragment extends ListFragment {
|
|||
if (res != null) {
|
||||
feed = (Feed) res[0];
|
||||
queuedItemsIds = (LongList) res[1];
|
||||
newItemsIds = res[2] == null ? null : (LongList) res[2];
|
||||
itemsLoaded = true;
|
||||
if (viewsCreated) {
|
||||
onFragmentLoaded();
|
||||
|
|
|
@ -218,11 +218,6 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
return (queue != null) ? queue.contains(item.getId()) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(FeedItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemDownloadProgressPercent(FeedItem item) {
|
||||
if (downloaderList != null) {
|
||||
|
|
|
@ -154,7 +154,7 @@ public class FeedItemMenuHandler {
|
|||
DBWriter.deleteFeedMediaOfItem(context, selectedItem.getMedia().getId());
|
||||
break;
|
||||
case R.id.mark_read_item:
|
||||
selectedItem.setRead(true);
|
||||
selectedItem.setPlayed(true);
|
||||
DBWriter.markItemRead(context, selectedItem, true, false);
|
||||
if(GpodnetPreferences.loggedIn()) {
|
||||
FeedMedia media = selectedItem.getMedia();
|
||||
|
@ -172,7 +172,7 @@ public class FeedItemMenuHandler {
|
|||
}
|
||||
break;
|
||||
case R.id.mark_unread_item:
|
||||
selectedItem.setRead(false);
|
||||
selectedItem.setPlayed(false);
|
||||
DBWriter.markItemRead(context, selectedItem, false, false);
|
||||
if(GpodnetPreferences.loggedIn()) {
|
||||
GpodnetEpisodeAction actionNew = new GpodnetEpisodeAction.Builder(selectedItem, Action.NEW)
|
||||
|
|
|
@ -44,7 +44,11 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
|
|||
private Feed feed;
|
||||
private long feedId;
|
||||
|
||||
private boolean read;
|
||||
private int state;
|
||||
public final static int NEW = -1;
|
||||
public final static int UNPLAYED = 0;
|
||||
public final static int PLAYED = 1;
|
||||
|
||||
private String paymentLink;
|
||||
private FlattrStatus flattrStatus;
|
||||
|
||||
|
@ -66,7 +70,7 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
|
|||
private boolean autoDownload = true;
|
||||
|
||||
public FeedItem() {
|
||||
this.read = true;
|
||||
this.state = UNPLAYED;
|
||||
this.flattrStatus = new FlattrStatus();
|
||||
this.hasChapters = false;
|
||||
}
|
||||
|
@ -75,7 +79,7 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
|
|||
* This constructor is used by DBReader.
|
||||
* */
|
||||
public FeedItem(long id, String title, String link, Date pubDate, String paymentLink, long feedId,
|
||||
FlattrStatus flattrStatus, boolean hasChapters, FeedImage image, boolean read,
|
||||
FlattrStatus flattrStatus, boolean hasChapters, FeedImage image, int state,
|
||||
String itemIdentifier, boolean autoDownload) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
|
@ -86,7 +90,7 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
|
|||
this.flattrStatus = flattrStatus;
|
||||
this.hasChapters = hasChapters;
|
||||
this.image = image;
|
||||
this.read = read;
|
||||
this.state = state;
|
||||
this.itemIdentifier = itemIdentifier;
|
||||
this.autoDownload = autoDownload;
|
||||
}
|
||||
|
@ -94,13 +98,13 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
|
|||
/**
|
||||
* This constructor should be used for creating test objects.
|
||||
*/
|
||||
public FeedItem(long id, String title, String itemIdentifier, String link, Date pubDate, boolean read, Feed feed) {
|
||||
public FeedItem(long id, String title, String itemIdentifier, String link, Date pubDate, int state, Feed feed) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.itemIdentifier = itemIdentifier;
|
||||
this.link = link;
|
||||
this.pubDate = (pubDate != null) ? (Date) pubDate.clone() : null;
|
||||
this.read = read;
|
||||
this.state = state;
|
||||
this.feed = feed;
|
||||
this.flattrStatus = new FlattrStatus();
|
||||
this.hasChapters = false;
|
||||
|
@ -109,13 +113,13 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
|
|||
/**
|
||||
* This constructor should be used for creating test objects involving chapter marks.
|
||||
*/
|
||||
public FeedItem(long id, String title, String itemIdentifier, String link, Date pubDate, boolean read, Feed feed, boolean hasChapters) {
|
||||
public FeedItem(long id, String title, String itemIdentifier, String link, Date pubDate, int read, Feed feed, boolean hasChapters) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.itemIdentifier = itemIdentifier;
|
||||
this.link = link;
|
||||
this.pubDate = (pubDate != null) ? (Date) pubDate.clone() : null;
|
||||
this.read = read;
|
||||
this.state = state;
|
||||
this.feed = feed;
|
||||
this.flattrStatus = new FlattrStatus();
|
||||
this.hasChapters = hasChapters;
|
||||
|
@ -238,12 +242,25 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
|
|||
this.feed = feed;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
public boolean isNew() {
|
||||
return state == NEW;
|
||||
}
|
||||
|
||||
public void setRead(boolean read) {
|
||||
this.read = read;
|
||||
|
||||
public void setNew() {
|
||||
state = NEW;
|
||||
}
|
||||
|
||||
public boolean isPlayed() {
|
||||
return state == PLAYED;
|
||||
}
|
||||
|
||||
public void setPlayed(boolean played) {
|
||||
if(played) {
|
||||
state = PLAYED;
|
||||
} else {
|
||||
state = UNPLAYED;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInProgress() {
|
||||
|
@ -342,7 +359,7 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
|
|||
return State.IN_PROGRESS;
|
||||
}
|
||||
}
|
||||
return (isRead() ? State.READ : State.UNREAD);
|
||||
return (isPlayed() ? State.READ : State.UNREAD);
|
||||
}
|
||||
|
||||
public long getFeedId() {
|
||||
|
|
|
@ -61,9 +61,9 @@ public class FeedItemFilter {
|
|||
}
|
||||
List<FeedItem> result = new ArrayList<FeedItem>();
|
||||
for(FeedItem item : items) {
|
||||
if(hideUnplayed && false == item.isRead()) continue;
|
||||
if(hideUnplayed && false == item.isPlayed()) continue;
|
||||
if(hidePaused && item.getState() == FeedItem.State.IN_PROGRESS) continue;
|
||||
if(hidePlayed && item.isRead()) continue;
|
||||
if(hidePlayed && item.isPlayed()) continue;
|
||||
boolean isQueued = DBReader.getQueueIDList(context).contains(item.getId());
|
||||
if(hideQueued && isQueued) continue;
|
||||
if(hideNotQueued && false == isQueued) continue;
|
||||
|
|
|
@ -186,6 +186,9 @@ public class FeedMedia extends FeedFile implements Playable {
|
|||
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
if(position > 0) {
|
||||
this.item.setPlayed(false);
|
||||
}
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
|
@ -447,6 +450,9 @@ public class FeedMedia extends FeedFile implements Playable {
|
|||
@Override
|
||||
public void setDownloaded(boolean downloaded) {
|
||||
super.setDownloaded(downloaded);
|
||||
if(downloaded) {
|
||||
item.setPlayed(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -815,7 +815,7 @@ public class DownloadService extends Service {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!item.isRead() && item.hasMedia() && !item.getMedia().isDownloaded()) {
|
||||
if (!item.isPlayed() && item.hasMedia() && !item.getMedia().isDownloaded()) {
|
||||
newMediaFiles.add(item.getMedia().getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class APCleanupAlgorithm implements EpisodeCleanupAlgorithm<Integer> {
|
|||
List<FeedItem> delete;
|
||||
for (FeedItem item : downloadedItems) {
|
||||
if (item.hasMedia() && item.getMedia().isDownloaded()
|
||||
&& !queue.contains(item.getId()) && item.isRead()) {
|
||||
&& !queue.contains(item.getId()) && item.isPlayed()) {
|
||||
candidates.add(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ public final class DBReader {
|
|||
new FlattrStatus(itemlistCursor.getLong(PodDBAdapter.IDX_FI_SMALL_FLATTR_STATUS)),
|
||||
itemlistCursor.getInt(PodDBAdapter.IDX_FI_SMALL_HAS_CHAPTERS) > 0,
|
||||
image,
|
||||
(itemlistCursor.getInt(PodDBAdapter.IDX_FI_SMALL_READ) > 0),
|
||||
itemlistCursor.getInt(PodDBAdapter.IDX_FI_SMALL_READ),
|
||||
itemlistCursor.getString(PodDBAdapter.IDX_FI_SMALL_ITEM_IDENTIFIER),
|
||||
itemlistCursor.getInt(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_AUTO_DOWNLOAD)) > 0
|
||||
);
|
||||
|
@ -481,8 +481,7 @@ public final class DBReader {
|
|||
* Loads a list of FeedItems whose 'read'-attribute is set to false.
|
||||
*
|
||||
* @param context A context that is used for opening a database connection.
|
||||
* @return A list of FeedItems whose 'read'-attribute it set to false. If the FeedItems in the list are not used,
|
||||
* consider using {@link #getUnreadItemIds(android.content.Context)} instead.
|
||||
* @return A list of FeedItems whose 'read'-attribute it set to false.
|
||||
*/
|
||||
public static List<FeedItem> getUnreadItemsList(Context context) {
|
||||
if (BuildConfig.DEBUG)
|
||||
|
@ -1012,20 +1011,6 @@ public final class DBReader {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map containing the number of unread items per feed
|
||||
*
|
||||
* @param context A context that is used for opening a database connection.
|
||||
* @return The number of unread items per feed.
|
||||
*/
|
||||
public static LongIntMap getNumberOfUnreadFeedItems(final Context context, long... feedIds) {
|
||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
adapter.open();
|
||||
final LongIntMap result = adapter.getNumberOfUnreadFeedItems(feedIds);
|
||||
adapter.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the DB for a FeedImage of the given id.
|
||||
*
|
||||
|
|
|
@ -561,7 +561,7 @@ public final class DBTasks {
|
|||
// all new feeds will have the most recent item marked as unplayed
|
||||
FeedItem mostRecent = newFeed.getMostRecentItem();
|
||||
if (mostRecent != null) {
|
||||
mostRecent.setRead(false);
|
||||
mostRecent.setNew();
|
||||
}
|
||||
|
||||
newFeedsList.add(newFeed);
|
||||
|
@ -572,16 +572,16 @@ public final class DBTasks {
|
|||
|
||||
Collections.sort(newFeed.getItems(), new FeedItemPubdateComparator());
|
||||
|
||||
final boolean markNewItemsAsUnread;
|
||||
final boolean markNewItems;
|
||||
if (newFeed.getPageNr() == savedFeed.getPageNr()) {
|
||||
if (savedFeed.compareWithOther(newFeed)) {
|
||||
Log.d(TAG, "Feed has updated attribute values. Updating old feed's attributes");
|
||||
savedFeed.updateFromOther(newFeed);
|
||||
}
|
||||
markNewItemsAsUnread = true;
|
||||
markNewItems = true;
|
||||
} else {
|
||||
Log.d(TAG, "New feed has a higher page number. Merging without marking as unread");
|
||||
markNewItemsAsUnread = false;
|
||||
markNewItems = false;
|
||||
savedFeed.setNextPageLink(newFeed.getNextPageLink());
|
||||
}
|
||||
if (savedFeed.getPreferences().compareWithOther(newFeed.getPreferences())) {
|
||||
|
@ -599,8 +599,8 @@ public final class DBTasks {
|
|||
item.setFeed(savedFeed);
|
||||
item.setAutoDownload(savedFeed.getPreferences().getAutoDownload());
|
||||
savedFeed.getItems().add(i, item);
|
||||
if (markNewItemsAsUnread) {
|
||||
item.setRead(false);
|
||||
if (markNewItems) {
|
||||
item.setNew();
|
||||
}
|
||||
} else {
|
||||
oldItem.updateFromOther(item);
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.net.URLEncoder;
|
|||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -352,7 +351,7 @@ public class DBWriter {
|
|||
final PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
adapter.open();
|
||||
final List<FeedItem> queue = DBReader.getQueue(context, adapter);
|
||||
FeedItem item = null;
|
||||
FeedItem item;
|
||||
|
||||
if (queue != null) {
|
||||
if (!itemListContains(queue, itemId)) {
|
||||
|
@ -403,23 +402,18 @@ public class DBWriter {
|
|||
|
||||
if (queue != null) {
|
||||
boolean queueModified = false;
|
||||
boolean unreadItemsModified = false;
|
||||
List<FeedItem> itemsToSave = new LinkedList<FeedItem>();
|
||||
for (int i = 0; i < itemIds.length; i++) {
|
||||
if (!itemListContains(queue, itemIds[i])) {
|
||||
final FeedItem item = DBReader.getFeedItem(
|
||||
context, itemIds[i]);
|
||||
final FeedItem item = DBReader.getFeedItem(context, itemIds[i]);
|
||||
|
||||
if (item != null) {
|
||||
// add item to either front ot back of queue
|
||||
boolean addToFront = UserPreferences.enqueueAtFront();
|
||||
|
||||
if(addToFront){
|
||||
queue.add(0+i, item);
|
||||
} else {
|
||||
queue.add(item);
|
||||
}
|
||||
|
||||
queueModified = true;
|
||||
}
|
||||
}
|
||||
|
@ -677,7 +671,7 @@ public class DBWriter {
|
|||
itemCursor.moveToNext();
|
||||
}
|
||||
itemCursor.close();
|
||||
adapter.setFeedItemRead(true, itemIds);
|
||||
adapter.setFeedItemRead(FeedItem.PLAYED, itemIds);
|
||||
adapter.close();
|
||||
|
||||
EventDistributor.getInstance().sendUnreadItemsUpdateBroadcast();
|
||||
|
@ -706,7 +700,7 @@ public class DBWriter {
|
|||
itemCursor.moveToNext();
|
||||
}
|
||||
itemCursor.close();
|
||||
adapter.setFeedItemRead(true, itemIds);
|
||||
adapter.setFeedItemRead(FeedItem.PLAYED, itemIds);
|
||||
adapter.close();
|
||||
|
||||
EventDistributor.getInstance().sendUnreadItemsUpdateBroadcast();
|
||||
|
|
|
@ -742,7 +742,13 @@ public class PodDBAdapter {
|
|||
setFeed(item.getFeed());
|
||||
}
|
||||
values.put(KEY_FEED, item.getFeed().getId());
|
||||
values.put(KEY_READ, item.isRead());
|
||||
if(item.isNew()) {
|
||||
values.put(KEY_READ, FeedItem.NEW);
|
||||
} else if(item.isPlayed()) {
|
||||
values.put(KEY_READ, FeedItem.PLAYED);
|
||||
} else {
|
||||
values.put(KEY_READ, FeedItem.UNPLAYED);
|
||||
}
|
||||
values.put(KEY_HAS_CHAPTERS, item.getChapters() != null || item.hasChapters());
|
||||
values.put(KEY_ITEM_IDENTIFIER, item.getItemIdentifier());
|
||||
values.put(KEY_FLATTR_STATUS, item.getFlattrStatus().toLong());
|
||||
|
@ -774,7 +780,7 @@ public class PodDBAdapter {
|
|||
db.beginTransaction();
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
values.put(KEY_READ, read);
|
||||
values.put(KEY_READ, read ? FeedItem.PLAYED : FeedItem.UNPLAYED);
|
||||
db.update(TABLE_NAME_FEED_ITEMS, values, KEY_ID + "=?", new String[]{String.valueOf(itemId)});
|
||||
|
||||
if (resetMediaPosition) {
|
||||
|
@ -787,7 +793,7 @@ public class PodDBAdapter {
|
|||
db.endTransaction();
|
||||
}
|
||||
|
||||
public void setFeedItemRead(boolean read, long... itemIds) {
|
||||
public void setFeedItemRead(int read, long... itemIds) {
|
||||
db.beginTransaction();
|
||||
ContentValues values = new ContentValues();
|
||||
for (long id : itemIds) {
|
||||
|
@ -873,18 +879,23 @@ public class PodDBAdapter {
|
|||
|
||||
public void setQueue(List<FeedItem> queue) {
|
||||
ContentValues values = new ContentValues();
|
||||
long[] ids = new long[queue.size()];
|
||||
db.beginTransaction();
|
||||
db.delete(TABLE_NAME_QUEUE, null, null);
|
||||
for (int i = 0; i < queue.size(); i++) {
|
||||
FeedItem item = queue.get(i);
|
||||
ids[i] = item.getId();
|
||||
values.put(KEY_ID, i);
|
||||
values.put(KEY_FEEDITEM, item.getId());
|
||||
values.put(KEY_FEED, item.getFeed().getId());
|
||||
db.insertWithOnConflict(TABLE_NAME_QUEUE, null, values,
|
||||
SQLiteDatabase.CONFLICT_REPLACE);
|
||||
db.insertWithOnConflict(TABLE_NAME_QUEUE, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
db.execSQL("UPDATE " + TABLE_NAME_FEED_ITEMS
|
||||
+ " SET " + KEY_READ + "=" + FeedItem.UNPLAYED
|
||||
+ " WHERE " + KEY_ID + " IN(" + TextUtils.join(",", Arrays.asList(ids)) + ")"
|
||||
+ " AND " + KEY_READ + "=" + FeedItem.NEW);
|
||||
}
|
||||
|
||||
public void clearQueue() {
|
||||
|
@ -1059,6 +1070,7 @@ public class PodDBAdapter {
|
|||
/**
|
||||
* Returns a cursor which contains all feed items in the queue. The returned
|
||||
* cursor uses the FEEDITEM_SEL_FI_SMALL selection.
|
||||
* cursor uses the FEEDITEM_SEL_FI_SMALL selection.
|
||||
*/
|
||||
public final Cursor getQueueCursor() {
|
||||
Object[] args = (Object[]) new String[]{
|
||||
|
@ -1090,24 +1102,14 @@ public class PodDBAdapter {
|
|||
*/
|
||||
public final Cursor getUnreadItemsCursor() {
|
||||
Cursor c = db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL, KEY_READ
|
||||
+ "=0", null, null, null, KEY_PUBDATE + " DESC");
|
||||
+ "<" + FeedItem.PLAYED, null, null, null, KEY_PUBDATE + " DESC");
|
||||
return c;
|
||||
}
|
||||
|
||||
public final Cursor getNewItemIdsCursor() {
|
||||
final String query = "SELECT " + TABLE_NAME_FEED_ITEMS + "." + KEY_ID
|
||||
final String query = "SELECT " + KEY_ID
|
||||
+ " FROM " + TABLE_NAME_FEED_ITEMS
|
||||
+ " INNER JOIN " + TABLE_NAME_FEED_MEDIA + " ON "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "="
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM
|
||||
+ " LEFT OUTER JOIN " + TABLE_NAME_QUEUE + " ON "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "="
|
||||
+ TABLE_NAME_QUEUE + "." + KEY_FEEDITEM
|
||||
+ " WHERE "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_READ + " = 0 AND " // unplayed
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_DOWNLOADED + " = 0 AND " // undownloaded
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_POSITION + " = 0 AND " // not partially played
|
||||
+ TABLE_NAME_QUEUE + "." + KEY_ID + " IS NULL"; // not in queue
|
||||
+ " WHERE " + KEY_READ + "=" + FeedItem.NEW;
|
||||
return db.rawQuery(query, null);
|
||||
}
|
||||
|
||||
|
@ -1116,18 +1118,9 @@ public class PodDBAdapter {
|
|||
* The returned cursor uses the FEEDITEM_SEL_FI_SMALL selection.
|
||||
*/
|
||||
public final Cursor getNewItemsCursor() {
|
||||
final String query = "SELECT " + SEL_FI_SMALL_STR + " FROM " + TABLE_NAME_FEED_ITEMS
|
||||
+ " INNER JOIN " + TABLE_NAME_FEED_MEDIA + " ON "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "="
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM
|
||||
+ " LEFT OUTER JOIN " + TABLE_NAME_QUEUE + " ON "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "="
|
||||
+ TABLE_NAME_QUEUE + "." + KEY_FEEDITEM
|
||||
+ " WHERE "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_READ + " = 0 AND " // unplayed
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_DOWNLOADED + " = 0 AND " // undownloaded
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_POSITION + " = 0 AND " // not partially played
|
||||
+ TABLE_NAME_QUEUE + "." + KEY_ID + " IS NULL" // not in queue
|
||||
final String query = "SELECT " + SEL_FI_SMALL_STR
|
||||
+ " FROM " + TABLE_NAME_FEED_ITEMS
|
||||
+ " WHERE " + KEY_READ + "=" + FeedItem.NEW
|
||||
+ " ORDER BY " + KEY_PUBDATE + " DESC";
|
||||
Cursor c = db.rawQuery(query, null);
|
||||
return c;
|
||||
|
@ -1139,11 +1132,11 @@ public class PodDBAdapter {
|
|||
}
|
||||
|
||||
public Cursor getDownloadedItemsCursor() {
|
||||
final String query = "SELECT " + SEL_FI_SMALL_STR + " FROM " + TABLE_NAME_FEED_ITEMS
|
||||
+ " INNER JOIN " + TABLE_NAME_FEED_MEDIA + " ON "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "="
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM + " WHERE "
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_DOWNLOADED + ">0";
|
||||
final String query = "SELECT " + SEL_FI_SMALL_STR
|
||||
+ " FROM " + TABLE_NAME_FEED_ITEMS
|
||||
+ " INNER JOIN " + TABLE_NAME_FEED_MEDIA
|
||||
+ " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "=" + TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM
|
||||
+ " WHERE " + TABLE_NAME_FEED_MEDIA + "." + KEY_DOWNLOADED + ">0";
|
||||
Cursor c = db.rawQuery(query, null);
|
||||
return c;
|
||||
}
|
||||
|
@ -1277,19 +1270,9 @@ public class PodDBAdapter {
|
|||
}
|
||||
|
||||
public final int getNumberOfNewItems() {
|
||||
final String query = "SELECT COUNT(" + TABLE_NAME_FEED_ITEMS + "." + KEY_ID + ")"
|
||||
+" FROM " + TABLE_NAME_FEED_ITEMS
|
||||
+ " LEFT JOIN " + TABLE_NAME_FEED_MEDIA + " ON "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "="
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM
|
||||
+ " LEFT JOIN " + TABLE_NAME_QUEUE + " ON "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "="
|
||||
+ TABLE_NAME_QUEUE + "." + KEY_FEEDITEM
|
||||
+ " WHERE "
|
||||
+ TABLE_NAME_FEED_ITEMS + "." + KEY_READ + " = 0 AND " // unplayed
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_DOWNLOADED + " = 0 AND " // undownloaded
|
||||
+ TABLE_NAME_FEED_MEDIA + "." + KEY_POSITION + " = 0 AND " // not partially played
|
||||
+ TABLE_NAME_QUEUE + "." + KEY_ID + " IS NULL"; // not in queue
|
||||
final String query = "SELECT COUNT(" + KEY_ID + ")"
|
||||
+ " FROM " + TABLE_NAME_FEED_ITEMS
|
||||
+ " WHERE " + KEY_READ + "=" + FeedItem.NEW;
|
||||
Cursor c = db.rawQuery(query, null);
|
||||
int result = 0;
|
||||
if (c.moveToFirst()) {
|
||||
|
@ -1315,7 +1298,8 @@ public class PodDBAdapter {
|
|||
final String query = "SELECT " + KEY_FEED + ", COUNT(" + KEY_ID + ") AS count "
|
||||
+ " FROM " + TABLE_NAME_FEED_ITEMS
|
||||
+ " WHERE " + KEY_FEED + " IN (" + builder.toString() + ") "
|
||||
+ " AND " + KEY_READ + " = 0"
|
||||
+ " AND (" + KEY_READ + "=" + FeedItem.NEW
|
||||
+ " OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")"
|
||||
+ " GROUP BY " + KEY_FEED;
|
||||
Cursor c = db.rawQuery(query, null);
|
||||
LongIntMap result = new LongIntMap(c.getCount());
|
||||
|
|
Loading…
Reference in New Issue