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 delegates | |
import java.lang.ref.SoftReference | |
import java.lang.ref.WeakReference | |
import kotlin.properties.ReadWriteProperty | |
import kotlin.reflect.KProperty | |
// Idea taken from: https://medium.com/@pgopinath/idiomatic-weakreference-implementation-by-delegate-in-kotlin-65ec60287de6 | |
fun <T>weakReference(tIn: T? = null): ReadWriteProperty<Any?, T?> { |
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
/** | |
* Creates a [FlowTestObserver] instance and starts collecting the values of the [Flow] immediately. | |
* You must call [FlowTestObserver.finish] after all the values have been emitted to the flow in order to continue. | |
*/ | |
fun <T> Flow<T>.test(scope: CoroutineScope): FlowTestObserver<T> { | |
return FlowTestObserver(scope, this) | |
} | |
/** | |
* A test class that collects the values of the provided `flow` in its own coroutine. The collected values are |
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.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.fragment.app.DialogFragment | |
import androidx.fragment.app.Fragment | |
import androidx.lifecycle.DefaultLifecycleObserver | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.viewbinding.ViewBinding |
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.DisplayMetrics | |
import android.util.Log | |
import android.view.View | |
import android.view.animation.Interpolator | |
import android.widget.Scroller | |
import androidx.core.view.ViewCompat | |
import androidx.recyclerview.widget.* | |
import kotlin.math.abs | |
import kotlin.math.max |
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.channels.BroadcastChannel | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.channels.consumeEach | |
runBlocking { | |
val sendChannel = BroadcastChannel<Int>(4) | |
println("Starting") |
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.Dispatchers | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.channels.consumeEach | |
import kotlinx.coroutines.delay | |
import kotlinx.coroutines.launch | |
import kotlinx.coroutines.runBlocking | |
runBlocking { | |
val sendChannel = Channel<Int>(4) |