Make media position resettable in markItemRead instead of setter.

In some cases, when setting the 'read' attribute, the programmer might
not want to reset the media position.
This commit is contained in:
daniel oeh 2012-11-16 20:59:22 +01:00
parent 7ca2f559d1
commit 7e8eccce08
3 changed files with 12 additions and 13 deletions

View File

@ -35,7 +35,7 @@ public class FeedItem extends FeedComponent {
private Date pubDate; private Date pubDate;
private FeedMedia media; private FeedMedia media;
private Feed feed; private Feed feed;
protected boolean read; private boolean read;
private String paymentLink; private String paymentLink;
private List<Chapter> chapters; private List<Chapter> chapters;
@ -152,9 +152,6 @@ public class FeedItem extends FeedComponent {
public void setRead(boolean read) { public void setRead(boolean read) {
this.read = read; this.read = read;
if (media != null) {
media.setPosition(0);
}
} }
private boolean isInProgress() { private boolean isInProgress() {

View File

@ -375,15 +375,17 @@ public class FeedManager {
* instead of the setters of FeedItem. * instead of the setters of FeedItem.
*/ */
public void markItemRead(final Context context, final FeedItem item, public void markItemRead(final Context context, final FeedItem item,
final boolean read) { final boolean read, boolean resetMediaPosition) {
if (AppConfig.DEBUG) if (AppConfig.DEBUG)
Log.d(TAG, "Setting item with title " + item.getTitle() Log.d(TAG, "Setting item with title " + item.getTitle()
+ " as read/unread"); + " as read/unread");
item.setRead(read); item.setRead(read);
if (item.hasMedia() && resetMediaPosition) {
item.getMedia().setPosition(0);
}
setFeedItem(context, item); setFeedItem(context, item);
if (item.hasMedia()) if (item.hasMedia() && resetMediaPosition)
setFeedMedia(context, item.getMedia()); setFeedMedia(context, item.getMedia());
contentChanger.post(new Runnable() { contentChanger.post(new Runnable() {
@ -411,7 +413,7 @@ public class FeedManager {
public void markFeedRead(Context context, Feed feed) { public void markFeedRead(Context context, Feed feed) {
for (FeedItem item : feed.getItems()) { for (FeedItem item : feed.getItems()) {
if (unreadItems.contains(item)) { if (unreadItems.contains(item)) {
markItemRead(context, item, true); markItemRead(context, item, true, false);
} }
} }
} }
@ -825,7 +827,7 @@ public class FeedManager {
} }
}); });
markItemRead(context, item, false); markItemRead(context, item, false, false);
} }
} }
// update attributes // update attributes
@ -1168,9 +1170,9 @@ public class FeedManager {
mediaIds.add(String.valueOf(mediaId)); mediaIds.add(String.valueOf(mediaId));
item.setMedia(new FeedMedia(mediaId, item)); item.setMedia(new FeedMedia(mediaId, item));
} }
item.read = (itemlistCursor item.setRead((itemlistCursor
.getInt(PodDBAdapter.IDX_FI_SMALL_READ) > 0) ? true .getInt(PodDBAdapter.IDX_FI_SMALL_READ) > 0) ? true
: false; : false);
item.setItemIdentifier(itemlistCursor item.setItemIdentifier(itemlistCursor
.getString(PodDBAdapter.IDX_FI_SMALL_ITEM_IDENTIFIER)); .getString(PodDBAdapter.IDX_FI_SMALL_ITEM_IDENTIFIER));
if (item.getState() == FeedItem.State.NEW) { if (item.getState() == FeedItem.State.NEW) {

View File

@ -88,10 +88,10 @@ public class FeedItemMenuHandler {
requester.cancelDownload(context, selectedItem.getMedia()); requester.cancelDownload(context, selectedItem.getMedia());
break; break;
case R.id.mark_read_item: case R.id.mark_read_item:
manager.markItemRead(context, selectedItem, true); manager.markItemRead(context, selectedItem, true, true);
break; break;
case R.id.mark_unread_item: case R.id.mark_unread_item:
manager.markItemRead(context, selectedItem, false); manager.markItemRead(context, selectedItem, false, true);
break; break;
case R.id.add_to_queue_item: case R.id.add_to_queue_item:
manager.addQueueItem(context, selectedItem); manager.addQueueItem(context, selectedItem);