Skip to content

Instantly share code, notes, and snippets.

View titoaesj's full-sized avatar
🇧🇷

Tito Albino Evangelista da Silva Junior titoaesj

🇧🇷
View GitHub Profile
@titoaesj
titoaesj / MainDispatcherRule.kt
Created May 24, 2023 11:28
Android Unit Tests Rule
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestDispatcher
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.rules.TestRule
import org.junit.rules.TestWatcher
import org.junit.runner.Description
@titoaesj
titoaesj / AnimatedCurrencyValue.kt
Last active December 2, 2021 12:34
Compose component animate text crescent Currency $1.0..N - [Android]
@OptIn(ExperimentalAnimationApi::class)
@Composable
private fun AnimatedCurrencyValue(
targetValue: Double,
delayOfDigits: Long = 100L,
locale: Locale = Locale.US
) {
// create variable for current time
var currentValue by remember {
@titoaesj
titoaesj / AnimatedDoubleValue.kt
Last active December 2, 2021 12:34
Compose component animate text crescent Double 0.0..N - [Android]
@OptIn(ExperimentalAnimationApi::class)
@Composable
private fun AnimatedDoubleValue(
targetValue: Double,
delayOfDigits: Long = 100L
) {
// create variable for current time
var currentValue by remember {
mutableStateOf(0.0)
@titoaesj
titoaesj / AnimatedIntValue.kt
Last active December 2, 2021 12:33
Compose component animate text crescent Integer 0..N - [Android]
@OptIn(ExperimentalAnimationApi::class)
@Composable
private fun AnimatedIntValue(
targetValue: Int,
delayOfDigits: Long = 100L
) {
// create variable for current time
var currentValue by remember {
mutableStateOf(0)
class CustomArcShape : Shape {
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
return Outline.Generic(
path = drawArcPath(size = size)
)
}
@titoaesj
titoaesj / ChipVerticalGrid.kt
Last active December 2, 2021 12:21
Android Compose - ChipVerticalGrid
@Composable
fun ChipVerticalGrid(
modifier: Modifier = Modifier,
spacing: Dp,
content: @Composable () -> Unit
) {
Layout(
content = content,
modifier = modifier
) { measurables, constraints ->
# Visual Studio Code
sudo ln -s /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code /usr/local/bin/code
# Sublime Text
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
@titoaesj
titoaesj / sonarqube.gradle
Created December 7, 2020 12:55
Configuração SonarQube Android
apply plugin: 'org.sonarqube'
sonarqube {
properties {
property "sonar.host.url", "http://localhost:9000"
property "sonar.projectKey", "br.com.appfut"
property "sonar.projectName", "AppFut"
property "sonar.sources", "src/main/java/"
property "sonar.binaries", "build"
property "sonar.language", "koltin"
@titoaesj
titoaesj / jacoco.gradle
Last active December 7, 2020 12:47
Configuração Jacoco Android
apply plugin: 'jacoco'
jacoco {
toolVersion = '0.8.6' //Use latest version
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
@titoaesj
titoaesj / RecyclerViewExtension.kt
Created June 18, 2019 13:14 — forked from arcadefire/RecyclerViewExtension.kt
Add addOnItemClickListener easily to a RecyclerView using Kotlin
import android.support.v7.widget.RecyclerView
import android.view.View
interface OnItemClickListener {
fun onItemClicked(position: Int, view: View)
}
fun RecyclerView.addOnItemClickListener(onClickListener: OnItemClickListener) {
this.addOnChildAttachStateChangeListener(object: RecyclerView.OnChildAttachStateChangeListener {
override fun onChildViewDetachedFromWindow(view: View?) {