Open mohsin opened 4 years ago
What listener would you use without RxJava for this?
On Sat, Feb 29, 2020, at 4:18 PM, Saifur Rahman Mohsin wrote:
I see that there is a consumer https://github.com/JakeWharton/RxBinding/blob/master/rxbinding/src/main/java/com/jakewharton/rxbinding3/view/ViewVisibilityConsumer.kt to set the view's visibility but I couldn't find an observable variant for the same. I'm trying to do something like this (for now I used a workaround but ideally an observable that emits visibility changes would be the best for this job):
mainLayout.visibility() .subscribe ({ if(it == View.VISIBLE) { (itemWhichShouldFillLayout.layoutParams as LinearLayout.LayoutParams).weight = 0.65f } else { (itemWhichShouldFillLayout.layoutParams as LinearLayout.LayoutParams).weight = 0.8f } })
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JakeWharton/RxBinding/issues/543?email_source=notifications&email_token=AAAQIEKOMZECMITT6UR4QLDRFF5Q7A5CNFSM4K66MFNKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IRNS3NQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAQIELH7VCB2YHQ6VKWXB3RFF5Q7ANCNFSM4K66MFNA.
Like I said, I wrote a workaround to solve this for me without using any listener coz my specific application needed to check visibility only when a button was clicked so I coded it to recheck visibility every time the button click occurred and made the relevant views visible or gone based on an if condition. But I’m sure it would be good to have a hot observable in the view class for this.
But as per the Android docs I believe there is one onVisibility Changed listener for this.
Like I said, I wrote a workaround to solve this for me without using any listener coz my specific application needed to check visibility only when a button was clicked so I coded it to recheck visibility every time the button click occurred and made the relevant views visible or gone based on an if condition. But I’m sure it would be good to have a hot observable in the view class for this.
But as per the Android docs I believe there is one onVisibility Changed listener for this.
Same issue. This listener is a protected function. Seems cannot write a kt extension to observe the change. Any ideas?
I see that there is a consumer to set the view's visibility but I couldn't find an observable variant for the same. I'm trying to do something like this (for now I used a workaround but ideally an observable that emits visibility changes would be the best for this job):
secondItem.visibility() .subscribe ({ if(it == View.VISIBLE) { (itemWhichShouldFillLayout.layoutParams as LinearLayout.LayoutParams).weight = 0.65f } else { (itemWhichShouldFillLayout.layoutParams as LinearLayout.LayoutParams).weight = 0.8f } })
Hola []()@hola
I see that there is a consumer to set the view's visibility but I couldn't find an observable variant for the same. I'm trying to do something like this (for now I used a workaround but ideally an observable that emits visibility changes would be the best for this job):