Skip to content

Commit

Permalink
Added pointer_halo_color_ontouch to the attributes that can be set. T…
Browse files Browse the repository at this point in the history
…his way the halo can have a different color when touched, in addition to a custom transparency (alpha).
  • Loading branch information
devadvance committed Feb 8, 2014
1 parent 8a83724 commit b3379a2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/com/devadvance/circularseekbar/CircularSeekBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class CircularSeekBar extends View {
private static final int DEFAULT_CIRCLE_PROGRESS_COLOR = Color.argb(235, 74, 138, 255);

This comment has been minimized.

Copy link
@sud007

sud007 Feb 10, 2014

@devadvance is it possible to let the Seekbar go roll infinitely like a music knob?

private static final int DEFAULT_POINTER_COLOR = Color.argb(235, 74, 138, 255);
private static final int DEFAULT_POINTER_HALO_COLOR = Color.argb(135, 74, 138, 255);
private static final int DEFAULT_POINTER_HALO_COLOR_ONTOUCH = Color.argb(135, 74, 138, 255);
private static final int DEFAULT_CIRCLE_FILL_COLOR = Color.TRANSPARENT;
private static final int DEFAULT_POINTER_ALPHA = 135;
private static final int DEFAULT_POINTER_ALPHA_ONTOUCH = 100;
Expand Down Expand Up @@ -171,6 +172,11 @@ public class CircularSeekBar extends View {
* Holds the color value for {@code mPointerHaloPaint} before the {@code Paint} instance is created.
*/
private int mPointerHaloColor = DEFAULT_POINTER_HALO_COLOR;

/**
* Holds the color value for {@code mPointerHaloPaint} before the {@code Paint} instance is created.
*/
private int mPointerHaloColorOnTouch = DEFAULT_POINTER_HALO_COLOR_ONTOUCH;

/**
* Holds the color value for {@code mCirclePaint} before the {@code Paint} instance is created.
Expand Down Expand Up @@ -373,6 +379,15 @@ private void initAttributes(TypedArray attrArray) {
mPointerHaloColor = DEFAULT_POINTER_HALO_COLOR;
}
}

tempColor = attrArray.getString(R.styleable.CircularSeekBar_pointer_halo_color_ontouch);
if (tempColor != null) {
try {
mPointerHaloColorOnTouch = Color.parseColor(tempColor);
} catch (IllegalArgumentException e) {
mPointerHaloColorOnTouch = DEFAULT_POINTER_HALO_COLOR_ONTOUCH;
}
}

tempColor = attrArray.getString(R.styleable.CircularSeekBar_circle_color);
if (tempColor != null) {
Expand Down Expand Up @@ -691,6 +706,7 @@ public boolean onTouchEvent(MotionEvent event) {
lastCWDistanceFromStart = cwDistanceFromStart;
mIsMovingCW = true;
mPointerHaloPaint.setAlpha(mPointerAlphaOnTouch);
mPointerHaloPaint.setColor(mPointerHaloColorOnTouch);
recalculateAll();
invalidate();
if (mOnCircularSeekBarChangeListener != null) {
Expand All @@ -707,6 +723,7 @@ public boolean onTouchEvent(MotionEvent event) {
lastCWDistanceFromStart = cwDistanceFromStart;
mIsMovingCW = true;
mPointerHaloPaint.setAlpha(mPointerAlphaOnTouch);
mPointerHaloPaint.setColor(mPointerHaloColorOnTouch);
recalculateAll();
invalidate();
if (mOnCircularSeekBarChangeListener != null) {
Expand Down Expand Up @@ -791,6 +808,7 @@ public boolean onTouchEvent(MotionEvent event) {
break;
case MotionEvent.ACTION_UP:
mPointerHaloPaint.setAlpha(mPointerAlpha);
mPointerHaloPaint.setColor(mPointerHaloColor);
if (mUserIsMovingPointer) {
mUserIsMovingPointer = false;
invalidate();
Expand All @@ -803,6 +821,7 @@ public boolean onTouchEvent(MotionEvent event) {
break;
case MotionEvent.ACTION_CANCEL: // Used when the parent view intercepts touches for things like scrolling
mPointerHaloPaint.setAlpha(mPointerAlpha);
mPointerHaloPaint.setColor(mPointerHaloColor);
mUserIsMovingPointer = false;
invalidate();
break;
Expand Down Expand Up @@ -852,6 +871,7 @@ protected Parcelable onSaveInstanceState() {
state.putInt("mCircleProgressColor", mCircleProgressColor);
state.putInt("mPointerColor", mPointerColor);
state.putInt("mPointerHaloColor", mPointerHaloColor);
state.putInt("mPointerHaloColorOnTouch", mPointerHaloColorOnTouch);
state.putInt("mPointerAlpha", mPointerAlpha);
state.putInt("mPointerAlphaOnTouch", mPointerAlphaOnTouch);

Expand All @@ -871,6 +891,7 @@ protected void onRestoreInstanceState(Parcelable state) {
mCircleProgressColor = savedState.getInt("mCircleProgressColor");
mPointerColor = savedState.getInt("mPointerColor");
mPointerHaloColor = savedState.getInt("mPointerHaloColor");
mPointerHaloColorOnTouch = savedState.getInt("mPointerHaloColorOnTouch");
mPointerAlpha = savedState.getInt("mPointerAlpha");
mPointerAlphaOnTouch = savedState.getInt("mPointerAlphaOnTouch");

Expand Down

0 comments on commit b3379a2

Please sign in to comment.