package Ġcom . sun ny weather . android . ui . place Ċ Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . Transform ations Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . sun ny weather . android . Log Util Ċ import Ġcom . sun ny weather . android . logic . Repository Ċ import Ġcom . sun ny weather . android . logic . model . Result Ċ Ċ class ĠPlace ViewModel Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġsearch LiveData Ġ= ĠMutable LiveData < String >() ĊĊĠĠĠ Ġval Ġplace List Ġ= ĠArrayList < String >() ĊĊĠĠĠ Ġval Ġplace LiveData Ġ= ĠTransform ations . switch Map ( search LiveData ) Ġ{ Ġcity Ġ-> ĊĠĠĠĠĠĠĠ ĠLog Util . d (" Place ViewModel ", Ġ" switch Map æĸ¹æ³ķ å·² è¢« è°ĥçĶ¨ ") ĊĠĠĠĠĠĠĠ ĠRepository . search Places ( city ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsearch Places ( city : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsearch LiveData . value Ġ= Ġcity ĊĠĠĠĠĠĠĠ ĠLog Util . d (" Place ViewModel ", Ġsearch LiveData . value . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsave Place ( city : ĠString ) Ġ= ĠRepository . save Place ( city ) ĊĊĠĠĠ Ġfun Ġget Saved Place () Ġ= ĠRepository . get Saved Place () ĊĊĠĠĠ Ġfun Ġis Place Saved () Ġ= ĠRepository . is Place Saved () Ċ Ċ }