Remove unneeded annotations and some cleanup

This commit is contained in:
len
2016-06-15 17:47:44 +02:00
parent 5ad06df4ac
commit a82e1d0e45
14 changed files with 29 additions and 55 deletions
@@ -10,6 +10,8 @@ import eu.kanade.tachiyomi.R
*/
class PreferenceKeys(context: Context) {
val theme = context.getString(R.string.pref_theme_key)
val rotation = context.getString(R.string.pref_rotation_type_key)
val enableTransitions = context.getString(R.string.pref_enable_transitions_key)
@@ -78,6 +80,8 @@ class PreferenceKeys(context: Context) {
val filterUnread = context.getString(R.string.pref_filter_unread_key)
val automaticUpdateStatus = context.getString(R.string.pref_enable_automatic_updates_key)
fun sourceUsername(sourceId: Int) = "pref_source_username_$sourceId"
fun sourcePassword(sourceId: Int) = "pref_source_password_$sourceId"
@@ -13,7 +13,7 @@ import java.io.IOException
fun <T> Preference<T>.getOrDefault(): T = get() ?: defaultValue()!!
class PreferencesHelper(private val context: Context) {
class PreferencesHelper(context: Context) {
val keys = PreferenceKeys(context)
@@ -32,28 +32,9 @@ class PreferencesHelper(private val context: Context) {
}
}
companion object {
fun clear() = prefs.edit().clear().apply()
fun getLibraryUpdateInterval(context: Context): Int {
return PreferenceManager.getDefaultSharedPreferences(context).getInt(
context.getString(R.string.pref_library_update_interval_key), 0)
}
fun getAutomaticUpdateStatus(context: Context): Boolean {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
context.getString(R.string.pref_enable_automatic_updates), false)
}
@JvmStatic
fun getTheme(context: Context): Int {
return PreferenceManager.getDefaultSharedPreferences(context).getInt(
context.getString(R.string.pref_theme_key), 1)
}
}
fun clear() {
prefs.edit().clear().apply()
}
fun theme() = prefs.getInt(keys.theme, 1)
fun rotation() = rxPrefs.getInteger(keys.rotation, 1)
@@ -147,4 +128,6 @@ class PreferencesHelper(private val context: Context) {
fun filterUnread() = rxPrefs.getBoolean(keys.filterUnread, false)
fun automaticUpdateStatus() = prefs.getBoolean(keys.automaticUpdateStatus, false)
}