diff --git a/RangeBarSample/src/main/res/layout/activity_main.xml b/RangeBarSample/src/main/res/layout/activity_main.xml
index 66c9b765..769a35d7 100644
--- a/RangeBarSample/src/main/res/layout/activity_main.xml
+++ b/RangeBarSample/src/main/res/layout/activity_main.xml
@@ -40,7 +40,7 @@
app:mrb_rangeBarPaddingBottom="30dp"
app:mrb_rangeBar_rounded="true"
app:mrb_rightThumbColor="#1E88E5"
- app:mrb_temporaryPins="true"
+ app:mrb_temporaryPins="ON_TOUCH_ONLY"
app:mrb_thumbBoundaryColor="@color/accent"
app:mrb_thumbBoundarySize="2dp"
app:mrb_thumbSize="10dp"
diff --git a/RangeBarSample/src/main/res/layout/recyclerview_item.xml b/RangeBarSample/src/main/res/layout/recyclerview_item.xml
index ef16629f..6e0ed7f8 100644
--- a/RangeBarSample/src/main/res/layout/recyclerview_item.xml
+++ b/RangeBarSample/src/main/res/layout/recyclerview_item.xml
@@ -20,7 +20,7 @@
app:mrb_thumbBoundaryColor="@color/accent"
app:mrb_thumbBoundarySize="2dp"
app:mrb_thumbSize="10dp"
- app:mrb_temporaryPins="true"
+ app:mrb_temporaryPins="ALWAYS"
app:mrb_tickBottomLabels="@array/ticks_labels"
app:mrb_tickDefaultLabel="label"
app:mrb_tickEnd="10"
diff --git a/materialrangebar/src/main/java/com/appyvet/materialrangebar/PinView.java b/materialrangebar/src/main/java/com/appyvet/materialrangebar/PinView.java
index 50f92503..26da4e72 100644
--- a/materialrangebar/src/main/java/com/appyvet/materialrangebar/PinView.java
+++ b/materialrangebar/src/main/java/com/appyvet/materialrangebar/PinView.java
@@ -91,7 +91,7 @@ class PinView extends View {
private float mMaxPinFont = RangeBar.DEFAULT_MAX_PIN_FONT_SP;
- private boolean mPinsAreTemporary;
+ private int mPinsAreTemporary;
private boolean mHasBeenPressed = false;
@@ -127,7 +127,7 @@ public void setFormatter(com.appyvet.materialrangebar.IRangeBarFormatter mFormat
* @param pinsAreTemporary whether to show the pin initially or just the circle
*/
public void init(Context ctx, float y, float pinRadiusDP, int pinColor, int textColor,
- float circleRadius, int circleColor, int circleBoundaryColor, float circleBoundarySize, float minFont, float maxFont, boolean pinsAreTemporary) {
+ float circleRadius, int circleColor, int circleBoundaryColor, float circleBoundarySize, float minFont, float maxFont, int pinsAreTemporary) {
mRes = ctx.getResources();
mPin = ContextCompat.getDrawable(ctx, R.drawable.rotate);
@@ -279,25 +279,27 @@ public void draw(Canvas canvas) {
canvas.drawCircle(mX, mY, mCircleBoundaryRadiusPx, mCircleBoundaryPaint);
//Draw pin if pressed
- if (mPinRadiusPx > 0 && (mHasBeenPressed || !mPinsAreTemporary)) {
- mBounds.set((int) mX - mPinRadiusPx,
- (int) mY - (mPinRadiusPx * 2) - (int) mPinPadding,
- (int) mX + mPinRadiusPx, (int) mY - (int) mPinPadding);
- mPin.setBounds(mBounds);
- String text = mValue;
-
- if (this.formatter != null) {
- text = formatter.format(text);
+ if (mPinsAreTemporary != 2) {
+ if (mPinRadiusPx > 0 && (mHasBeenPressed || (mPinsAreTemporary == 0))) {
+ mBounds.set((int) mX - mPinRadiusPx,
+ (int) mY - (mPinRadiusPx * 2) - (int) mPinPadding,
+ (int) mX + mPinRadiusPx, (int) mY - (int) mPinPadding);
+ mPin.setBounds(mBounds);
+ String text = mValue;
+
+ if (this.formatter != null) {
+ text = formatter.format(text);
+ }
+
+ calibrateTextSize(mTextPaint, text, mBounds.width());
+ mTextPaint.getTextBounds(text, 0, text.length(), mBounds);
+ mTextPaint.setTextAlign(Paint.Align.CENTER);
+ DrawableCompat.setTint(mPin, pinColor);
+ mPin.draw(canvas);
+ canvas.drawText(text,
+ mX, mY - mPinRadiusPx - mPinPadding + mTextYPadding,
+ mTextPaint);
}
-
- calibrateTextSize(mTextPaint, text, mBounds.width());
- mTextPaint.getTextBounds(text, 0, text.length(), mBounds);
- mTextPaint.setTextAlign(Paint.Align.CENTER);
- DrawableCompat.setTint(mPin, pinColor);
- mPin.draw(canvas);
- canvas.drawText(text,
- mX, mY - mPinRadiusPx - mPinPadding + mTextYPadding,
- mTextPaint);
}
super.draw(canvas);
}
diff --git a/materialrangebar/src/main/java/com/appyvet/materialrangebar/RangeBar.java b/materialrangebar/src/main/java/com/appyvet/materialrangebar/RangeBar.java
index 9be7ae5a..3a8fd548 100755
--- a/materialrangebar/src/main/java/com/appyvet/materialrangebar/RangeBar.java
+++ b/materialrangebar/src/main/java/com/appyvet/materialrangebar/RangeBar.java
@@ -247,7 +247,7 @@ public class RangeBar extends View {
private boolean drawTicks = true;
- private boolean mArePinsTemporary = true;
+ private int mArePinsTemporary = 1;
private boolean mOnlyOnDrag = false;
@@ -324,7 +324,7 @@ public Parcelable onSaveInstanceState() {
bundle.putFloat("BAR_PADDING_BOTTOM", mBarPaddingBottom);
bundle.putBoolean("IS_RANGE_BAR", mIsRangeBar);
bundle.putBoolean("IS_ONLY_ON_DRAG", mOnlyOnDrag);
- bundle.putBoolean("ARE_PINS_TEMPORARY", mArePinsTemporary);
+ bundle.putInt("ARE_PINS_TEMPORARY", mArePinsTemporary);
bundle.putInt("LEFT_INDEX", mLeftIndex);
bundle.putInt("RIGHT_INDEX", mRightIndex);
bundle.putInt("MIN_INDEX_DISTANCE", mMinIndexDistance);
@@ -374,7 +374,7 @@ public void onRestoreInstanceState(Parcelable state) {
mBarPaddingBottom = bundle.getFloat("BAR_PADDING_BOTTOM");
mIsRangeBar = bundle.getBoolean("IS_RANGE_BAR");
mOnlyOnDrag = bundle.getBoolean("IS_ONLY_ON_DRAG");
- mArePinsTemporary = bundle.getBoolean("ARE_PINS_TEMPORARY");
+ mArePinsTemporary = bundle.getInt("ARE_PINS_TEMPORARY");
mLeftIndex = bundle.getInt("LEFT_INDEX");
mRightIndex = bundle.getInt("RIGHT_INDEX");
@@ -848,7 +848,7 @@ public void setRangeBarEnabled(boolean isRangeBar) {
* stay
* drawn
*/
- public void setTemporaryPins(boolean arePinsTemporary) {
+ public void setTemporaryPins(int arePinsTemporary) {
mArePinsTemporary = arePinsTemporary;
invalidate();
}
@@ -1479,7 +1479,7 @@ private void rangeBarInit(Context context, AttributeSet attrs) {
mActiveConnectingLineColors = new ArrayList<>(mConnectingLineColors);
mIsRangeBar = ta.getBoolean(R.styleable.RangeBar_mrb_rangeBar, true);
- mArePinsTemporary = ta.getBoolean(R.styleable.RangeBar_mrb_temporaryPins, true);
+ mArePinsTemporary = ta.getInt(R.styleable.RangeBar_mrb_temporaryPins, 1);
mIsBarRounded = ta.getBoolean(R.styleable.RangeBar_mrb_rangeBar_rounded, false);
float density = mDisplayMetrices.density;
@@ -1812,7 +1812,7 @@ private void pressPin(final PinView thumb) {
if (mFirstSetTickCount) {
mFirstSetTickCount = false;
}
- if (mArePinsTemporary) {
+ if (mArePinsTemporary == 2 || mArePinsTemporary == 1) {
ValueAnimator animator = ValueAnimator.ofFloat(0, mExpandedPinRadius);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@@ -1842,7 +1842,7 @@ private void releasePin(final PinView thumb) {
int tickIndex = mBar.getNearestTickIndex(thumb);
thumb.setXValue(getPinValue(tickIndex));
- if (mArePinsTemporary) {
+ if (mArePinsTemporary == 2 || mArePinsTemporary == 1) {
ValueAnimator animator = ValueAnimator.ofFloat(mExpandedPinRadius, 0);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
diff --git a/materialrangebar/src/main/res/values/attrs.xml b/materialrangebar/src/main/res/values/attrs.xml
index caeb288c..ed6e030b 100644
--- a/materialrangebar/src/main/res/values/attrs.xml
+++ b/materialrangebar/src/main/res/values/attrs.xml
@@ -29,7 +29,11 @@
-
+
+
+
+
+