Merge "Stable seek bar positioning"
am: 874b481cdf
Change-Id: I86e8607222ab68cbd2999f65f9a382f9b0d02112
This commit is contained in:
@@ -88,6 +88,7 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
private float mTouchDownX;
|
private float mTouchDownX;
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
private boolean mIsDragging;
|
private boolean mIsDragging;
|
||||||
|
private float mTouchThumbOffset = 0.0f;
|
||||||
|
|
||||||
public AbsSeekBar(Context context) {
|
public AbsSeekBar(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -775,6 +776,14 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
|
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
if (mThumb != null) {
|
||||||
|
final int availableWidth = getWidth() - mPaddingLeft - mPaddingRight;
|
||||||
|
mTouchThumbOffset = (getProgress() - getMin()) / (float) (getMax()
|
||||||
|
- getMin()) - (event.getX() - mPaddingLeft) / availableWidth;
|
||||||
|
if (Math.abs(mTouchThumbOffset * availableWidth) > getThumbOffset()) {
|
||||||
|
mTouchThumbOffset = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isInScrollingContainer()) {
|
if (isInScrollingContainer()) {
|
||||||
mTouchDownX = event.getX();
|
mTouchDownX = event.getX();
|
||||||
} else {
|
} else {
|
||||||
@@ -857,7 +866,8 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
} else if (x < mPaddingLeft) {
|
} else if (x < mPaddingLeft) {
|
||||||
scale = 1.0f;
|
scale = 1.0f;
|
||||||
} else {
|
} else {
|
||||||
scale = (availableWidth - x + mPaddingLeft) / (float) availableWidth;
|
scale = (availableWidth - x + mPaddingLeft) / (float) availableWidth
|
||||||
|
+ mTouchThumbOffset;
|
||||||
progress = mTouchProgressOffset;
|
progress = mTouchProgressOffset;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -866,7 +876,7 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
} else if (x > width - mPaddingRight) {
|
} else if (x > width - mPaddingRight) {
|
||||||
scale = 1.0f;
|
scale = 1.0f;
|
||||||
} else {
|
} else {
|
||||||
scale = (x - mPaddingLeft) / (float) availableWidth;
|
scale = (x - mPaddingLeft) / (float) availableWidth + mTouchThumbOffset;
|
||||||
progress = mTouchProgressOffset;
|
progress = mTouchProgressOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user