private boolean startDragging(MotionEvent ev, boolean ignoreTrackIfInScrollContainer) { final Rect bounds = mTempRect; mThumb.copyBounds(bounds); // Grow the current thumb rect for a bigger touch area bounds.inset(-mAddedTouchBounds, -mAddedTouchBounds); mIsDragging = (bounds.contains((int) ev.getX(), (int) ev.getY())); if (!mIsDragging && mAllowTrackClick && !ignoreTrackIfInScrollContainer) { // If the user clicked outside the thumb, we compute the current position // and force an immediate drag to it. mIsDragging = true; mDragOffset = (bounds.width() / 2) - mAddedTouchBounds; updateDragging(ev); // As the thumb may have moved, get the bounds again mThumb.copyBounds(bounds); bounds.inset(-mAddedTouchBounds, -mAddedTouchBounds); } if (mIsDragging) { setPressed(true); attemptClaimDrag(); setHotspot(ev.getX(), ev.getY()); mDragOffset = (int) (ev.getX() - bounds.left - mAddedTouchBounds); if (mPublicChangeListener != null) { mPublicChangeListener.onStartTrackingTouch(this); } } return mIsDragging; }
private void stopDragging() { if (mPublicChangeListener != null) { mPublicChangeListener.onStopTrackingTouch(this); } mIsDragging = false; setPressed(false); }
private void notifyProgressChange(float smoothProgress, float targetProgress) { if (null != mOnProgressChangeListener) { mOnProgressChangeListener.onProgressChange(smoothProgress, targetProgress); } }
private void notifyProgress(int value, boolean fromUser) { if (mPublicChangeListener != null) { mPublicChangeListener.onProgressChanged(DiscreteSeekBar.this, value, fromUser); } onValueChanged(value); }