This file contains hidden or 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
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")) |
This file contains hidden or 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
@AssistedInject.Factory | |
interface Factory : ViewModelAssistedFactory<MyViewModel> | |
@Module | |
abstract class DetailModule { | |
@Binds | |
@IntoMap | |
@ViewModelKey(MyViewModel.class) | |
abstract fun bindFactory(factory: MyViewModel.Factory): ViewModelAssistedFactory | |
} |
This file contains hidden or 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 MyViewModel | |
@ViewModelInject constructor( | |
Long foo, @Assisted SavedStateHandle savedStateHandle | |
): ViewModel() { | |
//... | |
} | |
@ViewModelModule | |
@Module(includes = ViewModelInject_VMModule::class) | |
abstract class VMModule {} |
This file contains hidden or 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
import android.view.View | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.SupervisorJob | |
import kotlinx.coroutines.cancelChildren | |
import kotlin.coroutines.CoroutineContext | |
internal val View.viewScope: ViewCoroutineScope | |
get() { | |
val scope = getTag(R.id.coroutineScope) as ViewCoroutineScope? |
This file contains hidden or 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 LifecycleGroup(val lifecycleOwner: LifecycleOwner) { | |
/** | |
* Recommended for the majority of use cases | |
* The crucial difference from [collect] is that when the original flow emits a new value, [block] for previous | |
* value is cancelled. | |
**/ | |
inline fun <T> Flow<T>.collectLatestWhenStarted(crossinline block: suspend (T) -> Unit): Job { | |
return lifecycleOwner.lifecycleScope.launchWhenStarted { | |
[email protected] { | |
block(it) |