|
@@ -24,11 +24,13 @@ import butterknife.ButterKnife;
|
|
|
import eu.kanade.mangafeed.R;
|
|
|
import eu.kanade.mangafeed.data.database.models.Chapter;
|
|
|
import eu.kanade.mangafeed.data.download.DownloadService;
|
|
|
+import eu.kanade.mangafeed.event.DownloadStatusEvent;
|
|
|
import eu.kanade.mangafeed.ui.base.activity.BaseActivity;
|
|
|
import eu.kanade.mangafeed.ui.base.fragment.BaseRxFragment;
|
|
|
import eu.kanade.mangafeed.ui.decoration.DividerItemDecoration;
|
|
|
import eu.kanade.mangafeed.ui.manga.MangaActivity;
|
|
|
import eu.kanade.mangafeed.ui.reader.ReaderActivity;
|
|
|
+import eu.kanade.mangafeed.util.EventBusHook;
|
|
|
import eu.kanade.mangafeed.util.ToastUtil;
|
|
|
import nucleus.factory.RequiresPresenter;
|
|
|
import rx.Observable;
|
|
@@ -94,6 +96,18 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
|
|
return view;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onResume() {
|
|
|
+ super.onResume();
|
|
|
+ registerForEvents();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPause() {
|
|
|
+ unregisterForEvents();
|
|
|
+ super.onPause();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
inflater.inflate(R.menu.chapters, menu);
|
|
@@ -134,6 +148,19 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
|
|
startActivity(intent);
|
|
|
}
|
|
|
|
|
|
+ @EventBusHook
|
|
|
+ public void onEventMainThread(DownloadStatusEvent event) {
|
|
|
+ Chapter chapter;
|
|
|
+ for (int i = 0; i < adapter.getItemCount(); i++) {
|
|
|
+ chapter = adapter.getItem(i);
|
|
|
+ if (event.getChapterId() == chapter.id) {
|
|
|
+ chapter.status = event.getStatus();
|
|
|
+ adapter.notifyItemChanged(i);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
|
|
mode.getMenuInflater().inflate(R.menu.chapter_selection, menu);
|