Skip to content

Instantly share code, notes, and snippets.

View CMyae's full-sized avatar

Chan Myae Aung CMyae

View GitHub Profile
@CMyae
CMyae / activity_login.xml
Created September 21, 2019 10:25
Rally login screen layout implementation
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/constraint_layout"
android:background="?android:attr/colorBackground"
tools:context=".ui.login.LoginActivity"
@CMyae
CMyae / RallyLineGraphChart.kt
Last active September 18, 2019 09:37
Draw fill bezier curve
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
try {
...
borderPath.set(path)
path.lineTo(width.toFloat(), height.toFloat())
path.lineTo(0f, height.toFloat())
canvas?.drawPath(path, pathPaint)
canvas?.drawPath(borderPath, borderPathPaint)
} catch (e: Exception) {
@CMyae
CMyae / RallyLineGraphChart.kt
Last active September 18, 2019 09:38
Fill background paint for bezier curve
pathPaint.apply {
isAntiAlias = true
style = Paint.Style.FILL
color = fillColor
}
@CMyae
CMyae / RallyLineGraphChart.kt
Last active September 26, 2019 03:00
Border paint object style
borderPathPaint.apply {
isAntiAlias = true
strokeWidth = 8f
style = Paint.Style.STROKE
color = Color.parseColor("#FFFC4F47")
}
@CMyae
CMyae / RallyLineGraphChart.kt
Last active September 18, 2019 09:38
Draw first bezier curve
private fun drawBezierCurve(canvas: Canvas?) {
try {
if (points.isEmpty() && conPoint1.isEmpty() && conPoint2.isEmpty()) return
path.reset()
path.moveTo(points.first().x, points.first().y)
for (i in 1 until points.size) {
@CMyae
CMyae / RallyLineGraphChart.kt
Last active September 18, 2019 09:38
Code snippet for calculating connection points
private fun calculateConnectionPointsForBezierCurve() {
try {
for (i in 1 until points.size) {
conPoint1.add(PointF((points[i].x + points[i - 1].x) / 2, points[i - 1].y))
conPoint2.add(PointF((points[i].x + points[i - 1].x) / 2, points[i].y))
}
} catch (e: Exception) {
}
}
@CMyae
CMyae / RallyLineGraphChart.kt
Last active September 18, 2019 09:38
Code snippet for calculating data points for bezier curve
//Sample Data points -> 50,25,100,80,...(your data to be represented in graph)
private fun calculatePointsForData() {
val bottomY = getLargeBarHeight() - CURVE_BOTTOM_MARGIN
val xDiff = width.toFloat() / data.size
val maxData = data.maxBy { it.amount }!!.amount
for (i in 0 until data.size) {
val y = bottomY - (data[i].amount / maxData * bottomY)