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
export JAVA_HOME='/Users/afollestad/Library/Java/JavaVirtualMachines/azul-11-ARM64' | |
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk | |
export PATH="$HOME/Library/Android/sdk/tools:$HOME/Library/Android/sdk/platform-tools:$PATH" | |
alias gw="./gradlew " | |
alias dev="cd ~/Development" | |
alias gcm="git commit -am " | |
alias gco="git checkout " | |
alias gpu="git push " | |
alias gpl="git pull " |
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
@file:Suppress("unused", "MemberVisibilityCanBePrivate") | |
package com.afollestad.flow.util | |
import com.google.common.truth.Truth.assertThat | |
import com.google.common.truth.Truth.assertWithMessage | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Dispatchers.Unconfined | |
import kotlinx.coroutines.ExperimentalCoroutinesApi | |
import kotlinx.coroutines.Job |
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 kotlinx.coroutines.* | |
import kotlinx.coroutines.flow.Flow | |
import kotlinx.coroutines.flow.channelFlow | |
import kotlinx.coroutines.flow.launchIn | |
import kotlinx.coroutines.flow.onEach | |
@FlowPreview | |
@ExperimentalCoroutinesApi | |
fun main() { | |
runBlocking { |
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
class CommandLineParser( | |
private val input: String | |
) : Iterator<String> { | |
private var lastIndex: Int = 0 | |
override fun hasNext(): Boolean = lastIndex in 0..input.length - 2 | |
override fun next(): String { | |
val value = StringBuilder() | |
var quoteStarter: Char? = null |
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.graphics.Typeface | |
import androidx.annotation.CheckResult | |
import java.lang.Exception | |
/** @author Aidan Follestad (@afollestad) */ | |
object TypefaceHelper { | |
private val cache = hashMapOf<String, Typeface>() | |
/** | |
* Gets a typeface by its family name. Automatically statically caches it to avoid |
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.view.View | |
internal object Debouncer { | |
@Volatile private var enabled: Boolean = true | |
private val enableAgain = Runnable { enabled = true } | |
fun canPerform(view: View): Boolean { | |
if (enabled) { | |
enabled = false | |
view.post(enableAgain) |
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
addon-google_apis-google-10 | |
addon-google_apis-google-11 | |
addon-google_apis-google-12 | |
addon-google_apis-google-13 | |
addon-google_apis-google-14 | |
addon-google_apis-google-15 | |
addon-google_apis-google-16 | |
addon-google_apis-google-17 | |
addon-google_apis-google-18 | |
addon-google_apis-google-19 |
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.text.Editable | |
import android.text.TextWatcher | |
import android.widget.EditText | |
fun EditText.onTextChanged( | |
@IntRange(from = 0, to = 10000) debounce: Int = 0, | |
cb: (String) -> Unit | |
) { | |
addTextChangedListener(object : TextWatcher { | |
val callbackRunner = Runnable { |
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
/** @author Aidan Follestad (afollestad) */ | |
class LifecycleAwareDisposable( | |
private val disposable: Disposable | |
) : LifecycleObserver { | |
@OnLifecycleEvent(ON_DESTROY) | |
fun dispose() = disposable.dispose() | |
} | |
/** @author Aidan Follestad (afollestad) */ |
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.lifecycle.LiveData | |
import androidx.lifecycle.Transformations | |
fun <X, Y> LiveData<X>.map(mapper: (X) -> Y) = | |
Transformations.map(this, mapper)!! | |
fun <X, Y> LiveData<X>.switchMap(mapper: (X) -> LiveData<Y>) = | |
Transformations.switchMap(this, mapper)!! |
NewerOlder