Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

부산대 Android_이지은 5주차 2단계(리팩토링 완료) #77

Open
wants to merge 22 commits into
base: jieunyume
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bc798bc
docs: update README.md
JieunYume Jul 24, 2024
dd8ed1b
feat: Room 플러그인과 라이브러리 추가
JieunYume Jul 24, 2024
1faf7fd
feat: SavedLocation을 위한 entity, dao, room database 구현
JieunYume Jul 24, 2024
e12de89
feat: SavedLocationRepository에서 SavedLocationDataSource가 아닌 addDataba…
JieunYume Jul 24, 2024
a02a8cf
refactor: data source 클래스들의 이름 수정, LocationDto를 Location으로 수정하는 코드를 L…
JieunYume Jul 24, 2024
b777f09
refactor: 함수명 수정 및 패키지 이동
JieunYume Jul 24, 2024
5c44b53
feat: Hilt 라이브러리 추가 및 App의 종속성 컨테이너 설정
JieunYume Jul 24, 2024
038b4d9
feat: Repository 인터페이스를 사용하도록 수정
JieunYume Jul 24, 2024
d904772
refactor: LocationModule을 만들어 의존성 선언
JieunYume Jul 25, 2024
b930b26
refactor: SavedLocationModule을 만들어 의존성 선언
JieunYume Jul 25, 2024
5626965
refactor: Repository들을 Binds 방식으로 의존성 선언
JieunYume Jul 25, 2024
3670177
docs: update README.md
JieunYume Jul 25, 2024
7da86f2
refactor: item_location.xml에서 data binding을 사용하도록 수정
JieunYume Jul 26, 2024
4dd446e
refactor: item_saved_location.xml에서 data binding을 사용하도록 수정
JieunYume Jul 26, 2024
7256a0b
refactor: findViewById() 사용를 없애고 view binding을 사용하도록 변경
JieunYume Jul 26, 2024
33f9b92
refactor: SharedPreferences와 KakaoAPI의 의존성 주입 설정
JieunYume Jul 26, 2024
1488a8d
refactor: CoroutineDispatcher 의존성 주입
JieunYume Jul 29, 2024
89154f6
refactor: Location을 Parcelable로 변경
JieunYume Jul 29, 2024
42c2240
refactor: setOnClickListener로 리스너를 설정했던 방식에서 xml에서 data binding으로 리스너…
JieunYume Jul 29, 2024
8c7baf9
fix: 검색창 클리어 버튼을 누르면 꺼지는 현상 고침
JieunYume Jul 29, 2024
bedeeb6
refactor: LocationModule을 object로 변경
JieunYume Jul 30, 2024
18fdc10
refactor: listener 함수명 변경
JieunYume Jul 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/src/main/java/campus/tech/kakao/map/LocationModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import javax.inject.Singleton

@Module
Expand All @@ -19,7 +21,13 @@ class LocationModule {
@Singleton
@Provides
fun provideLocationRemoteDataSource(kakaoAPI: KakaoAPI): LocationRemoteDataSource {
return LocationRemoteDataSource(kakaoAPI)
return LocationRemoteDataSource(kakaoAPI, Dispatchers.IO)
}

@Singleton
@Provides
fun provideDispatchers(): CoroutineDispatcher {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoroutineDispatcher 와 같은 abstract class 나 interface 는 다형성을 띄기 때문에 문제가 발생할 수 있어요.
Qualifer annotation 같은 것으로 "어떤 객체인지" 명확하게 보여주는 것이 좋습니다!

return Dispatchers.IO
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package campus.tech.kakao.map.model.datasource

import campus.tech.kakao.map.model.SearchFromKeywordResponse
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import javax.inject.Inject

class LocationRemoteDataSource @Inject constructor(
private val kakaoAPI: KakaoAPI
private val kakaoAPI: KakaoAPI,
private val dispatchersIO: CoroutineDispatcher
) {
companion object{
private const val RESULT_SIZE = 15
}

suspend fun getLocations(keyword: String): SearchFromKeywordResponse? {
return withContext(Dispatchers.IO){
return withContext(dispatchersIO){
kakaoAPI.searchFromKeyword(keyword, RESULT_SIZE).body()
}
}
Expand Down