Skip to content

Commit

Permalink
[CHORE] ktlint 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
l5x5l committed Sep 20, 2024
1 parent d4b418c commit c32350a
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package pokitmons.pokit.core.feature.model.paging
import pokitmons.pokit.domain.commom.PokitResult

sealed interface PagingLoadResult<out T> {
data class Success<T>(val result: List<T>): PagingLoadResult<T>
data class Success<T>(val result: List<T>) : PagingLoadResult<T>
data class Error<T>(val errorCode: String) : PagingLoadResult<T>

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class SimplePaging<ITEM, KEY> (
private val initPage: Int = 0,
private val firstRequestPage: Int = 3,
) {
private val _pagingData : MutableStateFlow<List<ITEM>> = MutableStateFlow(emptyList())
val pagingData : StateFlow<List<ITEM>> = _pagingData.asStateFlow()
private val _pagingData: MutableStateFlow<List<ITEM>> = MutableStateFlow(emptyList())
val pagingData: StateFlow<List<ITEM>> = _pagingData.asStateFlow()

private val _pagingState : MutableStateFlow<PagingState> = MutableStateFlow(PagingState.IDLE)
val pagingState : StateFlow<PagingState> = _pagingState.asStateFlow()
private val _pagingState: MutableStateFlow<PagingState> = MutableStateFlow(PagingState.IDLE)
val pagingState: StateFlow<PagingState> = _pagingState.asStateFlow()

private var pagingDataRequestJob: Job? = null
private var currentPageIndex = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class SimplePagingUnitTest : DescribeSpec({
loadTime = PAGE_LOAD_TIME,
totalItemCount = TOTAL_ITEM_COUNT
),
getKeyFromItem = {it},
firstRequestPage = FIRST_REQUEST_PAGE_SAMPLE,
getKeyFromItem = { it },
firstRequestPage = FIRST_REQUEST_PAGE_SAMPLE
)

context("새로고침을 한 상황에서") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestPagingSource(
val startIndex = pageIndex * pageSize
val lastIndex = min(((pageIndex + 1) * pageSize), totalItemCount)

val itemList = (startIndex until lastIndex).map { "${it}번째 아이템" }
val itemList = (startIndex until lastIndex).map { "${it}번째 아이템" }
return PagingLoadResult.Success(itemList)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AddLinkViewModel @Inject constructor(
) : ContainerHost<AddLinkScreenState, AddLinkScreenSideEffect>, ViewModel() {
override val container: Container<AddLinkScreenState, AddLinkScreenSideEffect> = container(AddLinkScreenState())

private val pokitPagingSource = object: PagingSource<Pokit> {
private val pokitPagingSource = object : PagingSource<Pokit> {
override suspend fun load(pageIndex: Int, pageSize: Int): PagingLoadResult<Pokit> {
val response = getPokitsUseCase.getPokits(page = pageIndex, size = pageSize)
return PagingLoadResult.fromPokitResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AddPokitViewModel @Inject constructor(

private val pokitId = savedStateHandle.get<String>("pokit_id")?.toIntOrNull()

private val pokitPagingSource = object: PagingSource<Pokit> {
private val pokitPagingSource = object : PagingSource<Pokit> {
override suspend fun load(pageIndex: Int, pageSize: Int): PagingLoadResult<Pokit> {
val response = getPokitsUseCase.getPokits(page = pageIndex, size = pageSize)
return PagingLoadResult.fromPokitResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AlarmViewModel @Inject constructor(
private val deleteAlertUseCase: DeleteAlertUseCase,
) : ViewModel() {

private val alarmPagingSource = object: PagingSource<Alarm> {
private val alarmPagingSource = object : PagingSource<Alarm> {
override suspend fun load(pageIndex: Int, pageSize: Int): PagingLoadResult<Alarm> {
val response = getAlertsUseCase.getAlerts(page = pageIndex, size = pageSize)
return PagingLoadResult.fromPokitResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class PokitViewModel @Inject constructor(
pokitPaging.modifyItem(linkCountDecreasedPokit.copy(count = decreasedLinkCount))
}
}

}
}
}
Expand Down Expand Up @@ -154,7 +153,7 @@ class PokitViewModel @Inject constructor(
var screenType = mutableStateOf<ScreenType>(ScreenType.Pokit)
private set

private val pokitPagingSource = object: PagingSource<Pokit> {
private val pokitPagingSource = object : PagingSource<Pokit> {
override suspend fun load(pageIndex: Int, pageSize: Int): PagingLoadResult<Pokit> {
val sort = when (pokitsSortOrder.value) {
PokitsSortOrder.Latest -> PokitsSort.RECENT
Expand All @@ -163,7 +162,7 @@ class PokitViewModel @Inject constructor(
val response = getPokitsUseCase.getPokits(size = pageSize, page = pageIndex, sort = sort)
return PagingLoadResult.fromPokitResult(
pokitResult = response,
mapper = { domainPokits -> domainPokits.map { Pokit.fromDomainPokit(it) }}
mapper = { domainPokits -> domainPokits.map { Pokit.fromDomainPokit(it) } }
)
}
}
Expand All @@ -174,9 +173,9 @@ class PokitViewModel @Inject constructor(
coroutineScope = viewModelScope
)

private val linksPagingSource = object: PagingSource<DetailLink> {
private val linksPagingSource = object : PagingSource<DetailLink> {
override suspend fun load(pageIndex: Int, pageSize: Int): PagingLoadResult<DetailLink> {
val sort = when(linksSortOrder.value) {
val sort = when (linksSortOrder.value) {
UncategorizedLinksSortOrder.Latest -> LinksSort.RECENT
UncategorizedLinksSortOrder.Older -> LinksSort.OLDER
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class PokitDetailViewModel @Inject constructor(
private val getLinkUseCase: GetLinkUseCase,
savedStateHandle: SavedStateHandle,
) : ViewModel() {
private val pokitPagingSource = object: PagingSource<Pokit> {
private val pokitPagingSource = object : PagingSource<Pokit> {
override suspend fun load(pageIndex: Int, pageSize: Int): PagingLoadResult<Pokit> {
val response = getPokitsUseCase.getPokits(size = pageSize, page = pageIndex)
return PagingLoadResult.fromPokitResult(
pokitResult = response,
mapper = { domainPokits -> domainPokits.map { Pokit.fromDomainPokit(it) }}
mapper = { domainPokits -> domainPokits.map { Pokit.fromDomainPokit(it) } }
)
}
}
Expand All @@ -61,7 +61,7 @@ class PokitDetailViewModel @Inject constructor(
coroutineScope = viewModelScope
)

private val linkPagingSource = object: PagingSource<Link> {
private val linkPagingSource = object : PagingSource<Link> {
override suspend fun load(pageIndex: Int, pageSize: Int): PagingLoadResult<Link> {
val currentPokit = state.value.currentPokit
val currentFilter = state.value.currentFilter
Expand All @@ -73,7 +73,7 @@ class PokitDetailViewModel @Inject constructor(
categoryId = categoryId,
sort = sort,
isRead = if (currentFilter.notReadChecked) false else null,
favorite = if (currentFilter.bookmarkChecked) true else null,
favorite = if (currentFilter.bookmarkChecked) true else null
)
return PagingLoadResult.fromPokitResult(
pokitResult = response,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SearchViewModel @Inject constructor(
initLinkRemoveEventDetector()
}

private val linkPagingSource = object: PagingSource<Link> {
private val linkPagingSource = object : PagingSource<Link> {
override suspend fun load(pageIndex: Int, pageSize: Int): PagingLoadResult<Link> {
val currentFilter = state.value.filter ?: Filter()

Expand All @@ -82,7 +82,6 @@ class SearchViewModel @Inject constructor(
mapper = { domainLinks -> domainLinks.map { Link.fromDomainLink(it) } }
)
}

}

private val linkPaging = SimplePaging(
Expand All @@ -91,7 +90,7 @@ class SearchViewModel @Inject constructor(
coroutineScope = viewModelScope
)

private val pokitPagingSource = object: PagingSource<Pokit> {
private val pokitPagingSource = object : PagingSource<Pokit> {
override suspend fun load(pageIndex: Int, pageSize: Int): PagingLoadResult<Pokit> {
val response = getPokitsUseCase.getPokits(page = pageIndex, size = pageSize)
return PagingLoadResult.fromPokitResult(
Expand Down

0 comments on commit c32350a

Please sign in to comment.