allow removing favorites by long pressing them + Remove

This commit is contained in:
tibbi
2017-12-30 19:08:42 +01:00
parent d21b3e7c4d
commit 5efc2fadb6
2 changed files with 30 additions and 0 deletions

View File

@ -44,4 +44,20 @@ class Config(context: Context) : BaseConfig(context) {
var favorites: Set<String>
get() = prefs.getStringSet(FAVORITES, HashSet<String>())
set(favorites) = prefs.edit().remove(FAVORITES).putStringSet(FAVORITES, favorites).apply()
fun addFavorite(id: String) {
addFavorites(HashSet<String>(Arrays.asList(id)))
}
private fun addFavorites(favs: Set<String>) {
val currFavorites = HashSet<String>(favs)
currFavorites.addAll(favs)
favorites = currFavorites
}
fun removeFavorites(favs: Set<String>) {
val currFavorites = HashSet<String>(favorites)
currFavorites.removeAll(favs)
favorites = currFavorites
}
}