(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import javafx.application.*; | |
import javafx.geometry.Pos; | |
import javafx.scene.*; | |
import javafx.scene.control.Label; | |
import javafx.scene.layout.*; | |
import javafx.scene.paint.Color; | |
import javafx.stage.*; | |
import javax.imageio.ImageIO; | |
import java.io.IOException; |
import android.content.Context; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Nullable; | |
import android.support.v7.app.AppCompatActivity; | |
import com.mywebgrocer.util.ActivityResultData; | |
import java.util.Random; |
The official docs are actually useful now, so refer to those for up-to-date information.
inline fun <reified T> SharedPreferences.observeKey(key: String, default: T): Flow<T> = channelFlow { | |
send(getItem(key, default)) | |
val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, k -> | |
if (key == k) { | |
trySend(getItem(key, default)) | |
} | |
} | |
registerOnSharedPreferenceChangeListener(listener) |
// Extension for Activity | |
fun Activity.showAsBottomSheet(content: @Composable (() -> Unit) -> Unit) { | |
val viewGroup = this.findViewById(android.R.id.content) as ViewGroup | |
addContentToView(viewGroup, content) | |
} | |
// Extension for Fragment | |
fun Fragment.showAsBottomSheet(content: @Composable (() -> Unit) -> Unit) { | |
val viewGroup = requireActivity().findViewById(android.R.id.content) as ViewGroup | |
addContentToView(viewGroup, content) |