mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-17 19:29:44 +01:00
Extract setting of read/undread state to a FeedItem method
This commit is contained in:
parent
39eeadad20
commit
380a5f459b
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -119,7 +119,7 @@ public class FeedMedia extends FeedFile {
|
||||
}
|
||||
|
||||
public boolean isInProgress() {
|
||||
return (this.position > 0 && this.playbackCompletionDate == null);
|
||||
return (this.position > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user