I'm currently using the Android-ReactiveLocation Library (Github). The LastKnownLocationObservable
(Code) is working as intended. I'm using a flatMap
to fetch nearby stations from a db and (because of realm) I'm creating a model from the data. So I have a list of items and I'm creating the new Observable in flatMap
with Observable.from(data)
.
Then I want to sort the locations, filter them and group them.
.toSortedList()
.flatMap { Observable.from(it) }
.filter { it.distance <= (maxDistance.toDouble() * 1000) }
.groupBy { //Group the stations in categories
if (it.distance <= maxDistance && it.favorite) {
"nearbyFavorite"
} else if (it.favorite) {
"outOfReachFavorite"
} else {
"nearby"
}
}
However the onComplete is never called when I subscribe to the Observable. The Observable just stalls at toSortedList()
.
The Subscribe:
.subscribe(object: Subscriber<GroupedObservable<String, NearbyLocationItem>>() {
override fun onNext(p0: GroupedObservable<String, NearbyLocationItem>?) {
val locationItems = ArrayList<NearbyLocationItem>()
p0.subscribe { loc ->
locationItems.add(loc)
}
locations.put(p0.key, locationItems)
}
override fun onCompleted() {
Log.d(javaClass.simpleName, "Never called")
}
override fun onError(p0: Throwable?) {
}
}