From 53fae2939abb565ff12bd9b3d5632879e356b1d5 Mon Sep 17 00:00:00 2001 From: len Date: Sat, 19 Mar 2016 18:39:18 +0100 Subject: [PATCH] Remove apt, add manual EventBusIndex (not sure if it works) --- app/build.gradle | 4 +- app/src/main/java/eu/kanade/tachiyomi/App.kt | 1 + .../eu/kanade/tachiyomi/EventBusIndex.java | 75 +++++++++++++++++++ .../resolvers/LibraryMangaGetResolver.java | 28 ------- .../resolvers/LibraryMangaGetResolver.kt | 27 +++++++ .../resolvers/MangaChapterGetResolver.java | 38 ---------- .../resolvers/MangaChapterGetResolver.kt | 27 +++++++ .../java/eu/kanade/tachiyomi/TestApp.java | 25 ------- .../test/java/eu/kanade/tachiyomi/TestApp.kt | 22 ++++++ build.gradle | 1 - 10 files changed, 153 insertions(+), 95 deletions(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/EventBusIndex.java delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.kt delete mode 100644 app/src/test/java/eu/kanade/tachiyomi/TestApp.java create mode 100644 app/src/test/java/eu/kanade/tachiyomi/TestApp.kt diff --git a/app/build.gradle b/app/build.gradle index fc95120474..aac5991ba3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,6 @@ import java.text.SimpleDateFormat apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' -apply plugin: 'com.neenbedankt.android-apt' ext { // Git is needed in your system PATH for these commands to work. @@ -131,7 +130,6 @@ dependencies { compile 'com.github.amulyakhare:TextDrawable:558677e' compile "org.greenrobot:eventbus:3.0.0" - apt "org.greenrobot:eventbus-annotation-processor:3.0.1" compile "com.google.dagger:dagger:$DAGGER_VERSION" kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION" @@ -151,7 +149,7 @@ dependencies { exclude group: 'org.apache.httpcomponents', module: 'httpclient' } - androidTestApt "com.google.dagger:dagger-compiler:$DAGGER_VERSION" + kaptTest "com.google.dagger:dagger-compiler:$DAGGER_VERSION" compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 54f81002a5..e615ab9928 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -53,6 +53,7 @@ open class App : Application() { protected open fun setupEventBus() { EventBus.builder() + .addIndex(EventBusIndex()) .logNoSubscriberMessages(false) .installDefaultEventBus() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/EventBusIndex.java b/app/src/main/java/eu/kanade/tachiyomi/EventBusIndex.java new file mode 100644 index 0000000000..2e3a61d000 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/EventBusIndex.java @@ -0,0 +1,75 @@ +package eu.kanade.tachiyomi; + +import org.greenrobot.eventbus.meta.SimpleSubscriberInfo; +import org.greenrobot.eventbus.meta.SubscriberMethodInfo; +import org.greenrobot.eventbus.meta.SubscriberInfo; +import org.greenrobot.eventbus.meta.SubscriberInfoIndex; + +import org.greenrobot.eventbus.ThreadMode; + +import java.util.HashMap; +import java.util.Map; + +/** This class is generated by EventBus, do not edit. */ +public class EventBusIndex implements SubscriberInfoIndex { + private static final Map, SubscriberInfo> SUBSCRIBER_INDEX; + + static { + SUBSCRIBER_INDEX = new HashMap, SubscriberInfo>(); + + putIndex(new SimpleSubscriberInfo(eu.kanade.tachiyomi.ui.manga.MangaPresenter.class, true, + new SubscriberMethodInfo[] { + new SubscriberMethodInfo("onEvent", eu.kanade.tachiyomi.data.database.models.Manga.class, ThreadMode.MAIN, 0, + true), + })); + + putIndex(new SimpleSubscriberInfo(eu.kanade.tachiyomi.ui.manga.myanimelist.MyAnimeListPresenter.class, true, + new SubscriberMethodInfo[] { + new SubscriberMethodInfo("onEvent", eu.kanade.tachiyomi.event.MangaEvent.class, ThreadMode.MAIN, 0, true), + })); + + putIndex(new SimpleSubscriberInfo(eu.kanade.tachiyomi.ui.reader.ReaderPresenter.class, true, + new SubscriberMethodInfo[] { + new SubscriberMethodInfo("onEvent", eu.kanade.tachiyomi.event.ReaderEvent.class, ThreadMode.MAIN, 0, true), + })); + + putIndex(new SimpleSubscriberInfo(eu.kanade.tachiyomi.ui.library.LibraryCategoryFragment.class, true, + new SubscriberMethodInfo[] { + new SubscriberMethodInfo("onEvent", eu.kanade.tachiyomi.event.LibraryMangasEvent.class, ThreadMode.MAIN, 0, + true), + })); + + putIndex(new SimpleSubscriberInfo(eu.kanade.tachiyomi.data.download.DownloadService.class, true, + new SubscriberMethodInfo[] { + new SubscriberMethodInfo("onEvent", eu.kanade.tachiyomi.event.DownloadChaptersEvent.class, ThreadMode.MAIN, + 0, true), + })); + + putIndex(new SimpleSubscriberInfo(eu.kanade.tachiyomi.ui.manga.chapter.ChaptersPresenter.class, true, + new SubscriberMethodInfo[] { + new SubscriberMethodInfo("onEvent", eu.kanade.tachiyomi.event.MangaEvent.class, ThreadMode.MAIN, 0, true), + })); + + putIndex(new SimpleSubscriberInfo(eu.kanade.tachiyomi.ui.manga.info.MangaInfoPresenter.class, true, + new SubscriberMethodInfo[] { + new SubscriberMethodInfo("onEvent", eu.kanade.tachiyomi.event.MangaEvent.class, ThreadMode.MAIN, 0, true), + new SubscriberMethodInfo("onEvent", eu.kanade.tachiyomi.event.ChapterCountEvent.class, ThreadMode.MAIN, 0, + true), + })); + + } + + private static void putIndex(SubscriberInfo info) { + SUBSCRIBER_INDEX.put(info.getSubscriberClass(), info); + } + + @Override + public SubscriberInfo getSubscriberInfo(Class subscriberClass) { + SubscriberInfo info = SUBSCRIBER_INDEX.get(subscriberClass); + if (info != null) { + return info; + } else { + return null; + } + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.java deleted file mode 100644 index 219fcdc58d..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.java +++ /dev/null @@ -1,28 +0,0 @@ -package eu.kanade.tachiyomi.data.database.resolvers; - -import android.database.Cursor; -import android.support.annotation.NonNull; - -import eu.kanade.tachiyomi.data.database.models.Manga; -import eu.kanade.tachiyomi.data.database.models.MangaStorIOSQLiteGetResolver; -import eu.kanade.tachiyomi.data.database.tables.MangaTable; - -public class LibraryMangaGetResolver extends MangaStorIOSQLiteGetResolver { - - public static final LibraryMangaGetResolver INSTANCE = new LibraryMangaGetResolver(); - - @Override - @NonNull - public Manga mapFromCursor(@NonNull Cursor cursor) { - Manga manga = super.mapFromCursor(cursor); - - int unreadColumn = cursor.getColumnIndex(MangaTable.COLUMN_UNREAD); - manga.unread = cursor.getInt(unreadColumn); - - int categoryColumn = cursor.getColumnIndex(MangaTable.COLUMN_CATEGORY); - manga.category = cursor.getInt(categoryColumn); - - return manga; - } - -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.kt new file mode 100644 index 0000000000..3a0ac84bc9 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.kt @@ -0,0 +1,27 @@ +package eu.kanade.tachiyomi.data.database.resolvers + +import android.database.Cursor + +import eu.kanade.tachiyomi.data.database.models.Manga +import eu.kanade.tachiyomi.data.database.models.MangaStorIOSQLiteGetResolver +import eu.kanade.tachiyomi.data.database.tables.MangaTable + +class LibraryMangaGetResolver : MangaStorIOSQLiteGetResolver() { + + companion object { + val INSTANCE = LibraryMangaGetResolver() + } + + override fun mapFromCursor(cursor: Cursor): Manga { + val manga = super.mapFromCursor(cursor) + + val unreadColumn = cursor.getColumnIndex(MangaTable.COLUMN_UNREAD) + manga.unread = cursor.getInt(unreadColumn) + + val categoryColumn = cursor.getColumnIndex(MangaTable.COLUMN_CATEGORY) + manga.category = cursor.getInt(categoryColumn) + + return manga + } + +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.java deleted file mode 100644 index 35fbdc62d3..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.java +++ /dev/null @@ -1,38 +0,0 @@ -package eu.kanade.tachiyomi.data.database.resolvers; - -import android.database.Cursor; -import android.support.annotation.NonNull; - -import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; - -import eu.kanade.tachiyomi.data.database.models.Chapter; -import eu.kanade.tachiyomi.data.database.models.ChapterStorIOSQLiteGetResolver; -import eu.kanade.tachiyomi.data.database.models.Manga; -import eu.kanade.tachiyomi.data.database.models.MangaChapter; -import eu.kanade.tachiyomi.data.database.models.MangaStorIOSQLiteGetResolver; - -public class MangaChapterGetResolver extends DefaultGetResolver { - - public static final MangaChapterGetResolver INSTANCE = new MangaChapterGetResolver(); - - @NonNull - private final MangaStorIOSQLiteGetResolver mangaGetResolver; - - @NonNull - private final ChapterStorIOSQLiteGetResolver chapterGetResolver; - - public MangaChapterGetResolver() { - this.mangaGetResolver = new MangaStorIOSQLiteGetResolver(); - this.chapterGetResolver = new ChapterStorIOSQLiteGetResolver(); - } - - @NonNull - @Override - public MangaChapter mapFromCursor(@NonNull Cursor cursor) { - final Manga manga = mangaGetResolver.mapFromCursor(cursor); - final Chapter chapter = chapterGetResolver.mapFromCursor(cursor); - manga.id = chapter.manga_id; - - return new MangaChapter(manga, chapter); - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.kt new file mode 100644 index 0000000000..e057c6a443 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.kt @@ -0,0 +1,27 @@ +package eu.kanade.tachiyomi.data.database.resolvers + +import android.database.Cursor +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver +import eu.kanade.tachiyomi.data.database.models.ChapterStorIOSQLiteGetResolver +import eu.kanade.tachiyomi.data.database.models.MangaChapter +import eu.kanade.tachiyomi.data.database.models.MangaStorIOSQLiteGetResolver + +class MangaChapterGetResolver : DefaultGetResolver() { + + companion object { + val INSTANCE = MangaChapterGetResolver() + } + + private val mangaGetResolver = MangaStorIOSQLiteGetResolver() + + private val chapterGetResolver = ChapterStorIOSQLiteGetResolver() + + override fun mapFromCursor(cursor: Cursor): MangaChapter { + val manga = mangaGetResolver.mapFromCursor(cursor) + val chapter = chapterGetResolver.mapFromCursor(cursor) + manga.id = chapter.manga_id + + return MangaChapter(manga, chapter) + } + +} diff --git a/app/src/test/java/eu/kanade/tachiyomi/TestApp.java b/app/src/test/java/eu/kanade/tachiyomi/TestApp.java deleted file mode 100644 index f94649309b..0000000000 --- a/app/src/test/java/eu/kanade/tachiyomi/TestApp.java +++ /dev/null @@ -1,25 +0,0 @@ -package eu.kanade.tachiyomi; - -import eu.kanade.tachiyomi.injection.component.DaggerAppComponent; -import eu.kanade.tachiyomi.injection.module.AppModule; -import eu.kanade.tachiyomi.injection.module.TestDataModule; - -public class TestApp extends App { - - @Override - protected DaggerAppComponent.Builder prepareAppComponent() { - return DaggerAppComponent.builder() - .appModule(new AppModule(this)) - .dataModule(new TestDataModule()); - } - - @Override - protected void setupEventBus() { - // Do nothing - } - - @Override - protected void setupAcra() { - // Do nothing - } -} diff --git a/app/src/test/java/eu/kanade/tachiyomi/TestApp.kt b/app/src/test/java/eu/kanade/tachiyomi/TestApp.kt new file mode 100644 index 0000000000..554865e5dd --- /dev/null +++ b/app/src/test/java/eu/kanade/tachiyomi/TestApp.kt @@ -0,0 +1,22 @@ +package eu.kanade.tachiyomi + +import eu.kanade.tachiyomi.injection.component.DaggerAppComponent +import eu.kanade.tachiyomi.injection.module.AppModule +import eu.kanade.tachiyomi.injection.module.TestDataModule + +class TestApp : App() { + + override fun prepareAppComponent(): DaggerAppComponent.Builder { + return DaggerAppComponent.builder() + .appModule(AppModule(this)) + .dataModule(TestDataModule()) + } + + override fun setupEventBus() { + // Do nothing + } + + override fun setupAcra() { + // Do nothing + } +} diff --git a/build.gradle b/build.gradle index 922dc04c83..517e10293b 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,6 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.1.0-alpha3' - classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files