Closed CsabaZz closed 6 years ago
Hi @CsabaZz, You can change thumb's props before redraw it. For example set min/max values depend on logic of your app.
In your case you can extend logic OnValueChangeBefore and OnValueChangeAfter
@bmx666 I don't find those interfaces. Can you help me please? I'm using the v1.3 version.
Anyway, my logic is I have a TextView positioned above the slider, and I'm moving the TextView as how the Thumb is moving. So I added a MultiSlider.OnThumbValueChangeListener to the MultiSlider view, and positioning the TextView inside the listener like this:
@Override
public void onValueChanged(MultiSlider multiSlider, MultiSlider.Thumb thumb, int thumbIndex, int value) {
int left = mBuyInAmountSlider.getThumb(0).getThumb().getBounds().left;
int width = mBuyInAmountSlider.getThumb(0).getThumb().getBounds().width();
mBuyInAmountMinText.setText(String.valueOf(mBuyInAmountSlider.getThumb(0).getValue()));
mBuyInAmountMinText.setTranslationX((left + (width / 2)) - (mBuyInAmountMinText.getMeasuredWidth() / 2));
// there's a MaxText view as well which uses the getThumb(1)
}
My problem with this solution is that the listener called before the Thumb is updated, so
int left = mBuyInAmountSlider.getThumb(0).getThumb().getBounds().left;
will return me the previous value, not the latest one.
Maybe you looking something this #50?
I merged branch thumb-binder-dev with master, you can check
Sounds similar...
Added
compile 'io.apptik.widget:multislider:1.3.1-SNAPSHOT'
but does not seem that the underline code has changed, I can compile the project without the need of change the implementation of the listener as you suggested. :(
@CsabaZz, download source code of library and include in your app.
OK, thx. I thought it's available as gradle dependency.
Edit: I don't see the new interface neither in master nor in thumb-binder-dev branches. Did you updated the source on Github? The latest changes was made 10 days ago, it was a dependency configuration change and cleanup.
@CsabaZz, for thumb-binder-dev branch you don't need change library interface. Just bind textview to thumb (see example)
I'll do it, thanks!
Sorry for not answering earlier. Seems working fine with the binding code, and I could remove the call of translationX method since it is done by the lib - it means much cleaner code. :)
Can we change the order of these calls please, so the thumb is updated and then call we the listener? Thus we will know the new parameters of the Thumb, like the new left/right position of the thumb.
So,
Should be