From bd20977ebc7d155b6631971da742ac26e26a44c5 Mon Sep 17 00:00:00 2001
From: arkon <eugcheung94@gmail.com>
Date: Sun, 19 Apr 2020 12:03:51 -0400
Subject: [PATCH] Remove custom preference flow implementation

---
 .../tachiyomi/util/PreferenceExtensions.kt    | 42 -------------------
 1 file changed, 42 deletions(-)
 delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/util/PreferenceExtensions.kt

diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/PreferenceExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/PreferenceExtensions.kt
deleted file mode 100644
index f6b85b33e..000000000
--- a/app/src/main/java/eu/kanade/tachiyomi/util/PreferenceExtensions.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-package eu.kanade.tachiyomi.util
-
-import android.content.SharedPreferences
-import kotlin.coroutines.CoroutineContext
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.channels.awaitClose
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.channelFlow
-import kotlinx.coroutines.flow.flowOn
-
-@ExperimentalCoroutinesApi
-inline fun <reified T> SharedPreferences.getKey(key: String, default: T, dispatcher: CoroutineContext = Dispatchers.Default): Flow<T> {
-    val flow: Flow<T> = channelFlow {
-        offer(getItem(key, default))
-
-        val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, k ->
-            if (key == k) {
-                offer(getItem(key, default)!!)
-            }
-        }
-
-        registerOnSharedPreferenceChangeListener(listener)
-        awaitClose { unregisterOnSharedPreferenceChangeListener(listener) }
-    }
-    return flow
-            .flowOn(dispatcher)
-}
-
-inline fun <reified T> SharedPreferences.getItem(key: String, default: T): T {
-    @Suppress("UNCHECKED_CAST")
-    return when (default) {
-        is String -> getString(key, default) as T
-        is Int -> getInt(key, default) as T
-        is Long -> getLong(key, default) as T
-        is Boolean -> getBoolean(key, default) as T
-        is Float -> getFloat(key, default) as T
-        is Set<*> -> getStringSet(key, default as Set<String>) as T
-        is MutableSet<*> -> getStringSet(key, default as MutableSet<String>) as T
-        else -> throw IllegalArgumentException("Generic type not handled: ${T::class.java.name}")
-    }
-}