Extract setting of read/undread state to a FeedItem method

This commit is contained in:
Michael Kaiser 2012-10-24 19:06:57 +02:00
parent 39eeadad20
commit 380a5f459b
4 changed files with 15 additions and 13 deletions

View File

@ -128,6 +128,18 @@ public class FeedItem extends FeedComponent {
return read;
}
public void setRead(boolean read) {
this.read = read;
if (media != null) {
media.setPosition(0);
if (read) {
media.setPlaybackCompletionDate(new Date());
} else {
media.setPlaybackCompletionDate(null);
}
}
}
public boolean isInProgress() {
return (media != null && media.isInProgress());
}

View File

@ -379,17 +379,8 @@ public class FeedManager {
if (AppConfig.DEBUG)
Log.d(TAG, "Setting item with title " + item.getTitle()
+ " as read/unread");
item.read = read;
FeedMedia media = item.getMedia();
if (media != null) {
if (read) {
media.setPlaybackCompletionDate(new Date());
} else {
media.setPlaybackCompletionDate(null);
media.setPosition(0);
}
}
item.setRead(read);
setFeedItem(context, item);
contentChanger.post(new Runnable() {
@ -427,7 +418,7 @@ public class FeedManager {
if (AppConfig.DEBUG)
Log.d(TAG, "marking all items as read");
for (FeedItem item : unreadItems) {
item.read = true;
item.setRead(true);
}
final ArrayList<FeedItem> unreadItemsCopy = new ArrayList<FeedItem>(
unreadItems);

View File

@ -119,7 +119,7 @@ public class FeedMedia extends FeedFile {
}
public boolean isInProgress() {
return (this.position > 0 && this.playbackCompletionDate == null);
return (this.position > 0);
}
}

View File

@ -673,7 +673,6 @@ public class PlaybackService extends Service {
.getDefaultSharedPreferences(getApplicationContext());
// Save state
cancelPositionSaver();
media.setPosition(0);
media.setPlaybackCompletionDate(new Date());
manager.markItemRead(PlaybackService.this, media.getItem(), true);
FeedItem nextItem = manager