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
@file:Suppress("PackageDirectoryMismatch") | |
package androidx.compose.runtime | |
import androidx.compose.ui.platform.LocalLifecycleOwner | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.Lifecycle.State.CREATED | |
import androidx.lifecycle.Lifecycle.State.STARTED | |
import androidx.lifecycle.flowWithLifecycle | |
import kotlinx.coroutines.flow.Flow |
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.runtime.Composable | |
import androidx.compose.runtime.State | |
import androidx.compose.runtime.collectAsState | |
import androidx.compose.runtime.remember | |
import androidx.compose.ui.platform.LocalLifecycleOwner | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.Lifecycle.State.CREATED | |
import androidx.lifecycle.Lifecycle.State.STARTED | |
import androidx.lifecycle.flowWithLifecycle | |
import kotlinx.coroutines.flow.Flow |
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
@file:OptIn(ExperimentalTypeInference::class) | |
@file:Suppress("unused") | |
import kotlin.experimental.ExperimentalTypeInference | |
inline fun <reified R> R.unless(@BuilderInference block: Guarded<R>.() -> Any?): R = | |
try { | |
val result = Guarded<R>().block() | |
result as? R ?: this | |
} catch (e: Guarded.BreakGuardWithResult) { |
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
@OptIn(ExperimentalCoroutinesApi::class) | |
class ContactViewModel() : ViewModel() { | |
val firstName = MutableStateFlow("") | |
val lastName = MutableStateFlow("") | |
val fullName by DerivedStateFlow { | |
"${+::firstName} ${+::lastName}" | |
} | |
} |
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 android.os.Parcelable | |
import android.util.Size | |
import java.io.Serializable | |
typealias BundleContext = Bundle.() -> Unit | |
/** | |
* ``` | |
* fun example(someParcelable: Parcelable, someOtherBundle: Bundle) { |
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
fun main() { | |
FakeAppFeatures { | |
if (SomeFeature.enabled) { | |
println("some feature is enabled!") | |
} | |
} | |
} | |
sealed class Feature | |
object SomeFeature : Feature() |
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.view.View | |
import android.widget.AdapterView | |
import android.widget.ArrayAdapter | |
import android.widget.Spinner | |
import androidx.databinding.BindingAdapter | |
import androidx.databinding.InverseBindingAdapter | |
import androidx.databinding.InverseBindingListener | |
import com.aidanvii.toolbox.databinding.getTrackedValue | |
import com.aidanvii.toolbox.databinding.trackValue |
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 java.util.ArrayDeque | |
fun mutableNode( | |
value: Int, | |
left: MutableNode? = null, | |
right: MutableNode? = null | |
) = MutableNode(value, left, right) | |
data class MutableNode( | |
val value: Int, |