-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
�[AN] feat: 모임 Paging & 로딩 구현 (#698)
- Loading branch information
Showing
35 changed files
with
673 additions
and
295 deletions.
There are no files selected for viewing
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
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
6 changes: 6 additions & 0 deletions
6
android/app/src/main/java/com/happy/friendogly/data/mapper/ClubMapper.kt
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
24 changes: 24 additions & 0 deletions
24
android/app/src/main/java/com/happy/friendogly/data/mapper/SearchClubMapper.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.happy.friendogly.data.mapper | ||
|
||
import androidx.paging.PagingData | ||
import androidx.paging.map | ||
import com.happy.friendogly.data.model.ClubDto | ||
import com.happy.friendogly.data.model.SearchClubPageInfoDto | ||
import com.happy.friendogly.domain.model.Club | ||
import com.happy.friendogly.domain.model.SearchClubPageInfo | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
|
||
fun SearchClubPageInfo.toData(): SearchClubPageInfoDto { | ||
return SearchClubPageInfoDto( | ||
pageSize = pageSize, | ||
lastFoundId = lastFoundId.toString(), | ||
lastFoundCreatedAt = lastFoundCreatedAt.toString(), | ||
) | ||
} | ||
|
||
fun Flow<PagingData<ClubDto>>.toDomain(): Flow<PagingData<Club>> { | ||
return this.map { pagingData -> | ||
pagingData.map { it.toDomain() } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
android/app/src/main/java/com/happy/friendogly/data/model/SearchClubPageInfoDto.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.happy.friendogly.data.model | ||
|
||
data class SearchClubPageInfoDto( | ||
val pageSize: Int, | ||
val lastFoundCreatedAt: String, | ||
val lastFoundId: String, | ||
) |
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
50 changes: 50 additions & 0 deletions
50
android/app/src/main/java/com/happy/friendogly/data/repository/SearchClubRepositoryImpl.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.happy.friendogly.data.repository | ||
|
||
import androidx.paging.Pager | ||
import androidx.paging.PagingConfig | ||
import androidx.paging.PagingData | ||
import com.happy.friendogly.data.mapper.toData | ||
import com.happy.friendogly.data.mapper.toDomain | ||
import com.happy.friendogly.domain.model.Club | ||
import com.happy.friendogly.domain.model.ClubAddress | ||
import com.happy.friendogly.domain.model.ClubFilterCondition | ||
import com.happy.friendogly.domain.model.Gender | ||
import com.happy.friendogly.domain.model.SearchClubPageInfo | ||
import com.happy.friendogly.domain.model.SizeType | ||
import com.happy.friendogly.domain.repository.SearchClubRepository | ||
import com.happy.friendogly.remote.api.SearchingClubService | ||
import com.happy.friendogly.remote.paging.SearchingClubPagingSource | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class SearchClubRepositoryImpl | ||
@Inject | ||
constructor( | ||
private val service: SearchingClubService, | ||
) : SearchClubRepository { | ||
override suspend fun getSearchingClubs( | ||
searchClubPageInfo: SearchClubPageInfo, | ||
filterCondition: ClubFilterCondition, | ||
address: ClubAddress, | ||
genderParams: List<Gender>, | ||
sizeParams: List<SizeType>, | ||
): Flow<PagingData<Club>> { | ||
return Pager( | ||
config = | ||
PagingConfig( | ||
pageSize = searchClubPageInfo.pageSize, | ||
enablePlaceholders = false, | ||
), | ||
pagingSourceFactory = { | ||
SearchingClubPagingSource( | ||
service = service, | ||
searchClubPageInfoDto = searchClubPageInfo.toData(), | ||
filterCondition = filterCondition.toData(), | ||
address = address.toData(), | ||
genderParams = genderParams.map { it.toData() }, | ||
sizeParams = sizeParams.map { it.toData() }, | ||
) | ||
}, | ||
).flow.toDomain() | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
android/app/src/main/java/com/happy/friendogly/domain/model/SearchClubPageInfo.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.happy.friendogly.domain.model | ||
|
||
import kotlinx.datetime.LocalDateTime | ||
|
||
data class SearchClubPageInfo( | ||
val pageSize: Int = DEFAULT_PAGE_SIZE, | ||
val lastFoundCreatedAt: LocalDateTime = LocalDateTime.parse(DEFAULT_FOUND_CREATE), | ||
val lastFoundId: Long = DEFAULT_FOUND_ID, | ||
) { | ||
companion object { | ||
private const val DEFAULT_PAGE_SIZE = 20 | ||
private const val DEFAULT_FOUND_CREATE = "9999-12-31T23:59:59" | ||
private const val DEFAULT_FOUND_ID = 0x7fffffffffffffff | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
android/app/src/main/java/com/happy/friendogly/domain/repository/SearchClubRepository.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.happy.friendogly.domain.repository | ||
|
||
import androidx.paging.PagingData | ||
import com.happy.friendogly.domain.model.Club | ||
import com.happy.friendogly.domain.model.ClubAddress | ||
import com.happy.friendogly.domain.model.ClubFilterCondition | ||
import com.happy.friendogly.domain.model.Gender | ||
import com.happy.friendogly.domain.model.SearchClubPageInfo | ||
import com.happy.friendogly.domain.model.SizeType | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface SearchClubRepository { | ||
suspend fun getSearchingClubs( | ||
searchClubPageInfo: SearchClubPageInfo, | ||
filterCondition: ClubFilterCondition, | ||
address: ClubAddress, | ||
genderParams: List<Gender>, | ||
sizeParams: List<SizeType>, | ||
): Flow<PagingData<Club>> | ||
} |
13 changes: 8 additions & 5 deletions
13
android/app/src/main/java/com/happy/friendogly/domain/usecase/GetSearchingClubsUseCase.kt
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
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
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
Oops, something went wrong.