Skip to content

Instantly share code, notes, and snippets.

@sdetilly
sdetilly / UsingFold.kt
Created December 17, 2025 16:22
Working with .fold
data class User(val name: String)
data class UserWithInterest(val user: User, val interests: List<String>)
class MyRepository {
private val interestsMap = mapOf(
"Sarah" to listOf(
"Skiing",
"Bingo"
),
"Tim" to listOf(
@sdetilly
sdetilly / AnimatedContentDemo.kt
Created December 15, 2025 20:31
Animated Content with Crossfade and expand/collapse
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.SystemBarStyle
import androidx.activity.viewModels
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
@sdetilly
sdetilly / MemoryTestActivity
Created November 12, 2025 18:09
Use this to test the memory profiler on android studio using either fetchData or fetchData2
import android.os.Bundle
import android.os.Debug
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.SystemBarStyle
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
@sdetilly
sdetilly / aarRepackage-build.gradle.kts
Created October 31, 2025 15:27
Repackaging conflicting aars
plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
}
configurations {
create("aarToRepackage")
}
dependencies {
// Point to the original Lib-A AAR
@sdetilly
sdetilly / SegmentedControl.kt
Last active October 29, 2025 14:37
SegmentedControl animation
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.SystemBarStyle
import androidx.compose.animation.Crossfade
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
@sdetilly
sdetilly / gist:a169b49fee7e3ce377ae8fb8c84fad0b
Created October 19, 2025 15:09
Using DrawScope to create custom overlays
data class Message(
val id: Int,
val text: String,
val isFromMe: Boolean,
var reaction: String? = null
)
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@sdetilly
sdetilly / AnimatedVisibilityWithNull
Created October 3, 2025 18:42
How to use Animated visibility with null values
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.expandIn
import androidx.compose.animation.fadeIn
@sdetilly
sdetilly / MainActivity.kt
Created October 1, 2025 13:06
Shared Element Demo
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.SharedTransitionLayout
import androidx.compose.animation.SharedTransitionScope
import androidx.compose.animation.core.tween
@sdetilly
sdetilly / KoinServiceSetup.kt
Created July 31, 2023 19:28
Koin Service Setup
// Common Code
interface Bootstrap {
val gpsService: GPSService
}
class KoinBootstrap : KoinComponent {
fun initDependencies(bootstrap: Bootstrap) = startKoin {
configureKoin(bootstrap)
}
}
@sdetilly
sdetilly / RestaurantFinder.kt
Last active July 31, 2023 18:59
RestaurantFinder
fun restaurantsNearUser(): Flow<List<Restaurant>> =
flow {
emit(null)
gpsService.currentUserLocation().also { location ->
emit(location)
}
}
.map { userLocation ->
buildRestaurantList(userLocation)
}