The official docs are actually useful now, so refer to those for up-to-date information.
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
// 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) |
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
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) |
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.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; |
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 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; |
(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.