0

MVVMパターンでジョギングアプリを作りたいのですが、LocationListenerをどこに置くかがわかりません。LocationListener を MVVM と一緒に正しく使用するには? リポジトリ?テスト用に、このようなものを作成しました。動作確認のみのテストで問題なく動いていますが、これはMVVMではありません。

class GPSLocationListener(private var activity: MainActivity) : LocationListener {

lateinit var location: Location

override fun onLocationChanged(location: Location?) {
    val speed : Double = (location!!.speed * 3600 / 1000).toDouble()
    activity.updateUI(speed)
    this.location = location
}

override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun onProviderEnabled(provider: String?) {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun onProviderDisabled(provider: String?) {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
4

1 に答える 1