Skip to content

Instantly share code, notes, and snippets.

@pamartineza
Created February 23, 2018 18:30
Embed
What would you like to do?
class FavoritesMemoryCache {
//Bus Stop Favorites
private var busStopFavoritesList: MutableList<BusStopFavorite>?=null
fun retrieveBusStopFavoriteList(): List<BusStopFavorite>? {
if (busStopFavoritesList != null) {
return busStopFavoritesList.toList()
}
return null
}
fun saveBusStopFavoriteList(favorites: List<BusStopFavorite>) {
if (busStopFavoritesList != null) {
busStopFavoritesList?.clear()
busStopFavoritesList?.addAll(favorites)
} else {
busStopFavoritesList = mutableListOf()
busStopFavoritesList?.addAll(favorites)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment