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
val path = Path() | |
val paint = Paint() | |
paint.apply { | |
strokeWidth = 20f | |
style = Paint.Style.FILL | |
} | |
path.apply { | |
moveTo(xCenter, yCenter) |
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
override fun onDraw(canvas: Canvas) { | |
super.onDraw(canvas) | |
val path = Path() | |
path.apply { | |
moveTo(shadowSize + cornerRadius, shadowSize + cornerRadius) | |
arcTo(0f, 0f, shadowSize * 2 + 2 * cornerRadius, shadowSize * 2 + 2 * cornerRadius, 180f, 90f, false) | |
moveTo(shadowSize + cornerRadius, shadowSize + cornerRadius) | |
arcTo(shadowSize, shadowSize, shadowSize + 2 * cornerRadius, shadowSize + 2 * cornerRadius, 270f, -90f, false) | |
} | |
canvas.drawPath(path, radialGradientPaint) |
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
class CardView(context: Context, attributeSet: AttributeSet) : View(context, attributeSet) { | |
private var outerWidth = 0f | |
private var outerHeight = 0f | |
private var xCenter = 0f | |
private var yCenter = 0f | |
private var cornerRadius = 10f | |
private var shadowSize = 50f | |
private val shadowStartColor = 0x20000000 | |
private val shadowEndColor = 0x00000000 |
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
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.MediatorLiveData | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Job | |
import kotlinx.coroutines.delay | |
import kotlinx.coroutines.launch | |
fun <T> LiveData<T>.debounce(duration: Long = 1000L, coroutineScope: CoroutineScope) = MediatorLiveData<T>().also { mld -> | |
val source = this |
OlderNewer