-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#5] 지역코드/시군구코드 로컬 저장 #6
Conversation
# Conflicts: # app/src/main/java/kr/ksw/visitkorea/app/VisitKoreaApp.kt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코멘트 추가 완료
@@ -37,6 +40,16 @@ object DataModule { | |||
.build() | |||
} | |||
|
|||
@Provides | |||
@Singleton | |||
fun provideAreaCodeDatabase(application: Application): AreaCodeDatabase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun provideAreaCodeDatabase(@ApplicationContext context: Context): AreaCodeDatabase {
...
}
로 해도 좋을 것 같아요. predefined binding 에 대한 qualifier 입니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ApplicationContext
의 경우 생성자 주입으로 context를 제공하는 것이 아니라서 그런지 추가하면 Missing Binds 에러가 발생하네요
@PrimaryKey(autoGenerate = true) | ||
val id: Int? = null, | ||
val code: String, | ||
val name: String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing comma 를 넣어 주면 좋을 거 같아요
val id: Int? = null, | ||
val areaCode: String, | ||
val code: String, | ||
val name: String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마찬가지로 trailing comma 를 넣어 주면 좋을 것 같습니다.
return Result.success() | ||
} | ||
|
||
override suspend fun getForegroundInfo(): ForegroundInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ForegroundInfo 가 뭔가 해서 찾아봤는데, Workmanager 가 12 이전 버전에서 사용될 때 ForegroundService 를 이용하기 위한 거 같네요. 혹시 앱을 닫아도 계속적으로 실행되어야 할 만큼 doWork()
내부의 구현이 오래 걸리는 걸까요? 이건 그냥 궁금해서 여쭤 보는 거예요 :) 그리고 getForegroundInfo() 와 관련된 메서드로 setExpedited()
가 있는데, 이것의 예시도 참고해 보세요. 말 그대로 Workmanager가 신속하게 동작하도록 하는 메서드입니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
참고했던 예제에서 override를 하고있어서 필수로 override해야하는 함수인줄 알았습니다. 지금 보니 getForegroundInfo는 일반 open 함수라 ForegroundService까지 이용할 필요가없으면 굳이 override하지 않아도 될 것같네요! 지우는게 나을것 같습니다.
viewModelScope.launch { | ||
val areaCodeItems = areaCodeDatabase.areaCodeDao.getAllAreaCodeEntities() | ||
if(areaCodeItems.isEmpty()) { | ||
val workRequest = OneTimeWorkRequestBuilder<AreaCodeWorker>().build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위에 리뷰를 달았는데, workRequest 를 만들 때 따로 설정해줘야 하는 게 없다면 from 이라는 정적메소드를 사용해도 될 것 같습니다.
val myWorkRequest = OneTimeWorkRequest.from(MyWork::class.java)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정했습니다!
@@ -29,6 +29,7 @@ class SplashActivity : ComponentActivity() { | |||
|
|||
override fun onCreate(savedInstanceState: Bundle?) { | |||
super.onCreate(savedInstanceState) | |||
viewModel.initAreaCode(applicationContext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스플래시화면에서 viewModel.initAreaCode()
가 setContentView{}
이후에 불려도 되지 않을까 하는 생각이 들긴 해요. 아마 큰 차이는 없을 거 같지만요. 이건 의견을 좀 달아 주시면 좋을 것 같습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setContent 이후에 있어도 좋을것 같습니다
변경사항
멘토님께