Allow to mark all previous chapters as read

This commit is contained in:
inorichi 2016-01-19 16:35:36 +01:00
parent 416fd128ba
commit 4bf15a5a2c
5 changed files with 22 additions and 0 deletions

View file

@ -254,6 +254,11 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
return true; return true;
} }
public boolean onMarkPreviousAsRead(Chapter chapter) {
getPresenter().markPreviousChaptersAsRead(chapter);
return true;
}
protected boolean onDownload(Observable<Chapter> chapters) { protected boolean onDownload(Observable<Chapter> chapters) {
DownloadService.start(getActivity()); DownloadService.start(getActivity());

View file

@ -99,6 +99,8 @@ public class ChaptersHolder extends FlexibleViewHolder {
return adapter.getFragment().onDownload(chapter); return adapter.getFragment().onDownload(chapter);
case R.id.action_delete: case R.id.action_delete:
return adapter.getFragment().onDelete(chapter); return adapter.getFragment().onDelete(chapter);
case R.id.action_mark_previous_as_read:
return adapter.getFragment().onMarkPreviousAsRead(item);
} }
return false; return false;
}); });

View file

@ -207,6 +207,15 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
.subscribe()); .subscribe());
} }
public void markPreviousChaptersAsRead(Chapter selected) {
Observable.from(chapters)
.filter(c -> c.chapter_number > -1 && c.chapter_number < selected.chapter_number)
.doOnNext(c -> c.read = true)
.toList()
.flatMap(chapters -> db.insertChapters(chapters).asRxObservable())
.subscribe();
}
public void downloadChapters(Observable<Chapter> selectedChapters) { public void downloadChapters(Observable<Chapter> selectedChapters) {
add(selectedChapters add(selectedChapters
.toList() .toList()

View file

@ -22,4 +22,9 @@
android:title="@string/action_mark_as_unread" android:title="@string/action_mark_as_unread"
android:icon="@drawable/ic_action_undone_all" android:icon="@drawable/ic_action_undone_all"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item
android:id="@+id/action_mark_previous_as_read"
android:title="@string/action_mark_previous_as_read"/>
</menu> </menu>

View file

@ -19,6 +19,7 @@
<string name="action_select_all">Select all</string> <string name="action_select_all">Select all</string>
<string name="action_mark_as_read">Mark as read</string> <string name="action_mark_as_read">Mark as read</string>
<string name="action_mark_as_unread">Mark as unread</string> <string name="action_mark_as_unread">Mark as unread</string>
<string name="action_mark_previous_as_read">Mark previous as read</string>
<string name="action_download">Download</string> <string name="action_download">Download</string>
<string name="action_delete">Delete</string> <string name="action_delete">Delete</string>
<string name="action_update">Update</string> <string name="action_update">Update</string>