From 0f7923a688e9bb2c007b63de9d6d5efd908c43cf Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 2 Feb 2020 22:04:20 -0500 Subject: [PATCH] Remove unused SharedData object --- .../data/backup/BackupRestoreService.kt | 2 +- .../ui/manga/info/MangaInfoController.kt | 2 +- .../eu/kanade/tachiyomi/util/SharedData.kt | 55 ------------------- 3 files changed, 2 insertions(+), 57 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/util/SharedData.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt index f2c2db5acd..05c4416387 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt @@ -31,7 +31,7 @@ import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.source.SourceNotFoundException import eu.kanade.tachiyomi.util.chop -import eu.kanade.tachiyomi.util.getUriCompat +import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.isServiceRunning import eu.kanade.tachiyomi.util.notificationManager import kotlinx.coroutines.CoroutineExceptionHandler diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index fd0d0ead37..4c763ddcae 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -62,7 +62,7 @@ import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.doOnApplyWindowInsets -import eu.kanade.tachiyomi.util.getUriCompat +import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.marginBottom import eu.kanade.tachiyomi.util.snack import eu.kanade.tachiyomi.util.toast diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/SharedData.kt b/app/src/main/java/eu/kanade/tachiyomi/util/SharedData.kt deleted file mode 100644 index 5ac2f45ebb..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/util/SharedData.kt +++ /dev/null @@ -1,55 +0,0 @@ -package eu.kanade.tachiyomi.util - -import java.util.* - -/** - * This singleton is used to share some objects within the application, useful to communicate - * different parts of the app. - * - * It stores the objects in a map using the type of the object as key, so that only one object per - * class is stored at once. - */ -object SharedData { - - /** - * Map where the objects are saved. - */ - val map = HashMap, Any>() - - /** - * Publish an object to the shared data. - * - * @param data the object to put. - */ - fun put(data: T) { - map[data.javaClass] = data - } - - /** - * Retrieves an object from the shared data. - * - * @param classType the class of the object to retrieve. - * @return an object of type T or null if it's not found. - */ - @Suppress("UNCHECKED_CAST") - fun get(classType: Class) = map[classType] as? T - - /** - * Removes an object from the shared data. - * - * @param classType the class of the object to remove. - * @return the object removed, null otherwise. - */ - fun remove(classType: Class) = get(classType)?.apply { map.remove(classType) } - - /** - * Returns an object from the shared data or introduces a new one with the given function. - * - * @param classType the class of the object to retrieve. - * @param fn the function to execute if it didn't find the object. - * @return an object of type T. - */ - @Suppress("UNCHECKED_CAST") - inline fun getOrPut(classType: Class, fn: () -> T) = map.getOrPut(classType, fn) as T - -}