Skip to content

Instantly share code, notes, and snippets.

View TylerMcCraw's full-sized avatar

Tyler McCraw TylerMcCraw

View GitHub Profile
@TylerMcCraw
TylerMcCraw / SharedPreferencesExtensions.kt
Created October 27, 2022 04:49 — forked from orwir/SharedPreferencesExtensions.kt
Kotlin extensions for shared preferences
import android.content.Context
import android.content.SharedPreferences
import kotlin.reflect.KProperty
/**
* Creates delegate for property from [prefs] with the key presented as className+propertyName.
* @param T type of the property
* @param defaultValue is used if property not set
* @return wrapper for property accessors
*/
@TylerMcCraw
TylerMcCraw / Parallax.kt
Created May 26, 2022 19:47 — forked from surajsau/ParallaxScreen.kt
Parallax effect with Jetpack Compose
val context = LocalContext.current
val scope = rememberCoroutineScope()
var data by remember { mutableStateOf<SensorData?>(null) }
DisposableEffect(Unit) {
val dataManager = SensorDataManager(context)
dataManager.init()
scope.launch {
@TylerMcCraw
TylerMcCraw / WidgetWithAccelerometer.kt
Created March 4, 2022 18:47 — forked from PSPanishetti/WidgetWithAccelerometer.kt
Spaghetti code for working widget that attached to accelerometer in android.
import android.content.Context
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*