Upgrade to EventBus 3
This commit is contained in:
@@ -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<Category> categories = getLibraryFragment().getAdapter().categories;
|
||||
// When a category is deleted, the index can be greater than the number of categories
|
||||
if (position >= categories.size())
|
||||
|
||||
@@ -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<LibraryPresenter>
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
EventBus.getDefault().removeStickyEvent(LibraryMangasEvent.class);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle bundle) {
|
||||
activeCategory = viewPager.getCurrentItem();
|
||||
|
||||
@@ -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<LibraryFragment> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
protected void onDropView() {
|
||||
EventBus.getDefault().removeStickyEvent(LibraryMangasEvent.class);
|
||||
super.onDestroy();
|
||||
super.onDropView();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user