Reputation: 615
Can anyone point me to the right direction please? I have a RecyclerView which holds a ViewPager who has 2 Fragments. So the view hierarchy kinda looks like these:
Activity
-------RecyclerView
------------------Adapter ↖
------------------------ViewPager ↖
---------------------------------Fragment1 (Radio Buttons) , Fragment2 (Num Picker)
Im trying to retrieve a Click on each Radio Button (Enum Long Value) so I modify Room DB inside the Adapter.
Gif of Use Case:
This is my Open Fragment1 code:
private val publishSubject: PublishSubject<Long> = PublishSubject.create()
open val publishObservable: Observable<Long> = publishSubject
RadioButton.onClick { _ ->
publishSubject.onNext(WINNER.AWAY.value)
println("Fragment 1 = ${WINNER.AWAY.value}") // <-- This prints on Click
}
enum class WINNER(val value: Long) {
LOCAL(1),
DRAW(2),
AWAY(3)
}
In the Adapter:
val fragment1 = Fragment1()
mDisposable.add(fragment1.publishObservable
.subscribeOn(Schedulers.io())
.subscribe { println("Adapter = $it") }) // <-- This doesnt println
I have tried using Bundles, Shared Preferences, Interfaces and even other Horizontal RecyclerView (This one Im not sure how to rlly use with a fixed view)But i do know performance wise RV its better.
Upvotes: 0
Views: 762