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
/** | |
* Fork of AppCompat ContextThemeWrapper (barely) to correctly support applying override | |
* configurations – all the features we don't need are dropped, it always extends the base context's | |
* theme, the theme can't be set explicitly, and it adds one critical piece of functionality: the new | |
* theme is [rebased][Theme.rebase] after being cloned from the base context's theme. | |
*/ | |
open class ContextConfigThemeWrapper( | |
base: Context, | |
private val overrideConfiguration: Configuration | |
) : ContextWrapper(base) { |
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.desktop.ui.tooling.preview.Preview | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.Row | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.material.Checkbox | |
import androidx.compose.material.MaterialTheme | |
import androidx.compose.material.Surface | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.* |
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
// Paste this code into shaders.skia.org | |
float tileSize = 12; | |
float dotMinDiameter = 9; | |
vec2 maxRedShift = vec2(-2, 3); | |
vec2 maxGreenShift = vec2(2.5, 0); | |
vec2 maxBlueShift = vec2(1, -2); | |
half3 baseColor = half3(0, 0, 0); | |
half4 main(vec2 fragcoord) { |
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 <C> ChipField( | |
chips: List<C>, | |
chipContent: @Composable (C) -> Unit. | |
modifier: Modifier = Modifier | |
) { | |
SelectionContainer( | |
allowCursor = true, | |
// some sort of callback or hoisted state for reading/mutating selection | |
modifier.textFieldFocusable() | |
) { |
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.animation.PhysicsBuilder | |
import androidx.animation.Spring.DampingRatioHighBouncy | |
import androidx.animation.Spring.StiffnessLow | |
import androidx.compose.Composable | |
import androidx.compose.Model | |
import androidx.compose.remember | |
import androidx.ui.animation.animate | |
import androidx.ui.core.DrawClipToBounds | |
import androidx.ui.core.Text | |
import androidx.ui.core.drawLayer |
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.zachklipp.coroutines | |
import kotlinx.coroutines.experimental.DisposableHandle | |
import kotlinx.coroutines.experimental.intrinsics.startCoroutineCancellable | |
import kotlinx.coroutines.experimental.selects.SelectClause0 | |
import kotlinx.coroutines.experimental.selects.SelectClause1 | |
import kotlinx.coroutines.experimental.selects.SelectClause2 | |
import kotlinx.coroutines.experimental.selects.SelectInstance | |
/** |
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
interface Host { | |
suspend fun getMovies(): List<Movies> | |
suspend fun setWatched(movie: Movie): Boolean | |
close() | |
} | |
class HostImpl( | |
// You could have a different WorkerPool for each system you need to talk to | |
// that has its own throttling requirements. | |
private val workerPool: WorkerPool |
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 kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import kotlin.coroutines.CoroutineContext | |
import kotlin.coroutines.coroutineContext | |
class DatabaseExecutor( | |
nWorkers: Int, | |
context: CoroutineContext | |
) { |
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
class CoroutineNamesTest { | |
@Test fun coroutineNames() { | |
runBlocking(CoroutineName("parent")) { | |
println("parent: $coroutineContext") | |
launch { | |
println("unnamed child: $coroutineContext") | |
} | |
launch(CoroutineName("named child")) { |