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

[1.1.0-AN_FEAT] 스플래시 때 포켓몬 front 이미지 캐시 #319

Merged
merged 8 commits into from
Sep 22, 2024

Conversation

murjune
Copy link
Contributor

@murjune murjune commented Sep 10, 2024

작업한 내용

  • 스플래시 시 포켓몬 24장 내부 저장소에 저~장
  • 전부 다 저장하니까 거의 40~50초 걸려서 처음 포켓몬 도감 화면 들어올 때 보이는 포켓몬 사진만 미리 저장했습니당

나중에 Paging + 스크롤할 때마다 이미지 Preload 해야할 것 같습니다.

PR 포인트

  • 코드가 조금 어려울 수 있습니다 참고 자료 드립니다

우테코 5기의 Glide 캐시 정리 블로그
suspendCancellableCoroutine

🚀Next Feature

  • CD 하지롱

@github-actions github-actions bot added the AN_FEAT ✨ 안드 새로운 기능 label Sep 10, 2024
Copy link

@sh1mj1 sh1mj1 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!
궁금한 점 남겨두었는데 제가 직접 말로도 물어볼게요

@SuppressLint("StaticFieldLeak")
private var instance: GlideImageCacher? = null

fun init(context: Context) {
Copy link

Choose a reason for hiding this comment

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

init 에서 따로 초기화를 해주는 이유가 무엇인가요?
instance() 에서 instance: GlideImageCacher 에 할당을 해주는 것 외에 다른 이점이 또 있나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

매번 context를 넣어주지 않아도 된다는 장점이 있습니다 ㅎㅎ

Choose a reason for hiding this comment

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

}
}

override suspend fun clear() {
Copy link

Choose a reason for hiding this comment

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

clear 를 따로 호출해줄 필요가 없는 걸까요?

Copy link

Choose a reason for hiding this comment

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

이 함수를 호출해줘야 할 때가 있다면, 서버에서 내려오는 이미지가 변경이 되었을 때 호출하면 되는걸까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

맞습니다~ 만약 서버의 url 에 해당하는 이미지가 바뀌었다면 clear 하고 다시 받아야겠죠?

@@ -30,7 +30,7 @@ class PokemonIntroViewModel(
coroutineScope {
val warmUp = async { pokemonRepository.warmUp() }
val delay = async { delay(1000) }
Copy link

Choose a reason for hiding this comment

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

여기서 delay(1000) 을 해야 할 필요가 있었나요..?

Copy link
Contributor Author

@murjune murjune Sep 11, 2024

Choose a reason for hiding this comment

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

이래서 매직 넘버를 지양해야하는거군요!
스플래쉬 화면을 보여주는 최소 시간을 설정한 것입니다!

dataSource: DataSource?,
isFirstResource: Boolean,
): Boolean {
con.resume(Unit)
Copy link

Choose a reason for hiding this comment

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

Timber.d(" $dataSource")
여기에 로그 찍어 놓고 실행하면 처음에는 REMOTE 로 찍히다가, 나중에는 DATA_DISK_CACHE 처럼 떠야 하는 게 맞나요?

제가 찍어봤을 때 처음 REMOTE 만 뜨고 다시는 뜨지 않아서요.
그러면 프리로딩한 캐시 이미지를 쓰고 있는 게 맞나 싶어서요

Copy link

Choose a reason for hiding this comment

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

아아~ 이제 알았다 취소~

* 🎉 Chore: PR_Comment_Notification.yml 

PR Comment 에 '/noti' 를 포함할 경우 Andorid 채널 혹은 Backend 채널로 노티가 간다

* 🎉 Chore: �Avatar, Content, Description 수정

* docs: README v0.1

* CD: discord로 apk 전달

* CD: cd되는지 확인

* ci: artifact 버전 v3로 수정

* test

* build : 병렬처리

* Revert "Merge branch 'main' into an/cd/send_to_discord"

This reverts commit 925c8db, reversing
changes made to 346391c.

* ci: google-service추가

* ci: 버저닝 label 추가
Copy link
Contributor Author

@murjune murjune left a comment

Choose a reason for hiding this comment

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

작업 하나 추가했어요~

Comment on lines 31 to 41
try {
coroutineScope {
val warmUp = async { pokemonRepository.warmUp() }
val delay = async { delay(MIN_SPLASH_TIME) }
awaitAll(warmUp, delay)
pokemonRepository.warmUp()
}
_navigationToHomeEvent.emit(Unit)
} catch (e: Exception) {
Timber.e(e)
handlePokemonError(e)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

이거 try-catch문을 추가해야하는데 제가 까먹었네요
이제 reconnect할 때 정상적으로 refresh될겁니당

Copy link

Choose a reason for hiding this comment

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

저번에 회의할 때 작성했던 코드군요 !

Copy link

@kkosang kkosang left a comment

Choose a reason for hiding this comment

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

미션하느라 리뷰가 늦었네요 🥲
고생하셨습니다 오둥이~

Comment on lines 31 to 41
try {
coroutineScope {
val warmUp = async { pokemonRepository.warmUp() }
val delay = async { delay(MIN_SPLASH_TIME) }
awaitAll(warmUp, delay)
pokemonRepository.warmUp()
}
_navigationToHomeEvent.emit(Unit)
} catch (e: Exception) {
Timber.e(e)
handlePokemonError(e)
Copy link

Choose a reason for hiding this comment

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

저번에 회의할 때 작성했던 코드군요 !

isFirstResource: Boolean,
): Boolean {
con.resume(Unit)
return false
Copy link

Choose a reason for hiding this comment

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

이미지 로딩에 성공했는데 왜 return false를 반환하는건지 궁금했는데, 성공과 실패 여부를 알리는 것이 아니였군요 😂

Choose a reason for hiding this comment

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

그러네여 ,, Glide의 기본 성공 처리를 유지 여부에 관련된 것,,,, 메모,,

}
}

override suspend fun clear() {
Copy link

Choose a reason for hiding this comment

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

이 함수를 호출해줘야 할 때가 있다면, 서버에서 내려오는 이미지가 변경이 되었을 때 호출하면 되는걸까요?

Copy link

@JoYehyun99 JoYehyun99 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다오둥~~~~~ 👍

private val biomeRepository: BiomeRepository,
private val analyticsLogger: AnalyticsLogger,
) : DexRepository {
private var cachedPokemons: List<Pokemon> = emptyList()

override suspend fun warmUp() {
if (localPokemonDataSource.pokemons().isEmpty()) {
localPokemonDataSource.savePokemons(remotePokemonDataSource.pokemons2())
val pokemons = remotePokemonDataSource.pokemons2()
cachePokemonData(pokemons)

Choose a reason for hiding this comment

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

cachePokemonDatapokemonstake해서 넣어주는 것도 좋을둣요!!!

@SuppressLint("StaticFieldLeak")
private var instance: GlideImageCacher? = null

fun init(context: Context) {

Choose a reason for hiding this comment

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

isFirstResource: Boolean,
): Boolean {
con.resume(Unit)
return false

Choose a reason for hiding this comment

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

그러네여 ,, Glide의 기본 성공 처리를 유지 여부에 관련된 것,,,, 메모,,

@murjune murjune merged commit 0bd8290 into an/develop Sep 22, 2024
5 checks passed
@murjune murjune deleted the an/feat-image-cache branch September 22, 2024 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AN_FEAT ✨ 안드 새로운 기능
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants