-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Individual thumb click listeners #63
Comments
Hi, @viestursGr You cat fix library to this: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
if (isInScrollingContainer() && mDraggingThumbs.size() == 0) {
mTouchDownX = event.getX(pointerIdx);
if (currThumb != null) {
onStartTrackingTouch(currThumb);
setThumbValue(currThumb, getValue(event, currThumb), true);
setHotspot(xx, yy, currThumb);
}
}
break; And add some stuffs in project public class MultiSliderFragmentRange extends Fragment {
private boolean moved = false;
private int start_value = 0;
private int thumb_idx = -1;
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState) {
multiSlider1.setOnThumbValueChangeListener(new MultiSlider.SimpleChangeListener() {
@Override
public void onValueChanged(MultiSlider multiSlider, MultiSlider.Thumb thumb, int
thumbIndex, int value) {
moved |= start_value != value;
thumb_idx = thumbIndex;
}
});
multiSlider1.setOnTrackingChangeListener(new MultiSlider.OnTrackingChangeListener() {
private long pressStartTime;
private long pressEndTime;
@Override
public void onStartTrackingTouch(MultiSlider multiSlider, MultiSlider.Thumb thumb, int value) {
pressStartTime = System.currentTimeMillis();
moved = false;
start_value = value;
thumb_idx = -1;
}
@Override
public void onStopTrackingTouch(MultiSlider multiSlider, MultiSlider.Thumb thumb, int value) {
if (!moved && thumb_idx != -1) {
pressEndTime = System.currentTimeMillis();
final long diff = pressEndTime - pressStartTime;
final long long_duration = ViewConfiguration.getLongPressTimeout();
if (diff > long_duration)
Toast.makeText(getActivity(), "Long Click " + thumb_idx, Toast.LENGTH_SHORT).show();
else
Toast.makeText(getActivity(), "Click " + thumb_idx, Toast.LENGTH_SHORT).show();
}
}
}); It's ugly solution, but if you can create better, pls make pull request. |
Made an incomplete solution in few hours, not the best, but could work for now. I'll improve it and test it later. Check out my fork (won't make pull request until it's better unless you really want it) |
@viestursGr I looked at your code. I think that the library requires refactoring for more flexibility and simplify add new features for thumbs. P.S. Some time ago I started prototyping binding view for thumbs in this branch, but I don't have time to resume work. I specially made external class for Thumbs, because part of Thumb's logic should be completely independent from slider. I thinking about base object (with few basic methods for slider), which user can inherit and add to slider. |
So far I didn't find a way how to put on click listener on individual thumbs. The user case I have is that each individual thumb should be able to disable itself by press on the respective thumb. Hence individual thumb on click listeners are needed. Unless there is a hidden functionality I am not aware off and you don't have any plans for it, I could try making such functionality. Either way, response would be welcomed (and advice)!
The text was updated successfully, but these errors were encountered: