Skip to content

Instantly share code, notes, and snippets.

View GuilhE's full-sized avatar

Guilherme Delgado GuilhE

View GitHub Profile
@fvilarino
fvilarino / ticker_final.kt
Last active February 9, 2024 16:04
Ticker Final
private val TickerCycleMillis = 150
private object AlphabetMapper {
private val Alphabet = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789•".toList()
val size: Int = Alphabet.size
fun getLetterAt(index: Int): Char = Alphabet[index % size]
fun getIndexOf(letter: Char, offset: Int = 0): TickerIndex {
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.VectorConverter
import androidx.compose.animation.core.spring
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.forEachGesture
// Usage
// PingPongSwitch(
// textFirst = "Ping",
// textSecond = "Pong"
// )
@Composable
fun PingPongSwitch(
state: PingPongSwitchState = rememberPingPongSwitchState(),
textFirst: String,
import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
import java.util.*
import kotlin.reflect.KProperty
/*
* Android Shared Preferences Delegate for Kotlin
*
* Usage:
import org.json.JSONObject
import java.io.File
const val tinyPngApiKey = "<YOUR-API-KEY-GOES-HERE>"
val projectDir = File("<PATH-TOPROJECT-ROOT>")
val supportedExtensions = listOf("png", "jpg")
fun main() {
projectDir.walk().forEach { srcFile ->
if (supportedExtensions.contains(srcFile.extension)) {
@alexforrester
alexforrester / Moshi Kotlin Codegen Example with Custom Adapter
Last active August 28, 2022 19:39
Moshi Kotlin Codegen Example with Custom Adapter
//app build.gradle
apply plugin: 'kotlin-kapt'
...
dependencies {
{
//Moshi Core
implementation "com.squareup.moshi:moshi:1.8.0"
//Moshi Codegen
@polbins
polbins / README.md
Last active June 20, 2022 02:50
Android Studio as default Git Diff Tool

Create Android Studio Command-line Launcher

  1. Open Android Studio
  2. Go to: Tools > Create Command-line Launcher
  3. Leave as default, Press OK

Configure Git to use Android Studio as default Diff Tool

  1. Add the following lines to your .gitconfig
@takahirom
takahirom / EventBus.kt
Last active June 9, 2022 10:21
EventBus by Kotlin coroutine
import kotlinx.coroutines.experimental.channels.BroadcastChannel
import kotlinx.coroutines.experimental.channels.ConflatedBroadcastChannel
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.filter
import kotlinx.coroutines.experimental.channels.map
import kotlinx.coroutines.experimental.launch
import javax.inject.Inject
import javax.inject.Singleton
@apkelly
apkelly / MatrixCompose.kt
Last active September 16, 2021 23:11
Matrix Animation
import android.graphics.Typeface
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
@zsmb13
zsmb13 / publish-mavencentral.gradle
Last active April 21, 2021 07:25
Basic MavenCentral script
apply plugin: 'maven-publish'
apply plugin: 'signing'
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
from sourceSets.main.java.srcDirs