Skip to content

Instantly share code, notes, and snippets.

View ViewModelInject_Basics.kt
class MyViewModel
@ViewModelInject constructor(
Long foo, @Assisted SavedStateHandle savedStateHandle
): ViewModel() {
//...
}
@ViewModelModule
@Module(includes = ViewModelInject_VMModule::class)
abstract class VMModule {}
@hansenji
hansenji / savedstate_boilerplate.kt
Last active Apr 1, 2019
savedstate_boilerplate.kt
View savedstate_boilerplate.kt
@AssistedInject.Factory
interface Factory : ViewModelAssistedFactory<MyViewModel>
@Module
abstract class DetailModule {
@Binds
@IntoMap
@ViewModelKey(MyViewModel.class)
abstract fun bindFactory(factory: MyViewModel.Factory): ViewModelAssistedFactory
}
@hansenji
hansenji / JacksonKotlinModuleExample.kt
Created Apr 4, 2017
Jackson Kotlin Module Example
View JacksonKotlinModuleExample.kt
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
fun main(args: Array<String>) {
// val mapper = ObjectMapper().registerModule(KotlinModule())
// val mapper = ObjectMapper().registerKotlinModule()
val mapper = jacksonObjectMapper()
val writer = mapper.writerWithDefaultPrettyPrinter()
val json1 = writer.writeValueAsString(Data1(1, "Foo", "Bar"))
You can’t perform that action at this time.