Apr 17 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Ed T. | has entered the room |
Ed T. |
Hi Mark
|
Mark M. |
hello, Ed!
|
Mark M. |
how can I help you today?
|
Ed T. |
I have two 'widgets' in an event storm....
|
Ed T. |
more or less
|
Apr 17 | 4:00 PM |
Ed T. |
I'm used to doing something like this... with text widgets... .removeTextChangedListener(this);
|
Mark M. |
um, I'm not sure what an "event storm" is
|
Ed T. |
call back events are stomping on each other
|
Ed T. |
I've got two paths a user can do input
|
Ed T. |
one via a percentage slider
|
Ed T. |
and another via direct text edit
|
Ed T. |
seekbar slider
|
Ed T. |
is there a clean way to make a widget not react to changes without nuking the listener?
|
Ed T. |
does that question even make sense
|
Mark M. |
have a smarter listener, perhaps
|
Ed T. |
lol
|
Mark M. |
otherwise, no
|
Mark M. |
if the problem is that the listener is doing something that you don't want done in all situations, encode that logic in the listener
|
Mark M. |
(or in something that the listener invokes, such as a method on your controller/presenter/whatever)
|
Ed T. |
imagine you have the famous TIP application
|
Ed T. |
you can move a slider
|
Ed T. |
that updates the TextEdit field
|
Ed T. |
or you can directly edit the TextEdit field
|
Ed T. |
I need them to be "in sync"
|
Apr 17 | 4:05 PM |
Ed T. |
so the slider can change the text amount
|
Ed T. |
and the text amount can change the slider
|
Ed T. |
I'll just add a flag to short circuit the listener
|
Ed T. |
so much for MVC
|
Ed T. |
I'm use to updating a model
|
Ed T. |
then when I'm doing firing a listener or telling an adapter... to update it's views or fire listeners
|
Mark M. |
I guess that I don't really understand the problem, other than perhaps figuring out the simplest way to implement "debounce" logic with the EditText, so you only update the SeekBar after the user is done typing
|
Ed T. |
the seekbar is at the top
|
Ed T. |
it works fine
|
Ed T. |
the issue happens on the EditText value change
|
Ed T. |
not smooth
|
Ed T. |
flicker and some other odd behaviors
|
Ed T. |
but that is what is causing it
|
Mark M. |
are you attempting to update the SeekBar on every text change?
|
Mark M. |
IOW, for every character typed (or deleted), you try to update the SeekBar immediately?
|
Apr 17 | 4:10 PM |
Ed T. |
yes
|
Ed T. | |
Ed T. |
so imagine that application where you put in an Amount
|
Ed T. |
then a slider for the TIP
|
Ed T. |
moving seekbar changes tip amount as well as shows percentage
|
Ed T. |
then you can also directly edit the tip amount
|
Mark M. |
only update the SeekBar after the user is done typing
|
Ed T. |
doing that would update the SeekBar
|
Mark M. |
where "done typing" is determined by "have not received a new text-change event after X milliseconds", for some value of X that works for you via experimentation (e.g., 500)
|
Mark M. |
if you happen to be using RxJava, Jake Wharton's RxBinding stuff makes adding this "debounce" logic fairly easy, as I understand it
|
Ed T. |
Thanks Mark
|
Apr 17 | 4:15 PM |
Mark M. |
or, perhaps, use this: https://github.com/gregacucnik/EditableSeekBar
|
Mark M. |
which is a SeekBar/EditText combination widget
|
Mark M. |
or, examine that library's code and see how it handles debounce
|
Apr 17 | 4:30 PM |
Ed T. | has left the room |
Apr 17 | 4:55 PM |
Mark M. | turned off guest access |