Skip to content

Instantly share code, notes, and snippets.

View samoylenkodmitry's full-sized avatar
🎯
Focusing

Dmitry Samoylenko samoylenkodmitry

🎯
Focusing
View GitHub Profile
@samoylenkodmitry
samoylenkodmitry / Shader.kt
Created June 20, 2024 12:56
Jetpack Compose Ripple shader
// Credits https://kotlinlang.slack.com/archives/CJLTWPH7S/p1718623704772239
import android.graphics.RenderEffect
import android.graphics.RuntimeShader
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@samoylenkodmitry
samoylenkodmitry / .editorconfig
Created December 6, 2020 10:17
.editorconfig
[*.{kt,kts}]
# possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely)
indent_size=unset
# true (recommended) / false
insert_final_newline=false
# possible values: number (e.g. 120) (package name, imports & comments are ignored), "off"
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
max_line_length=140
# Comma-separated list of rules to disable (Since 0.34.0)
# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
#https://detekt.github.io/detekt/
build:
maxIssues: 0
excludeCorrectable: false
weights:
# complexity: 2
# LongParameterList: 1
# style: 1
# comments: 1
@samoylenkodmitry
samoylenkodmitry / pre-commit
Last active April 17, 2023 13:13
kotlin_and_java_diff_precommit_hook
#!/bin/bash
# Setting up guide http://dmitrysamoylenko.com/2020/12/06/configure_lints.html
# https://github.com/checkstyle/checkstyle
# https://github.com/pinterest/ktlint
# https://github.com/detekt/detekt
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ]; then
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
@samoylenkodmitry
samoylenkodmitry / PhoneNumberTextWatcher.java
Created December 7, 2016 11:44
This is an implementation of phone number formatter that can be applied to EditText.
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.util.SparseBooleanArray;
import android.view.View;