Skip to content

Instantly share code, notes, and snippets.

@o4oren
o4oren / RotaryKnobView.kt
Created May 2, 2020 12:37
RotaryKnobView signature
class RotaryKnobView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr), GestureDetector.OnGestureListener {
}
@o4oren
o4oren / attrs.xml
Created May 2, 2020 12:31
Rotary knob attibutes
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="RotaryKnobView">
<attr name="minValue" format="integer" />
<attr name="maxValue" format="integer" />
<attr name="initialValue" format="integer" />
<attr name="knobDrawable" format="reference" />
</declare-styleable>
</resources>
@o4oren
o4oren / rotary_knob_view.xml
Last active May 2, 2020 12:31
rotary_knob_view
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/knobImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
@o4oren
o4oren / calculate.kt
Created April 30, 2020 18:09
calc_angle
private fun calculateAngle(x: Float, y: Float): Float {
val px = (x / width.toFloat()) - 0.5
val py = ( 1 - y / height.toFloat()) - 0.5
var angle = -(Math.toDegrees(atan2(py, px)))
.toFloat() + 90
if (angle > 180) angle -= 360
return angle
}
@o4oren
o4oren / properties.json
Last active November 12, 2018 19:24
properties.json
{
"serverBaseUri": "http://localhost:3000",
"mongoConnectUrl": "mongodb://localhost:27017/",
"dbName": "ahem",
"appListenPort": 3000,
"smtpPort" : 2525,
"emailDeleteInterval" : 3600,
"emailDeleteAge" : 86400,
"allowAutocomplete" : true,
"allowedDomains" : ["my.domain.com"],