This file contains 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
@MainThread | |
inline fun <reified VM : ViewModel> ComponentActivity.viewModel( | |
noinline provider: (SavedStateHandle) -> VM | |
) = createLazyViewModel( | |
viewModelClass = VM::class, | |
savedStateRegistryOwnerProducer = { this }, | |
viewModelStoreOwnerProducer = { this }, | |
viewModelProvider = provider | |
) |
This file contains 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
// ViewModel factory | |
@MainThread | |
inline fun <reified VM : ViewModel> ComponentActivity.viewModel( | |
noinline provider: (SavedStateHandle) -> VM | |
) = createLazyViewModel( | |
viewModelClass = VM::class, | |
savedStateRegistryOwnerProducer = { this }, | |
viewModelStoreOwnerProducer = { this }, | |
viewModelProvider = provider |
This file contains 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
public class ViewModelInjectionFactory<VM extends ViewModel> implements ViewModelProvider.Factory { | |
private Lazy<VM> viewModel; | |
@Inject | |
public ViewModelInjectionFactory(Lazy<VM> viewModel) { | |
this.viewModel = viewModel; | |
} | |
@Override |
This file contains 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 UploadFilesUseCase( | |
private val schedulerProvider: SchedulerProvider, | |
private val httpManager: HttpManager | |
) { | |
private var operation: Completable? = null | |
fun uploadFiles(): Completable = synchronized(this) { | |
operation | |
?: (doUploadFiles() |
This file contains 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
inline fun Modifier.conditional( | |
condition: Boolean, | |
ifTrue: Modifier.() -> Modifier, | |
ifFalse: Modifier.() -> Modifier = { this }, | |
): Modifier = if (condition) { | |
then(ifTrue(this)) | |
} else { | |
then(ifFalse(this)) | |
} |
OlderNewer