Skip to content

Instantly share code, notes, and snippets.

View mitchtabian's full-sized avatar
🎞️
Building stuff

Mitch Tabian mitchtabian

🎞️
Building stuff
View GitHub Profile
@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)
class RecipeListFragment: Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val view = inflater.inflate(
R.layout.fragment_recipe_list, container, false
)
class RecipeListFragment: Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val view = ComposeView(requireContext())
view.apply {
setContent {
setContent{
ListItem(
modifier = Modifier
.height(100.dp)
.border(border = BorderStroke(1.dp, Color.Black))
,
icon = {
Icon(
Icons.Filled.Adb,
modifier = Modifier
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),
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),
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))
val stateResult: MutableState<String> = mutableStateOf("")
fun execute(){
expensiveFlowThing().onEach { result ->
withContext(Main){
stateResult.value = result
}
}.launchIn(viewModelScope)
}
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()
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}"