Skip to content

Instantly share code, notes, and snippets.

@pamartineza
Created February 23, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamartineza/b38d5f793c13f501e785f6dfb42ae8bb to your computer and use it in GitHub Desktop.
Save pamartineza/b38d5f793c13f501e785f6dfb42ae8bb to your computer and use it in GitHub Desktop.
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