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
fun getFestival( ... ): ResponseWrapper<FestivalData> { | |
val request: suspend () -> Unit = { | |
val festival = festivalAPI.get( ... ) | |
("Festival API" to "Fetched from API").debug() | |
festivalDAO.insert(festival) | |
("Festival DAO" to "Inserted to DB").debug() | |
} | |
val refreshTrigger = MutableLiveData<Unit>() | |
val refreshState = refresh.switchMap { | |
("Festival Refresh" to "Refresh Request").debug() |
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
private val festivalRequest = MutableLiveData<An>() | |
private val festivalResponse = festivalRequest.map { getFestivalUseCase.execute(it) } | |
val festival = festivalResponse.switchMap { it.data } | |
val festivalState = festivalResponse.switchMap { it.state } | |
val festivalRefreshState = festivalResponse.switchMap { it.refreshState } |
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
binding.btnRequest.setOnClickListener { | |
viewModel.requestFestival( ... ) | |
} | |
binding.btnRetry.setOnClickListener { | |
viewModel.refreshFestival() | |
} | |
viewModel.festival.observer { | |
// 페스티벌 데이터가 나옵니다. | |
} | |
val observer = { state: NetworkState? -> |
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
fun <T> intentExtra(defaultValue: T? = null) = object : ReadOnlyProperty<Activity, T?> { | |
override fun getValue(thisRef: Activity, property: KProperty<*>): T? { | |
return when (defaultValue) { | |
is String -> thisRef.intent.getStringExtra(property.name) as T | |
is Int -> thisRef.intent.getIntExtra(property.name, defaultValue) as T | |
is Long -> thisRef.intent.getLongExtra(property.name, defaultValue) as T | |
// And More... | |
else -> null | |
} | |
} |
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
@Composable | |
fun ConstraintLayoutScope.t2t( | |
ref: ConstrainedLayoutReference? = null, | |
margin: Dp = 0.dp | |
): Constraint = { | |
val reference = ref ?: parent | |
top.linkTo(reference.top, margin) | |
} |
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
@Composable | |
fun LottoTheme( | |
content : @Composable () -> Unit | |
) { | |
MaterialTheme( | |
content = content | |
) | |
} |
OlderNewer