Skip to content

Instantly share code, notes, and snippets.

View arohim's full-sized avatar
😋

a-rohim arohim

😋
View GitHub Profile
@arohim
arohim / GooglePlayServices.kt
Created July 17, 2024 15:47 — forked from LouisCAD/GooglePlayServices.kt
Allows using Google Play Services Task API in Kotlin Coroutines, plus Play Services availability check made easier.
import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.tasks.Task
import splitties.init.appCtx
import kotlin.coroutines.experimental.suspendCoroutine
val googleApiAvailability = GoogleApiAvailability.getInstance()!!
inline val playServicesAvailability get() = googleApiAvailability.isGooglePlayServicesAvailable(appCtx)
@JvmName("awaitVoid")
suspend fun Task<Void>.await() = suspendCoroutine<Unit> { continuation ->
1. hiltvm (applicable in top-level)
@dagger.hilt.android.lifecycle.HiltViewModel
class $NAME$ @javax.inject.Inject constructor(
$PARAM$
) : androidx.lifecycle.ViewModel() {
$END$
}
2. vmstatefunc (applicable in class)
private val _$NAME$ = androidx.compose.runtime.mutableStateOf<$TYPE$>($INITIAL_VALUE$)
@arohim
arohim / NewInstance.kt
Last active August 4, 2020 04:12 — forked from MarcinMoskala/NewInstance.kt
Random Kotlin Instance
import com.google.gson.Gson
import com.google.gson.JsonElement
import kotlin.random.Random
import kotlin.reflect.KClass
import kotlin.reflect.KType
import kotlin.reflect.KTypeParameter
import kotlin.reflect.typeOf
@ExperimentalStdlibApi