These snippets should mostly work, but if you want a fully compiling project then please check out my ShoppingApp project here: https://github.com/handstandsam/ShoppingApp in that project there is a shopping-cart
module and shopping-cart-sqldelight
module that are used to implement the DB functionality.
This file contains 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
//Sam Edwards | |
//expo.cpp | |
//Include statements | |
#include<iomanip.h> | |
#include<iostream.h> | |
#include<math.h> | |
#include<string.h> | |
#include<process.h> | |
#include<conio.h> | |
#include<stdlib.h> |
This file contains 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
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="..."> | |
<!-- To get access to the NFC hardware, you have to apply for permission in the manifest. --> | |
<uses-permission android:name="android.permission.NFC" /> | |
<uses-permission android:name="android.permission.VIBRATE" /> | |
<application> | |
<activity | |
android:name=".ui.ContactlessActivity" |
This file contains 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
/** Whether the Oven command was successful, or something happened */ | |
sealed class OvenResult { | |
object Success : OvenResult() | |
data class Failure(val e: Exception) : OvenResult() | |
} | |
/** Class we will use Mockito to Mock */ | |
class Oven { | |
fun setTemperatureFahrenheit(tempF: Int) { | |
TODO("Implementation Goes Here") |
This file contains 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.handstandsam.mutablestateflow | |
import kotlinx.coroutines.flow.MutableStateFlow | |
import kotlinx.coroutines.test.runBlockingTest | |
import org.junit.Test | |
class UseImmutableDataWithMutableStateFlow { | |
data class SomePojo(var name: String = "placeholder") |
This file contains 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.os.Bundle | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleRegistry | |
import androidx.savedstate.SavedStateRegistry | |
import androidx.savedstate.SavedStateRegistryController | |
import androidx.savedstate.SavedStateRegistryOwner | |
internal class MyLifecycleOwner : SavedStateRegistryOwner { | |
private var mLifecycleRegistry: LifecycleRegistry = LifecycleRegistry(this) | |
private var mSavedStateRegistryController: SavedStateRegistryController = SavedStateRegistryController.create(this) |
This file contains 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
@Composable | |
fun DropdownComposable(items: List<String> = listOf("A", "B", "C"), onClick: (String) -> Unit) { | |
var expanded by remember { mutableStateOf(false) } | |
var selectedIndex by remember { mutableStateOf(0) } | |
Box( | |
modifier = Modifier | |
.wrapContentSize(Alignment.TopStart) | |
) { | |
Text( | |
text = state.value.eventName, |
This file contains 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
/** | |
* JVM Implementation from KotlinX Coroutines | |
* https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/src/channels/Actor.kt#L31-L124 | |
*/ | |
@ObsoleteCoroutinesApi | |
public fun <E> CoroutineScope.actor( | |
context: CoroutineContext = EmptyCoroutineContext, | |
capacity: Int = 0, // todo: Maybe Channel.DEFAULT here? | |
start: CoroutineStart = CoroutineStart.DEFAULT, | |
onCompletion: CompletionHandler? = null, |
This file contains 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.Animatable | |
import androidx.compose.animation.core.LinearEasing | |
import androidx.compose.animation.core.tween | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.border | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.height | |
import androidx.compose.foundation.layout.padding |