Skip to content

Instantly share code, notes, and snippets.

View axiel7's full-sized avatar
🐢
Take your time

Axel axiel7

🐢
Take your time
View GitHub Profile
@manuelvicnt
manuelvicnt / ProvideViewModels.kt
Last active May 2, 2024 17:16
Scope ViewModels to Composables
// PLEASE, READ
//
// This is a way to scope ViewModels to the Composition.
// However, this doesn't survive configuration changes or procress death on its own.
// You can handle all config changes in compose by making the activity handle those in the Manifest file
// e.g. android:configChanges="colorMode|density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode">
//
// This is just an exploration to see what's possible in Compose. We don't encourage developers to copy-paste
// this code if they don't fully understand the implications of it and if this actually solves the use case to solve.
@jeluchu
jeluchu / TypeConverter
Created August 9, 2020 12:30
Explain to save custom objecto on Room Database with TypeConverter
@TypeConverter
fun stringToListPromo(data: String?): List<PromoEntity?>? {
if (data == null) {
return Collections.emptyList()
}
val listType: Type = object :
TypeToken<List<PromoEntity?>?>() {}.type
return gson.fromJson<List<PromoEntity?>>(data, listType)
}
@yinsee
yinsee / UIImage+Trim
Last active June 19, 2023 05:33
Trim whitespaces on UIImage
/*
http://stackoverflow.com/questions/9061800/how-do-i-autocrop-a-uiimage/40780523#40780523
*/
import UIKit
extension UIImage {
func trim() -> UIImage {
let newRect = self.cropRect