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
abstract class BaseFragment<VB : ViewBinding>( | |
private val bindingFactory: (LayoutInflater, ViewGroup?, Boolean) -> VB | |
) : Fragment() { | |
private var _binding: VB? = null | |
val binding: VB | |
get() = _binding!! | |
override fun onCreateView( | |
inflater: LayoutInflater, |
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
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