-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Allow customizing the position of ray start speed #248
base: master
Are you sure you want to change the base?
Conversation
withEffects = a.getBoolean(R.styleable.RaySpeedometer_sv_withEffects, withEffects) | ||
rayStartSpeed = | ||
a.getFloat(R.styleable.RaySpeedometer_sv_rayStartSpeed, Float.NEGATIVE_INFINITY).let { | ||
if (it == Float.NEGATIVE_INFINITY) null else it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of hacky but I couldn't find a good way in the attributes API to allow null values.
} | ||
|
||
for (i in getStartDegree()..getEndDegree() step degreeBetweenMark) { | ||
val drawWith = if (!rangeCheck.contains(i)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part I tried to clean up. These lines seemed to be present in both parts of the conditional
canvas.drawPath(markPath, rayMarkPaint)
canvas.rotate(degreeBetweenMark.toFloat(), size * .5f, size * .5f)
i += degreeBetweenMark
The only thing that really looked to be changing was the paint.
@@ -30,6 +30,7 @@ open class RaySpeedometer @JvmOverloads constructor( | |||
private var withEffects = true | |||
|
|||
private var degreeBetweenMark = 5 | |||
var rayStartSpeed: Float? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value the ray will be drawn from. This allows the ray to be drawn backwards. null preserves current functionality and draws from startSpeed.
One of my users had commented that they didn't like that the ray speedometer drew from the beginning of the gauge instead of at 0. This looked strange especially when it was an arbitrary negative number. I added an option to set a start value. I left the current functionality but you can now set
app:sv_rayStartSpeed="0"
to draw from 0 and it will draw backwards if the value is less than 0.You can see how it looks when starting from 0 instead of the minimum value.