From e348d6c1cf36e7d56e7474d2d30067355137f6fd Mon Sep 17 00:00:00 2001 From: inorichi Date: Tue, 9 Feb 2016 21:19:11 +0100 Subject: [PATCH] Upgrade to EventBus 3 --- app/build.gradle | 13 +++++++++++-- app/src/main/java/eu/kanade/tachiyomi/App.java | 6 ++++++ .../data/download/DownloadService.java | 10 ++++++---- .../ui/base/activity/BaseActivity.java | 17 +++-------------- .../ui/base/fragment/BaseFragment.java | 17 +++-------------- .../ui/base/presenter/BasePresenter.java | 7 ++----- .../ui/library/LibraryCategoryFragment.java | 10 ++++++---- .../tachiyomi/ui/library/LibraryFragment.java | 9 ++------- .../tachiyomi/ui/library/LibraryPresenter.java | 7 ++++--- .../tachiyomi/ui/manga/MangaActivity.java | 3 ++- .../tachiyomi/ui/manga/MangaPresenter.java | 12 +++++++----- .../ui/manga/chapter/ChaptersPresenter.java | 12 +++++++----- .../ui/manga/info/MangaInfoPresenter.java | 16 +++++++++------- .../manga/myanimelist/MyAnimeListPresenter.java | 10 ++++++---- .../tachiyomi/ui/reader/ReaderPresenter.java | 12 +++++++----- .../ui/recent/RecentChaptersPresenter.java | 3 ++- .../eu/kanade/tachiyomi/util/EventBusHook.java | 7 ------- 17 files changed, 83 insertions(+), 88 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/util/EventBusHook.java diff --git a/app/build.gradle b/app/build.gradle index 746477fcdf..a966716780 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -82,13 +82,20 @@ android { } +apt { + arguments { + eventBusIndex "eu.kanade.tachiyomi.EventBusIndex" + } +} + dependencies { final SUPPORT_LIBRARY_VERSION = '23.1.1' final DAGGER_VERSION = '2.0.2' + final EVENTBUS_VERSION = '3.0.0' final OKHTTP_VERSION = '3.1.1' - final MOCKITO_VERSION = '1.10.19' final STORIO_VERSION = '1.8.0' final ICEPICK_VERSION = '3.1.0' + final MOCKITO_VERSION = '1.10.19' compile fileTree(dir: 'libs', include: ['*.jar']) compile project(":SubsamplingScaleImageView") @@ -113,7 +120,6 @@ dependencies { compile "com.pushtorefresh.storio:sqlite:$STORIO_VERSION" compile "com.pushtorefresh.storio:sqlite-annotations:$STORIO_VERSION" compile 'info.android15.nucleus:nucleus:2.0.4' - compile 'de.greenrobot:eventbus:2.4.0' compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.jakewharton:butterknife:7.0.1' compile 'com.jakewharton.timber:timber:4.1.0' @@ -127,6 +133,9 @@ dependencies { compile 'com.github.amulyakhare:TextDrawable:558677e' compile 'com.github.pwittchen:reactivenetwork:0.1.5' + compile "org.greenrobot:eventbus:$EVENTBUS_VERSION" + apt "org.greenrobot:eventbus-annotation-processor:$EVENTBUS_VERSION" + compile "com.google.dagger:dagger:$DAGGER_VERSION" apt "com.google.dagger:dagger-compiler:$DAGGER_VERSION" apt "com.pushtorefresh.storio:sqlite-annotations-processor:$STORIO_VERSION" diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.java b/app/src/main/java/eu/kanade/tachiyomi/App.java index 1e6305797c..1a2ef055c3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.java +++ b/app/src/main/java/eu/kanade/tachiyomi/App.java @@ -5,6 +5,7 @@ import android.content.Context; import org.acra.ACRA; import org.acra.annotation.ReportsCrashes; +import org.greenrobot.eventbus.EventBus; import eu.kanade.tachiyomi.injection.ComponentReflectionInjector; import eu.kanade.tachiyomi.injection.component.AppComponent; @@ -39,6 +40,11 @@ public class App extends Application { componentInjector = new ComponentReflectionInjector<>(AppComponent.class, applicationComponent); + EventBus.builder() + .addIndex(new EventBusIndex()) + .logNoSubscriberMessages(false) + .installDefaultEventBus(); + ACRA.init(this); } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.java b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.java index 43aa82f4d0..e232e59e01 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.java +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.java @@ -8,14 +8,16 @@ import android.os.PowerManager; import com.github.pwittchen.reactivenetwork.library.ReactiveNetwork; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import javax.inject.Inject; -import de.greenrobot.event.EventBus; import eu.kanade.tachiyomi.App; import eu.kanade.tachiyomi.R; import eu.kanade.tachiyomi.data.preference.PreferencesHelper; import eu.kanade.tachiyomi.event.DownloadChaptersEvent; -import eu.kanade.tachiyomi.util.EventBusHook; import eu.kanade.tachiyomi.util.ToastUtil; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; @@ -47,7 +49,7 @@ public class DownloadService extends Service { createWakeLock(); listenQueueRunningChanges(); - EventBus.getDefault().registerSticky(this); + EventBus.getDefault().register(this); listenNetworkChanges(); } @@ -71,7 +73,7 @@ public class DownloadService extends Service { return null; } - @EventBusHook + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEvent(DownloadChaptersEvent event) { EventBus.getDefault().removeStickyEvent(event); downloadManager.onDownloadChaptersEvent(event); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.java index 90d92ba744..469e2489fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.java @@ -5,7 +5,8 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.MenuItem; -import de.greenrobot.event.EventBus; +import org.greenrobot.eventbus.EventBus; + import icepick.Icepick; public class BaseActivity extends AppCompatActivity { @@ -58,20 +59,8 @@ public class BaseActivity extends AppCompatActivity { return super.onOptionsItemSelected(item); } - public void registerForStickyEvents() { - registerForStickyEvents(0); - } - - public void registerForStickyEvents(int priority) { - EventBus.getDefault().registerSticky(this, priority); - } - public void registerForEvents() { - registerForEvents(0); - } - - public void registerForEvents(int priority) { - EventBus.getDefault().register(this, priority); + EventBus.getDefault().register(this); } public void unregisterForEvents() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseFragment.java index 9b20f5cdb7..ab25316645 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseFragment.java @@ -3,7 +3,8 @@ package eu.kanade.tachiyomi.ui.base.fragment; import android.os.Bundle; import android.support.v4.app.Fragment; -import de.greenrobot.event.EventBus; +import org.greenrobot.eventbus.EventBus; + import eu.kanade.tachiyomi.ui.base.activity.BaseActivity; import icepick.Icepick; @@ -33,20 +34,8 @@ public class BaseFragment extends Fragment { return (BaseActivity) getActivity(); } - public void registerForStickyEvents() { - registerForStickyEvents(0); - } - - public void registerForStickyEvents(int priority) { - EventBus.getDefault().registerSticky(this, priority); - } - public void registerForEvents() { - registerForEvents(0); - } - - public void registerForEvents(int priority) { - EventBus.getDefault().register(this, priority); + EventBus.getDefault().register(this); } public void unregisterForEvents() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/presenter/BasePresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/presenter/BasePresenter.java index fe3c720699..cccbc0602b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/presenter/BasePresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/presenter/BasePresenter.java @@ -4,7 +4,8 @@ import android.content.Context; import android.os.Bundle; import android.support.annotation.NonNull; -import de.greenrobot.event.EventBus; +import org.greenrobot.eventbus.EventBus; + import icepick.Icepick; import nucleus.view.ViewWithPresenter; @@ -24,10 +25,6 @@ public class BasePresenter extends RxPresenter { Icepick.saveInstanceState(this, state); } - public void registerForStickyEvents() { - EventBus.getDefault().registerSticky(this); - } - public void registerForEvents() { EventBus.getDefault().register(this); } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.java index a94b822815..0b2dc199f5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.java @@ -9,6 +9,9 @@ import android.view.ViewGroup; import com.f2prateek.rx.preferences.Preference; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import java.util.ArrayList; import java.util.List; @@ -22,7 +25,6 @@ import eu.kanade.tachiyomi.event.LibraryMangasEvent; import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder; import eu.kanade.tachiyomi.ui.base.fragment.BaseFragment; import eu.kanade.tachiyomi.ui.manga.MangaActivity; -import eu.kanade.tachiyomi.util.EventBusHook; import eu.kanade.tachiyomi.widget.AutofitRecyclerView; import icepick.State; import rx.Subscription; @@ -97,7 +99,7 @@ public class LibraryCategoryFragment extends BaseFragment @Override public void onResume() { super.onResume(); - registerForStickyEvents(); + registerForEvents(); } @Override @@ -112,8 +114,8 @@ public class LibraryCategoryFragment extends BaseFragment super.onSaveInstanceState(outState); } - @EventBusHook - public void onEventMainThread(LibraryMangasEvent event) { + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) + public void onEvent(LibraryMangasEvent event) { List categories = getLibraryFragment().getAdapter().categories; // When a category is deleted, the index can be greater than the number of categories if (position >= categories.size()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.java index b25d565846..b5a08c2479 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.java @@ -18,13 +18,14 @@ import android.view.ViewGroup; import com.afollestad.materialdialogs.MaterialDialog; +import org.greenrobot.eventbus.EventBus; + import java.util.ArrayList; import java.util.List; import java.util.Map; import butterknife.Bind; import butterknife.ButterKnife; -import de.greenrobot.event.EventBus; import eu.davidea.flexibleadapter.FlexibleAdapter; import eu.kanade.tachiyomi.R; import eu.kanade.tachiyomi.data.database.models.Category; @@ -90,12 +91,6 @@ public class LibraryFragment extends BaseRxFragment super.onDestroyView(); } - @Override - public void onPause() { - EventBus.getDefault().removeStickyEvent(LibraryMangasEvent.class); - super.onPause(); - } - @Override public void onSaveInstanceState(Bundle bundle) { activeCategory = viewPager.getCurrentItem(); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.java index 71d64f9762..98fc64d6fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.java @@ -3,13 +3,14 @@ package eu.kanade.tachiyomi.ui.library; import android.os.Bundle; import android.util.Pair; +import org.greenrobot.eventbus.EventBus; + import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.inject.Inject; -import de.greenrobot.event.EventBus; import eu.kanade.tachiyomi.data.cache.CoverCache; import eu.kanade.tachiyomi.data.database.DatabaseHelper; import eu.kanade.tachiyomi.data.database.models.Category; @@ -55,9 +56,9 @@ public class LibraryPresenter extends BasePresenter { } @Override - protected void onDestroy() { + protected void onDropView() { EventBus.getDefault().removeStickyEvent(LibraryMangasEvent.class); - super.onDestroy(); + super.onDropView(); } @Override diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaActivity.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaActivity.java index 554db50a97..a488a4cb2e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaActivity.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaActivity.java @@ -15,11 +15,12 @@ import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.widget.Toolbar; +import org.greenrobot.eventbus.EventBus; + import javax.inject.Inject; import butterknife.Bind; import butterknife.ButterKnife; -import de.greenrobot.event.EventBus; import eu.kanade.tachiyomi.App; import eu.kanade.tachiyomi.R; import eu.kanade.tachiyomi.data.database.models.Manga; diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.java index a24f093e71..c976f9e28f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.java @@ -2,14 +2,16 @@ package eu.kanade.tachiyomi.ui.manga; import android.os.Bundle; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import javax.inject.Inject; -import de.greenrobot.event.EventBus; import eu.kanade.tachiyomi.data.database.DatabaseHelper; import eu.kanade.tachiyomi.data.database.models.Manga; import eu.kanade.tachiyomi.event.MangaEvent; import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter; -import eu.kanade.tachiyomi.util.EventBusHook; import icepick.State; import rx.Observable; @@ -28,7 +30,7 @@ public class MangaPresenter extends BasePresenter { restartableLatestCache(GET_MANGA, this::getMangaObservable, MangaActivity::setManga); if (savedState == null) - registerForStickyEvents(); + registerForEvents(); } @Override @@ -43,8 +45,8 @@ public class MangaPresenter extends BasePresenter { .doOnNext(manga -> EventBus.getDefault().postSticky(new MangaEvent(manga))); } - @EventBusHook - public void onEventMainThread(Manga manga) { + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) + public void onEvent(Manga manga) { EventBus.getDefault().removeStickyEvent(manga); unregisterForEvents(); this.manga = manga; diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.java index 1175809f06..bb5cfbada0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.java @@ -3,11 +3,14 @@ package eu.kanade.tachiyomi.ui.manga.chapter; import android.os.Bundle; import android.util.Pair; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import java.util.List; import javax.inject.Inject; -import de.greenrobot.event.EventBus; import eu.kanade.tachiyomi.data.database.DatabaseHelper; import eu.kanade.tachiyomi.data.database.models.Chapter; import eu.kanade.tachiyomi.data.database.models.Manga; @@ -21,7 +24,6 @@ import eu.kanade.tachiyomi.event.DownloadChaptersEvent; import eu.kanade.tachiyomi.event.MangaEvent; import eu.kanade.tachiyomi.event.ReaderEvent; import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter; -import eu.kanade.tachiyomi.util.EventBusHook; import icepick.State; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; @@ -72,7 +74,7 @@ public class ChaptersPresenter extends BasePresenter { (view, download) -> view.onChapterStatusChange(download), (view, error) -> Timber.e(error.getCause(), error.getMessage())); - registerForStickyEvents(); + registerForEvents(); } @Override @@ -82,8 +84,8 @@ public class ChaptersPresenter extends BasePresenter { super.onDestroy(); } - @EventBusHook - public void onEventMainThread(MangaEvent event) { + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) + public void onEvent(MangaEvent event) { this.manga = event.manga; start(GET_MANGA); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.java index 224f38604d..82495c1820 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.java @@ -3,6 +3,9 @@ package eu.kanade.tachiyomi.ui.manga.info; import android.os.Bundle; import android.widget.ImageView; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import java.io.File; import java.io.IOException; @@ -16,7 +19,6 @@ import eu.kanade.tachiyomi.data.source.base.Source; import eu.kanade.tachiyomi.event.ChapterCountEvent; import eu.kanade.tachiyomi.event.MangaEvent; import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter; -import eu.kanade.tachiyomi.util.EventBusHook; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; @@ -80,8 +82,8 @@ public class MangaInfoPresenter extends BasePresenter { (view, manga) -> view.onFetchMangaDone(), (view, error) -> view.onFetchMangaError()); - // onEventMainThread receives an event thanks to this line. - registerForStickyEvents(); + // Listen for events + registerForEvents(); } @Override @@ -90,15 +92,15 @@ public class MangaInfoPresenter extends BasePresenter { super.onDestroy(); } - @EventBusHook - public void onEventMainThread(MangaEvent event) { + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) + public void onEvent(MangaEvent event) { this.manga = event.manga; source = sourceManager.get(manga.source); refreshManga(); } - @EventBusHook - public void onEventMainThread(ChapterCountEvent event) { + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) + public void onEvent(ChapterCountEvent event) { if (count != event.getCount()) { count = event.getCount(); start(GET_CHAPTER_COUNT); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListPresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListPresenter.java index e997b77b5e..0ccff700dd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListPresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListPresenter.java @@ -4,6 +4,9 @@ import android.content.Context; import android.os.Bundle; import android.text.TextUtils; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import java.util.List; import javax.inject.Inject; @@ -16,7 +19,6 @@ import eu.kanade.tachiyomi.data.mangasync.MangaSyncManager; import eu.kanade.tachiyomi.data.mangasync.services.MyAnimeList; import eu.kanade.tachiyomi.event.MangaEvent; import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter; -import eu.kanade.tachiyomi.util.EventBusHook; import eu.kanade.tachiyomi.util.ToastUtil; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; @@ -85,7 +87,7 @@ public class MyAnimeListPresenter extends BasePresenter { @Override protected void onTakeView(MyAnimeListFragment view) { super.onTakeView(view); - registerForStickyEvents(); + registerForEvents(); } @Override @@ -94,8 +96,8 @@ public class MyAnimeListPresenter extends BasePresenter { super.onDropView(); } - @EventBusHook - public void onEventMainThread(MangaEvent event) { + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) + public void onEvent(MangaEvent event) { this.manga = event.manga; start(GET_MANGA_SYNC); } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.java index 14ab9bc2a8..21ca565295 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.java @@ -4,12 +4,15 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.util.Pair; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import java.io.File; import java.util.List; import javax.inject.Inject; -import de.greenrobot.event.EventBus; import eu.kanade.tachiyomi.data.database.DatabaseHelper; import eu.kanade.tachiyomi.data.database.models.Chapter; import eu.kanade.tachiyomi.data.database.models.Manga; @@ -25,7 +28,6 @@ import eu.kanade.tachiyomi.data.source.model.Page; import eu.kanade.tachiyomi.data.sync.UpdateMangaSyncService; import eu.kanade.tachiyomi.event.ReaderEvent; import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter; -import eu.kanade.tachiyomi.util.EventBusHook; import icepick.State; import rx.Observable; import rx.Subscription; @@ -90,7 +92,7 @@ public class ReaderPresenter extends BasePresenter { (view, error) -> view.onChapterError()); if (savedState == null) { - registerForStickyEvents(); + registerForEvents(); } } @@ -106,8 +108,8 @@ public class ReaderPresenter extends BasePresenter { super.onSave(state); } - @EventBusHook - public void onEventMainThread(ReaderEvent event) { + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) + public void onEvent(ReaderEvent event) { EventBus.getDefault().removeStickyEvent(event); manga = event.getManga(); source = event.getSource(); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/RecentChaptersPresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/RecentChaptersPresenter.java index 5603423512..f991ee93b9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/RecentChaptersPresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/RecentChaptersPresenter.java @@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.ui.recent; import android.os.Bundle; +import org.greenrobot.eventbus.EventBus; + import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; @@ -12,7 +14,6 @@ import java.util.TreeMap; import javax.inject.Inject; -import de.greenrobot.event.EventBus; import eu.kanade.tachiyomi.data.database.DatabaseHelper; import eu.kanade.tachiyomi.data.database.models.MangaChapter; import eu.kanade.tachiyomi.data.source.SourceManager; diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/EventBusHook.java b/app/src/main/java/eu/kanade/tachiyomi/util/EventBusHook.java deleted file mode 100644 index 013de2854b..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/util/EventBusHook.java +++ /dev/null @@ -1,7 +0,0 @@ -package eu.kanade.tachiyomi.util; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; - -@Target({ElementType.METHOD}) -public @interface EventBusHook {} \ No newline at end of file