This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.halfcircleprogresscompose | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.aspectRatio | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.offset | |
import androidx.compose.foundation.layout.padding | |
import androidx.compose.foundation.layout.size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class RotationState(val pitch: Float, val roll: Float) | |
@Composable | |
fun observeDeviceRotation(): RotationState { | |
val rotationState = remember { mutableStateOf(RotationState(0f, 0f)) } | |
val sensorManager = LocalContext.current.getSystemService(Context.SENSOR_SERVICE) as SensorManager | |
val accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) | |
val magnetometer = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) | |
val rotationMatrix = FloatArray(9) | |
val orientationAngles = FloatArray(3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.composecoolcircleanim.ui.demo | |
import androidx.compose.animation.core.CubicBezierEasing | |
import androidx.compose.animation.core.Easing | |
import androidx.compose.animation.core.LinearOutSlowInEasing | |
import androidx.compose.animation.core.RepeatMode | |
import androidx.compose.animation.core.animateFloat | |
import androidx.compose.animation.core.infiniteRepeatable | |
import androidx.compose.animation.core.rememberInfiniteTransition | |
import androidx.compose.animation.core.tween |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.animation.core.LinearOutSlowInEasing | |
import androidx.compose.animation.core.RepeatMode | |
import androidx.compose.animation.core.animateFloat | |
import androidx.compose.animation.core.infiniteRepeatable | |
import androidx.compose.animation.core.rememberInfiniteTransition | |
import androidx.compose.animation.core.tween | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.layout.requiredSize | |
import androidx.compose.runtime.Composable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.composegraphicslayerplayground | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.animation.core.CubicBezierEasing | |
import androidx.compose.animation.core.LinearEasing | |
import androidx.compose.animation.core.RepeatMode | |
import androidx.compose.animation.core.animateFloat | |
import androidx.compose.animation.core.animateFloatAsState |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'com.android.application' | |
id 'org.jetbrains.kotlin.android' | |
id 'kotlin-kapt' | |
id 'dagger.hilt.android.plugin' | |
} | |
android { | |
compileSdk 32 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.util.Log | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleObserver | |
import androidx.lifecycle.OnLifecycleEvent | |
object IndentProvider { | |
private var depth = 0 | |
private const val SPACE = " " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Clipboard.onChanged(block: (String?) -> Unit) { | |
addFlavorListener { e -> block((e.source as Clipboard).clipboardString) } | |
} | |
var Clipboard.clipboardString: String? | |
set(value) { | |
val ss = StringSelection(value) | |
setContents(ss, ss) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/52441962 | |
fun String.runCommand( | |
workingDir: File = File("."), | |
timeoutAmount: Long = 60, | |
timeoutUnit: TimeUnit = TimeUnit.SECONDS, | |
onErrorReturn: (Throwable) -> String = { "error: ${it.message}" } | |
): String { | |
val result = runCatching { | |
val parts = this.split("\\s".toRegex()) | |
val proc = ProcessBuilder(*parts.toTypedArray()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.mvvmlab | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import androidx.databinding.DataBindingUtil | |
import androidx.databinding.ObservableBoolean | |
import androidx.databinding.ObservableField | |
import androidx.databinding.ObservableInt | |
import androidx.lifecycle.* | |
import com.example.mvvmlab.databinding.ActivityMainBinding |
NewerOlder