mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 18:39:19 +01:00
Upgrade to EventBus 3
This commit is contained in:
parent
7835921045
commit
e348d6c1cf
@ -82,13 +82,20 @@ android {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apt {
|
||||||
|
arguments {
|
||||||
|
eventBusIndex "eu.kanade.tachiyomi.EventBusIndex"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
final SUPPORT_LIBRARY_VERSION = '23.1.1'
|
final SUPPORT_LIBRARY_VERSION = '23.1.1'
|
||||||
final DAGGER_VERSION = '2.0.2'
|
final DAGGER_VERSION = '2.0.2'
|
||||||
|
final EVENTBUS_VERSION = '3.0.0'
|
||||||
final OKHTTP_VERSION = '3.1.1'
|
final OKHTTP_VERSION = '3.1.1'
|
||||||
final MOCKITO_VERSION = '1.10.19'
|
|
||||||
final STORIO_VERSION = '1.8.0'
|
final STORIO_VERSION = '1.8.0'
|
||||||
final ICEPICK_VERSION = '3.1.0'
|
final ICEPICK_VERSION = '3.1.0'
|
||||||
|
final MOCKITO_VERSION = '1.10.19'
|
||||||
|
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
compile project(":SubsamplingScaleImageView")
|
compile project(":SubsamplingScaleImageView")
|
||||||
@ -113,7 +120,6 @@ dependencies {
|
|||||||
compile "com.pushtorefresh.storio:sqlite:$STORIO_VERSION"
|
compile "com.pushtorefresh.storio:sqlite:$STORIO_VERSION"
|
||||||
compile "com.pushtorefresh.storio:sqlite-annotations:$STORIO_VERSION"
|
compile "com.pushtorefresh.storio:sqlite-annotations:$STORIO_VERSION"
|
||||||
compile 'info.android15.nucleus:nucleus:2.0.4'
|
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.github.bumptech.glide:glide:3.6.1'
|
||||||
compile 'com.jakewharton:butterknife:7.0.1'
|
compile 'com.jakewharton:butterknife:7.0.1'
|
||||||
compile 'com.jakewharton.timber:timber:4.1.0'
|
compile 'com.jakewharton.timber:timber:4.1.0'
|
||||||
@ -127,6 +133,9 @@ dependencies {
|
|||||||
compile 'com.github.amulyakhare:TextDrawable:558677e'
|
compile 'com.github.amulyakhare:TextDrawable:558677e'
|
||||||
compile 'com.github.pwittchen:reactivenetwork:0.1.5'
|
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"
|
compile "com.google.dagger:dagger:$DAGGER_VERSION"
|
||||||
apt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
|
apt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
|
||||||
apt "com.pushtorefresh.storio:sqlite-annotations-processor:$STORIO_VERSION"
|
apt "com.pushtorefresh.storio:sqlite-annotations-processor:$STORIO_VERSION"
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
|
|
||||||
import org.acra.ACRA;
|
import org.acra.ACRA;
|
||||||
import org.acra.annotation.ReportsCrashes;
|
import org.acra.annotation.ReportsCrashes;
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.injection.ComponentReflectionInjector;
|
import eu.kanade.tachiyomi.injection.ComponentReflectionInjector;
|
||||||
import eu.kanade.tachiyomi.injection.component.AppComponent;
|
import eu.kanade.tachiyomi.injection.component.AppComponent;
|
||||||
@ -39,6 +40,11 @@ public class App extends Application {
|
|||||||
componentInjector =
|
componentInjector =
|
||||||
new ComponentReflectionInjector<>(AppComponent.class, applicationComponent);
|
new ComponentReflectionInjector<>(AppComponent.class, applicationComponent);
|
||||||
|
|
||||||
|
EventBus.builder()
|
||||||
|
.addIndex(new EventBusIndex())
|
||||||
|
.logNoSubscriberMessages(false)
|
||||||
|
.installDefaultEventBus();
|
||||||
|
|
||||||
ACRA.init(this);
|
ACRA.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,16 @@ import android.os.PowerManager;
|
|||||||
|
|
||||||
import com.github.pwittchen.reactivenetwork.library.ReactiveNetwork;
|
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 javax.inject.Inject;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import eu.kanade.tachiyomi.App;
|
import eu.kanade.tachiyomi.App;
|
||||||
import eu.kanade.tachiyomi.R;
|
import eu.kanade.tachiyomi.R;
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper;
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper;
|
||||||
import eu.kanade.tachiyomi.event.DownloadChaptersEvent;
|
import eu.kanade.tachiyomi.event.DownloadChaptersEvent;
|
||||||
import eu.kanade.tachiyomi.util.EventBusHook;
|
|
||||||
import eu.kanade.tachiyomi.util.ToastUtil;
|
import eu.kanade.tachiyomi.util.ToastUtil;
|
||||||
import rx.Subscription;
|
import rx.Subscription;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
@ -47,7 +49,7 @@ public class DownloadService extends Service {
|
|||||||
createWakeLock();
|
createWakeLock();
|
||||||
|
|
||||||
listenQueueRunningChanges();
|
listenQueueRunningChanges();
|
||||||
EventBus.getDefault().registerSticky(this);
|
EventBus.getDefault().register(this);
|
||||||
listenNetworkChanges();
|
listenNetworkChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ public class DownloadService extends Service {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusHook
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||||
public void onEvent(DownloadChaptersEvent event) {
|
public void onEvent(DownloadChaptersEvent event) {
|
||||||
EventBus.getDefault().removeStickyEvent(event);
|
EventBus.getDefault().removeStickyEvent(event);
|
||||||
downloadManager.onDownloadChaptersEvent(event);
|
downloadManager.onDownloadChaptersEvent(event);
|
||||||
|
@ -5,7 +5,8 @@ import android.support.v7.app.AppCompatActivity;
|
|||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import icepick.Icepick;
|
import icepick.Icepick;
|
||||||
|
|
||||||
public class BaseActivity extends AppCompatActivity {
|
public class BaseActivity extends AppCompatActivity {
|
||||||
@ -58,20 +59,8 @@ public class BaseActivity extends AppCompatActivity {
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerForStickyEvents() {
|
|
||||||
registerForStickyEvents(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerForStickyEvents(int priority) {
|
|
||||||
EventBus.getDefault().registerSticky(this, priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerForEvents() {
|
public void registerForEvents() {
|
||||||
registerForEvents(0);
|
EventBus.getDefault().register(this);
|
||||||
}
|
|
||||||
|
|
||||||
public void registerForEvents(int priority) {
|
|
||||||
EventBus.getDefault().register(this, priority);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterForEvents() {
|
public void unregisterForEvents() {
|
||||||
|
@ -3,7 +3,8 @@ package eu.kanade.tachiyomi.ui.base.fragment;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
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 eu.kanade.tachiyomi.ui.base.activity.BaseActivity;
|
||||||
import icepick.Icepick;
|
import icepick.Icepick;
|
||||||
|
|
||||||
@ -33,20 +34,8 @@ public class BaseFragment extends Fragment {
|
|||||||
return (BaseActivity) getActivity();
|
return (BaseActivity) getActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerForStickyEvents() {
|
|
||||||
registerForStickyEvents(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerForStickyEvents(int priority) {
|
|
||||||
EventBus.getDefault().registerSticky(this, priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerForEvents() {
|
public void registerForEvents() {
|
||||||
registerForEvents(0);
|
EventBus.getDefault().register(this);
|
||||||
}
|
|
||||||
|
|
||||||
public void registerForEvents(int priority) {
|
|
||||||
EventBus.getDefault().register(this, priority);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterForEvents() {
|
public void unregisterForEvents() {
|
||||||
|
@ -4,7 +4,8 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import icepick.Icepick;
|
import icepick.Icepick;
|
||||||
import nucleus.view.ViewWithPresenter;
|
import nucleus.view.ViewWithPresenter;
|
||||||
|
|
||||||
@ -24,10 +25,6 @@ public class BasePresenter<V extends ViewWithPresenter> extends RxPresenter<V> {
|
|||||||
Icepick.saveInstanceState(this, state);
|
Icepick.saveInstanceState(this, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerForStickyEvents() {
|
|
||||||
EventBus.getDefault().registerSticky(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerForEvents() {
|
public void registerForEvents() {
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import com.f2prateek.rx.preferences.Preference;
|
import com.f2prateek.rx.preferences.Preference;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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.adapter.FlexibleViewHolder;
|
||||||
import eu.kanade.tachiyomi.ui.base.fragment.BaseFragment;
|
import eu.kanade.tachiyomi.ui.base.fragment.BaseFragment;
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaActivity;
|
import eu.kanade.tachiyomi.ui.manga.MangaActivity;
|
||||||
import eu.kanade.tachiyomi.util.EventBusHook;
|
|
||||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView;
|
import eu.kanade.tachiyomi.widget.AutofitRecyclerView;
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
import rx.Subscription;
|
import rx.Subscription;
|
||||||
@ -97,7 +99,7 @@ public class LibraryCategoryFragment extends BaseFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
registerForStickyEvents();
|
registerForEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,8 +114,8 @@ public class LibraryCategoryFragment extends BaseFragment
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusHook
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(LibraryMangasEvent event) {
|
public void onEvent(LibraryMangasEvent event) {
|
||||||
List<Category> categories = getLibraryFragment().getAdapter().categories;
|
List<Category> categories = getLibraryFragment().getAdapter().categories;
|
||||||
// When a category is deleted, the index can be greater than the number of categories
|
// When a category is deleted, the index can be greater than the number of categories
|
||||||
if (position >= categories.size())
|
if (position >= categories.size())
|
||||||
|
@ -18,13 +18,14 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||||
import eu.kanade.tachiyomi.R;
|
import eu.kanade.tachiyomi.R;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category;
|
import eu.kanade.tachiyomi.data.database.models.Category;
|
||||||
@ -90,12 +91,6 @@ public class LibraryFragment extends BaseRxFragment<LibraryPresenter>
|
|||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
EventBus.getDefault().removeStickyEvent(LibraryMangasEvent.class);
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle bundle) {
|
public void onSaveInstanceState(Bundle bundle) {
|
||||||
activeCategory = viewPager.getCurrentItem();
|
activeCategory = viewPager.getCurrentItem();
|
||||||
|
@ -3,13 +3,14 @@ package eu.kanade.tachiyomi.ui.library;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache;
|
import eu.kanade.tachiyomi.data.cache.CoverCache;
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category;
|
import eu.kanade.tachiyomi.data.database.models.Category;
|
||||||
@ -55,9 +56,9 @@ public class LibraryPresenter extends BasePresenter<LibraryFragment> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDropView() {
|
||||||
EventBus.getDefault().removeStickyEvent(LibraryMangasEvent.class);
|
EventBus.getDefault().removeStickyEvent(LibraryMangasEvent.class);
|
||||||
super.onDestroy();
|
super.onDropView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,11 +15,12 @@ import android.support.v4.content.ContextCompat;
|
|||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import eu.kanade.tachiyomi.App;
|
import eu.kanade.tachiyomi.App;
|
||||||
import eu.kanade.tachiyomi.R;
|
import eu.kanade.tachiyomi.R;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga;
|
import eu.kanade.tachiyomi.data.database.models.Manga;
|
||||||
|
@ -2,14 +2,16 @@ package eu.kanade.tachiyomi.ui.manga;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga;
|
import eu.kanade.tachiyomi.data.database.models.Manga;
|
||||||
import eu.kanade.tachiyomi.event.MangaEvent;
|
import eu.kanade.tachiyomi.event.MangaEvent;
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
||||||
import eu.kanade.tachiyomi.util.EventBusHook;
|
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ public class MangaPresenter extends BasePresenter<MangaActivity> {
|
|||||||
restartableLatestCache(GET_MANGA, this::getMangaObservable, MangaActivity::setManga);
|
restartableLatestCache(GET_MANGA, this::getMangaObservable, MangaActivity::setManga);
|
||||||
|
|
||||||
if (savedState == null)
|
if (savedState == null)
|
||||||
registerForStickyEvents();
|
registerForEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,8 +45,8 @@ public class MangaPresenter extends BasePresenter<MangaActivity> {
|
|||||||
.doOnNext(manga -> EventBus.getDefault().postSticky(new MangaEvent(manga)));
|
.doOnNext(manga -> EventBus.getDefault().postSticky(new MangaEvent(manga)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusHook
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(Manga manga) {
|
public void onEvent(Manga manga) {
|
||||||
EventBus.getDefault().removeStickyEvent(manga);
|
EventBus.getDefault().removeStickyEvent(manga);
|
||||||
unregisterForEvents();
|
unregisterForEvents();
|
||||||
this.manga = manga;
|
this.manga = manga;
|
||||||
|
@ -3,11 +3,14 @@ package eu.kanade.tachiyomi.ui.manga.chapter;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga;
|
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.MangaEvent;
|
||||||
import eu.kanade.tachiyomi.event.ReaderEvent;
|
import eu.kanade.tachiyomi.event.ReaderEvent;
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
||||||
import eu.kanade.tachiyomi.util.EventBusHook;
|
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
@ -72,7 +74,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
|||||||
(view, download) -> view.onChapterStatusChange(download),
|
(view, download) -> view.onChapterStatusChange(download),
|
||||||
(view, error) -> Timber.e(error.getCause(), error.getMessage()));
|
(view, error) -> Timber.e(error.getCause(), error.getMessage()));
|
||||||
|
|
||||||
registerForStickyEvents();
|
registerForEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,8 +84,8 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusHook
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(MangaEvent event) {
|
public void onEvent(MangaEvent event) {
|
||||||
this.manga = event.manga;
|
this.manga = event.manga;
|
||||||
start(GET_MANGA);
|
start(GET_MANGA);
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ package eu.kanade.tachiyomi.ui.manga.info;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
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.ChapterCountEvent;
|
||||||
import eu.kanade.tachiyomi.event.MangaEvent;
|
import eu.kanade.tachiyomi.event.MangaEvent;
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
||||||
import eu.kanade.tachiyomi.util.EventBusHook;
|
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
import rx.schedulers.Schedulers;
|
import rx.schedulers.Schedulers;
|
||||||
@ -80,8 +82,8 @@ public class MangaInfoPresenter extends BasePresenter<MangaInfoFragment> {
|
|||||||
(view, manga) -> view.onFetchMangaDone(),
|
(view, manga) -> view.onFetchMangaDone(),
|
||||||
(view, error) -> view.onFetchMangaError());
|
(view, error) -> view.onFetchMangaError());
|
||||||
|
|
||||||
// onEventMainThread receives an event thanks to this line.
|
// Listen for events
|
||||||
registerForStickyEvents();
|
registerForEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,15 +92,15 @@ public class MangaInfoPresenter extends BasePresenter<MangaInfoFragment> {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusHook
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(MangaEvent event) {
|
public void onEvent(MangaEvent event) {
|
||||||
this.manga = event.manga;
|
this.manga = event.manga;
|
||||||
source = sourceManager.get(manga.source);
|
source = sourceManager.get(manga.source);
|
||||||
refreshManga();
|
refreshManga();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusHook
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(ChapterCountEvent event) {
|
public void onEvent(ChapterCountEvent event) {
|
||||||
if (count != event.getCount()) {
|
if (count != event.getCount()) {
|
||||||
count = event.getCount();
|
count = event.getCount();
|
||||||
start(GET_CHAPTER_COUNT);
|
start(GET_CHAPTER_COUNT);
|
||||||
|
@ -4,6 +4,9 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
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.data.mangasync.services.MyAnimeList;
|
||||||
import eu.kanade.tachiyomi.event.MangaEvent;
|
import eu.kanade.tachiyomi.event.MangaEvent;
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
||||||
import eu.kanade.tachiyomi.util.EventBusHook;
|
|
||||||
import eu.kanade.tachiyomi.util.ToastUtil;
|
import eu.kanade.tachiyomi.util.ToastUtil;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
@ -85,7 +87,7 @@ public class MyAnimeListPresenter extends BasePresenter<MyAnimeListFragment> {
|
|||||||
@Override
|
@Override
|
||||||
protected void onTakeView(MyAnimeListFragment view) {
|
protected void onTakeView(MyAnimeListFragment view) {
|
||||||
super.onTakeView(view);
|
super.onTakeView(view);
|
||||||
registerForStickyEvents();
|
registerForEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -94,8 +96,8 @@ public class MyAnimeListPresenter extends BasePresenter<MyAnimeListFragment> {
|
|||||||
super.onDropView();
|
super.onDropView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusHook
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(MangaEvent event) {
|
public void onEvent(MangaEvent event) {
|
||||||
this.manga = event.manga;
|
this.manga = event.manga;
|
||||||
start(GET_MANGA_SYNC);
|
start(GET_MANGA_SYNC);
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,15 @@ import android.os.Bundle;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.util.Pair;
|
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.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga;
|
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.data.sync.UpdateMangaSyncService;
|
||||||
import eu.kanade.tachiyomi.event.ReaderEvent;
|
import eu.kanade.tachiyomi.event.ReaderEvent;
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter;
|
||||||
import eu.kanade.tachiyomi.util.EventBusHook;
|
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.Subscription;
|
import rx.Subscription;
|
||||||
@ -90,7 +92,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
(view, error) -> view.onChapterError());
|
(view, error) -> view.onChapterError());
|
||||||
|
|
||||||
if (savedState == null) {
|
if (savedState == null) {
|
||||||
registerForStickyEvents();
|
registerForEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +108,8 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
super.onSave(state);
|
super.onSave(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusHook
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(ReaderEvent event) {
|
public void onEvent(ReaderEvent event) {
|
||||||
EventBus.getDefault().removeStickyEvent(event);
|
EventBus.getDefault().removeStickyEvent(event);
|
||||||
manga = event.getManga();
|
manga = event.getManga();
|
||||||
source = event.getSource();
|
source = event.getSource();
|
||||||
|
@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.ui.recent;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -12,7 +14,6 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaChapter;
|
import eu.kanade.tachiyomi.data.database.models.MangaChapter;
|
||||||
import eu.kanade.tachiyomi.data.source.SourceManager;
|
import eu.kanade.tachiyomi.data.source.SourceManager;
|
||||||
|
@ -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 {}
|
|
Loading…
Reference in New Issue
Block a user