Created
May 2, 2020 13:13
-
-
Save o4oren/dafb5d702ad4465e9ad506f6c9672ef7 to your computer and use it in GitHub Desktop.
RotartyKnob initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init { | |
this.maxValue = maxValue + 1 | |
LayoutInflater.from(context) | |
.inflate(R.layout.rotary_knob_view, this, true) | |
context.theme.obtainStyledAttributes( | |
attrs, | |
R.styleable.RotaryKnobView, | |
0, | |
0 | |
).apply { | |
try { | |
minValue = getInt(R.styleable.RotaryKnobView_minValue, 0) | |
maxValue = getInt(R.styleable.RotaryKnobView_maxValue, 100) + 1 | |
divider = 300f / (maxValue - minValue) | |
value = getInt(R.styleable.RotaryKnobView_initialValue, 50) | |
knobDrawable = getDrawable(R.styleable.RotaryKnobView_knobDrawable) | |
knobImageView.setImageDrawable(knobDrawable) | |
} finally { | |
recycle() | |
} | |
} | |
gestureDetector = GestureDetectorCompat(context, this) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment