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
function android-demo-mode() { | |
CMD=$1 | |
if [[ $CMD != "on" && $CMD != "off" ]]; then | |
echo "Usage: $0 [on|off] [hhmm]" >&2 | |
return 1 | |
fi | |
if [[ "$2" != "" ]]; then | |
HHMM="$2" |
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.lifecycle.LiveData | |
import androidx.lifecycle.liveData | |
import androidx.lifecycle.map | |
import androidx.lifecycle.switchMap | |
import kotlinx.coroutines.delay | |
// Combine latest values | |
inline fun <X, Y, Z> LiveData<X>.combineLatest(data: LiveData<Y>, crossinline mapFunction: (X, Y) -> Z): LiveData<Z> { | |
return switchMap { x: X -> data.map { y: Y -> mapFunction(x, y) } } | |
} |
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.lifecycle.LiveData | |
import androidx.lifecycle.Observer | |
import kotlinx.coroutines.suspendCancellableCoroutine | |
import kotlinx.coroutines.withTimeoutOrNull | |
import kotlin.coroutines.resume | |
suspend fun <T : Any> LiveData<T>.awaitValue(): T? = withTimeoutOrNull(2000L) { | |
suspendCancellableCoroutine<T> { cont -> | |
val observer = object : Observer<T> { | |
override fun onChanged(t: T) { |
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.content.Context | |
import android.support.annotation.MainThread | |
import android.support.v7.app.AlertDialog | |
import io.reactivex.Observable | |
enum class RxDialogActionStyle { | |
POSITIVE, NEGATIVE, NEUTRAL | |
} | |
data class RxDialogAction(val title: CharSequence, val style: RxDialogActionStyle) |
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.content.Context; | |
import android.graphics.ColorFilter; | |
import android.graphics.PorterDuff; | |
import android.graphics.PorterDuffColorFilter; | |
import android.support.v7.widget.AppCompatImageView; | |
import android.util.AttributeSet; | |
public class HighlightableImageView extends AppCompatImageView { | |
private static final ColorFilter COLOR_FILTER = new PorterDuffColorFilter(0x40000000, PorterDuff.Mode.SRC_ATOP); |