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
/** | |
* A property that automatically clears its reference according to the Android lifecycle. | |
* | |
* When the value for this property is set, it will be scheduled to be cleared in the opposing | |
* lifecycle event. For example, a property whose value is set during `onCreate()` will be cleared | |
* during `onDestroy()`. | |
*/ | |
class LifecycleProperty<T> : LifecycleObserver { | |
companion object { | |
private val opposingEvents = mapOf( |
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
val observable1 = Observable.error<Int>(Exception()) | |
val observable2 = Observable.error<Int>(Exception()) | |
val zipper = BiFunction<Int, Int, String> { one, two -> "$one - $two" } | |
observable1.zipWith(observable2, zipper) | |
.subscribe( | |
{ System.out.println(it) }, | |
{ it.printStackTrace() } | |
) |
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
val sharedSource = Observable.just(1) | |
.delay(1, TimeUnit.SECONDS) | |
.map { _ -> | |
// Some operation that throws an exception | |
throw Exception() | |
} | |
.publish() | |
.autoConnect(2) | |
val disposable = CompositeDisposable() |
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
someApi.retrofitCall() // This is a network request made using Retrofit | |
.publish() | |
.connect() |
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 AutofillEditText : TextInputEditText { | |
@TargetApi(Build.VERSION_CODES.O) | |
override fun autofill(value: AutofillValue) { | |
val autofilledText = value.textValue | |
val processedText = sanitize(autofilledText) | |
super.autofill(AutofillValue.forText(processedText)) | |
} | |
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.example.tokens | |
import androidx.compose.ui.graphics.Color | |
class Colors( | |
val textPrimary: Color, | |
val textSecondary: Color, | |
val textInverse: Color, | |
val textSecondaryInverse: Color, | |
) |
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 NetworkImage(imageUrl: String, description: String) { | |
val context = LocalContext.current | |
LaunchedEffect(imageUrl) { | |
Coil.execute( | |
ImageRequest.Builder(context) | |
.data(imageUrl) | |
.target { result -> | |
loadedBitmaps[imageUrl] = (result as BitmapDrawable).bitmap | |
} |
OlderNewer