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
@ExperimentalCoroutinesApi | |
@Composable | |
fun loadPicture(url: String, @DrawableRes defaultImage: Int): MutableState<Bitmap?> { | |
val bitmapState: MutableState<Bitmap?> = mutableStateOf(null) | |
// show default image while image loads | |
Glide.with(ContextAmbient.current) | |
.asBitmap() | |
.load(defaultImage) |
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 RecipeListFragment: Fragment() { | |
override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View { | |
val view = inflater.inflate( | |
R.layout.fragment_recipe_list, container, false | |
) |
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 RecipeListFragment: Fragment() { | |
override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View { | |
val view = ComposeView(requireContext()) | |
view.apply { | |
setContent { |
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
setContent{ | |
ListItem( | |
modifier = Modifier | |
.height(100.dp) | |
.border(border = BorderStroke(1.dp, Color.Black)) | |
, | |
icon = { | |
Icon( | |
Icons.Filled.Adb, | |
modifier = Modifier |
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
setContent { | |
ScrollableColumn( | |
modifier = Modifier | |
.fillMaxWidth() | |
.fillMaxHeight() | |
.background(color = Color(0xFFF2F2F2)) | |
) { | |
Image( | |
bitmap = imageFromResource(res = resources, resId = R.drawable.happy_meal), | |
modifier = Modifier.height(300.dp), |
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
setContent { | |
ScrollableColumn( | |
modifier = Modifier | |
.fillMaxWidth() | |
.fillMaxHeight() | |
.background(color = Color(0xFFF2F2F2)) | |
) { | |
Image( | |
bitmap = imageFromResource(res = resources, resId = R.drawable.happy_meal_small), | |
modifier = Modifier.height(300.dp), |
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
setContent { | |
Column { | |
Image( | |
bitmap = imageFromResource(res = resources, resId = R.drawable.happy_meal_small), | |
modifier = Modifier.height(300.dp), | |
contentScale = ContentScale.Crop, | |
) | |
Column(modifier = Modifier.padding(16.dp)) { | |
Text(text = "Happy Meal") | |
Spacer(modifier = Modifier.padding(top = 8.dp)) |
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 stateResult: MutableState<String> = mutableStateOf("") | |
fun execute(){ | |
expensiveFlowThing().onEach { result -> | |
withContext(Main){ | |
stateResult.value = result | |
} | |
}.launchIn(viewModelScope) | |
} |
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
from friend.models import FriendList | |
from chat.utils import find_or_create_private_chat | |
friend_lists = FriendList.objects.all() | |
for f in friend_lists: | |
for friend in f.friends.all(): | |
chat = find_or_create_private_chat(f.user, friend) | |
chat.is_active = True | |
chat.save() |
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 google_maps = "17.0.0" | |
val google_maps_ktx = "2.1.1" | |
val google_maps_utils = "2.0.3" | |
val google_maps_utils_ktx = "1.7.0" | |
val google_maps = "com.google.android.gms:play-services-maps:${Versions.google_maps}" | |
val google_maps_ktx = "com.google.maps.android:maps-ktx:${Versions.google_maps_ktx}" | |
val google_maps_utils = "com.google.maps.android:android-maps-utils:${Versions.google_maps_utils}" | |
val google_maps_utils_ktx = "com.google.maps.android:maps-utils-ktx:${Versions.google_maps_utils_ktx}" |