Slide 49
Slide 49 text
• ۠ Ѫب оמ!
• ViewGroup ߄Չ ٸ݃ ViewModel ాܳ ߉ਸ ࣻ ب۾ View ஏীࢲ ഐೡ ࣻ ח
ಌ ೣࣻ
internal fun createVerticalCenterPublisher(layout: View): Observable =
Observable.create { emitter ->
emitter.onNext(layout.bottom - layout.top)
val callback = View.OnLayoutChangeListener { _, _, top, _, bottom, _, _, _, _ ->
emitter.onNext(bottom - top)
}
layout.addOnLayoutChangeListener(callback)
emitter.setCancellable {
layout.removeOnLayoutChangeListener(callback)
}
}.subscribeOn(AndroidSchedulers.mainThread())
.throttleLatest(100, TimeUnit.MILLISECONDS, true)
.map { it / 2 }