-
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
[AN-REFACTOR] 포켓몬 도감 데이터는 데이터 레이어에서 불러온다. #36
Merged
sh1mj1
merged 37 commits into
an/develop
from
an/refactor/dex_load_data_from_data_layer
Jul 21, 2024
Merged
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
563f163
chore: pokemon2 패키지 이름을 dex 로 변경한다
sh1mj1 a844f29
refactor: PokemonListFragment 에서 뷰모델을 BaseViewModelFactory 을 통해 생성한다
sh1mj1 82bd1a7
refactor: PokemonListFragment 어댑터를 lazy 하게 생성한다
sh1mj1 f459f0a
refactor: PokemonDetailFragment 에서 뷰모델을 BaseViewModelFactory 을 통해 생성한다
sh1mj1 48aac06
refactor: PokemonDetailFragment 의 어댑터를 lazy 하게 생성한다
sh1mj1 ae48877
feat(data/model/Type): 포켓몬 타입 원시값 포장, 캐싱한다
sh1mj1 9f2d5de
feat(data/model/Pokemon): 포켓몬 데이터
sh1mj1 0357661
feat: 포켓몬 목록을 in-memory 에서 불러온다
sh1mj1 3f1d6a3
feat(dex/model/PokemonUiModel): id, 이름, 이미지, 타입 목록을 가지는 ui model
sh1mj1 df11966
feat(TypeUiModel): 데이터 레이어의 타입으로부터 타입 ui 모델로 만든다
sh1mj1 d89bdfa
refactor: pokemonUiModel 을 모델 패키지의 것으로 교체한다
sh1mj1 d8f8f02
refactor: 포켓몬 목록 화면에서 데이터 레이어로부터 데이터를 가져온다
sh1mj1 dd9bc42
feat(data/model/Stat): 스탯 이름과 수치를 프로퍼티로 가진다
sh1mj1 be20db2
feat(presentation/.../StatUiModel): 스탯 이름, 수치, progress 를 프로퍼티로 가진다
sh1mj1 dd7820e
feat(presentation/.../PokemonUiModel): id, 도감번호, 이름, 이미지, 타입 목록을 가진다
sh1mj1 c96577a
feat(data/.../PokemonDetail): 포켓몬, 스탯 목록, 특성 목록, 키, 무게를 가진다
sh1mj1 69e8046
feat(presentation/.../PokemonDetailUiModel): 포켓몬 상세 정보 ui 모델을 가진다
sh1mj1 3a34b40
feat(PokemonDetailDataSource): 포켓몬 상세 정보를 가져온다
sh1mj1 265d4a8
refactor($PokemonDetail): 포켓몬 상세 페이지에서 ui 모델을 사용한다
sh1mj1 8f3c37d
refactor(PokemonDetailViewModel): 데이터 소스로부터 포켓몬 상세 정보를 불러온다
sh1mj1 77ebe4b
refactor(StatUiModel): 능력치 값의 limit 를 설정
sh1mj1 74b1248
refactor(item_stat.xml): 능력치 아이템의 텍스트 너비 조정
sh1mj1 72aa5fd
chore: 사용하지 않는 ui,데이터 모델 삭제
sh1mj1 38fa2a9
refactor(PokemonListFragment): 포켓몬 어댑터에 리스너 함수의 참조가 아닌 뷰모델을 넘긴다
sh1mj1 ab9777b
Merge branch 'an/develop' into an/refactor/dex_load_data_from_data_layer
sh1mj1 79cecea
refactor: 타입 이름을 한글로 설정한다
sh1mj1 4d87be4
chore(PokemonDetailViewModel): 로그 제거
sh1mj1 42ce099
refactor: data/model/Type 을 enum class 로 변경한다
sh1mj1 bf666c5
chore: 임시 포켓몬 리스트 데이터 소스 클래스 이름 변경
sh1mj1 5758312
chore: 임시 포켓몬 리스트 데이터 소스 인터페이스 제거
sh1mj1 0ee5fdc
feat: PokemonListRepository 인터페이스와 Fake 구현체를 만든다
sh1mj1 efa2011
refactor: 포켓몬 목록 뷰모델이 레포지토리로부터 포켓몬을 가져온다
sh1mj1 95f7d7a
chore: 임시 포켓몬 디테일 데이터 소스 클래스 이름 변경
sh1mj1 01f16b4
chore: 임시 포켓몬 상세 데이터 소스 인터페이스 제거
sh1mj1 b832591
feat: 포켓몬 상세 인터페이스와 Fake 구현체를 만든다
sh1mj1 c1ef63c
refactor: 포켓몬 상세 데이터 클래스에 있던 더미 데이터를 fake 데이터 소스로 이동
sh1mj1 9ac6345
refactor: 포켓몬 상세 뷰모델이 레포지토리로부터 포켓몬을 가져온다
sh1mj1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 7 additions & 0 deletions
7
android/app/src/main/java/poke/rogue/helper/data/datasource/DummyPokemonDetailDataSource.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 poke.rogue.helper.data.datasource | ||
|
||
import poke.rogue.helper.data.model.PokemonDetail | ||
|
||
class DummyPokemonDetailDataSource : PokemonDetailDataSource { | ||
override fun pokemonDetail(id: Long): PokemonDetail = PokemonDetail.DUMMY | ||
} |
232 changes: 232 additions & 0 deletions
232
android/app/src/main/java/poke/rogue/helper/data/datasource/InMemoryPokemonListDataSource.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,232 @@ | ||
package poke.rogue.helper.data.datasource | ||
|
||
import poke.rogue.helper.data.model.Pokemon | ||
import poke.rogue.helper.data.model.Type | ||
|
||
class InMemoryPokemonListDataSource : PokemonListDataSource { | ||
override fun pokemons(): List<Pokemon> = POKEMONS | ||
|
||
companion object { | ||
private const val FORMAT_POKEMON_IMAGE_URL = | ||
"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other" + | ||
"/official-artwork/" | ||
|
||
private const val POSTFIX_PNG = ".png" | ||
|
||
private fun pokemonImageUrl(pokemonId: Long) = FORMAT_POKEMON_IMAGE_URL + pokemonId + POSTFIX_PNG | ||
|
||
private val POKEMONS: List<Pokemon> = | ||
listOf( | ||
Pokemon( | ||
id = 1, | ||
dexNumber = 1, | ||
name = "이상해씨", | ||
imageUrl = pokemonImageUrl(pokemonId = 1), | ||
types = listOf(Type.of("풀"), Type.of("독")), | ||
), | ||
Pokemon( | ||
id = 2, | ||
dexNumber = 2, | ||
name = "이상해풀", | ||
imageUrl = pokemonImageUrl(pokemonId = 2), | ||
types = listOf(Type.of("풀"), Type.of("독")), | ||
), | ||
Pokemon( | ||
id = 3, | ||
dexNumber = 3, | ||
name = "이상해꽃", | ||
imageUrl = pokemonImageUrl(pokemonId = 3), | ||
types = listOf(Type.of("풀"), Type.of("독")), | ||
), | ||
Pokemon( | ||
id = 4, | ||
dexNumber = 4, | ||
name = "파이리", | ||
imageUrl = pokemonImageUrl(pokemonId = 4), | ||
types = listOf(Type.of("불꽃")), | ||
), | ||
Pokemon( | ||
id = 5, | ||
dexNumber = 5, | ||
name = "리자드", | ||
imageUrl = pokemonImageUrl(pokemonId = 5), | ||
types = listOf(Type.of("불꽃")), | ||
), | ||
Pokemon( | ||
id = 6, | ||
dexNumber = 6, | ||
name = "리자몽", | ||
imageUrl = pokemonImageUrl(pokemonId = 6), | ||
types = listOf(Type.of("불꽃"), Type.of("비행")), | ||
), | ||
Pokemon( | ||
id = 7, | ||
dexNumber = 7, | ||
name = "꼬부기", | ||
imageUrl = pokemonImageUrl(pokemonId = 7), | ||
types = listOf(Type.of("물")), | ||
), | ||
Pokemon( | ||
id = 8, | ||
dexNumber = 8, | ||
name = "어니부기", | ||
imageUrl = pokemonImageUrl(pokemonId = 8), | ||
types = listOf(Type.of("물")), | ||
), | ||
Pokemon( | ||
id = 9, | ||
dexNumber = 9, | ||
name = "거북왕", | ||
imageUrl = pokemonImageUrl(pokemonId = 9), | ||
types = listOf(Type.of("물")), | ||
), | ||
Pokemon( | ||
id = 10, | ||
dexNumber = 10, | ||
name = "캐터피", | ||
imageUrl = pokemonImageUrl(pokemonId = 10), | ||
types = listOf(Type.of("벌레")), | ||
), | ||
Pokemon( | ||
id = 11, | ||
dexNumber = 11, | ||
name = "단데기", | ||
imageUrl = pokemonImageUrl(pokemonId = 11), | ||
types = listOf(Type.of("벌레")), | ||
), | ||
Pokemon( | ||
id = 12, | ||
dexNumber = 12, | ||
name = "버터플", | ||
imageUrl = pokemonImageUrl(pokemonId = 12), | ||
types = listOf(Type.of("벌레"), Type.of("비행")), | ||
), | ||
Pokemon( | ||
id = 13, | ||
dexNumber = 13, | ||
name = "뿔충이", | ||
imageUrl = pokemonImageUrl(pokemonId = 13), | ||
types = listOf(Type.of("벌레"), Type.of("독")), | ||
), | ||
Pokemon( | ||
id = 14, | ||
dexNumber = 14, | ||
name = "딱충이", | ||
imageUrl = pokemonImageUrl(pokemonId = 14), | ||
types = listOf(Type.of("벌레"), Type.of("독")), | ||
), | ||
Pokemon( | ||
id = 15, | ||
dexNumber = 15, | ||
name = "독침붕", | ||
imageUrl = pokemonImageUrl(pokemonId = 15), | ||
types = listOf(Type.of("벌레"), Type.of("독")), | ||
), | ||
Pokemon( | ||
id = 16, | ||
dexNumber = 16, | ||
name = "구구", | ||
imageUrl = pokemonImageUrl(pokemonId = 16), | ||
types = listOf(Type.of("노말"), Type.of("비행")), | ||
), | ||
Pokemon( | ||
id = 17, | ||
dexNumber = 17, | ||
name = "피죤", | ||
imageUrl = pokemonImageUrl(pokemonId = 17), | ||
types = listOf(Type.of("노말"), Type.of("비행")), | ||
), | ||
Pokemon( | ||
id = 18, | ||
dexNumber = 18, | ||
name = "피죤투", | ||
imageUrl = pokemonImageUrl(pokemonId = 18), | ||
types = listOf(Type.of("노말"), Type.of("비행")), | ||
), | ||
Pokemon( | ||
id = 19, | ||
dexNumber = 19, | ||
name = "꼬렛", | ||
imageUrl = pokemonImageUrl(pokemonId = 19), | ||
types = listOf(Type.of("노말")), | ||
), | ||
Pokemon( | ||
id = 20, | ||
dexNumber = 20, | ||
name = "레트라", | ||
imageUrl = pokemonImageUrl(pokemonId = 20), | ||
types = listOf(Type.of("노말")), | ||
), | ||
Pokemon( | ||
id = 21, | ||
dexNumber = 21, | ||
name = "깨비참", | ||
imageUrl = pokemonImageUrl(pokemonId = 21), | ||
types = listOf(Type.of("노말"), Type.of("비행")), | ||
), | ||
Pokemon( | ||
id = 22, | ||
dexNumber = 22, | ||
name = "깨비드릴조", | ||
imageUrl = pokemonImageUrl(pokemonId = 22), | ||
types = listOf(Type.of("노말"), Type.of("비행")), | ||
), | ||
Pokemon( | ||
id = 23, | ||
dexNumber = 23, | ||
name = "아보", | ||
imageUrl = pokemonImageUrl(pokemonId = 23), | ||
types = listOf(Type.of("독")), | ||
), | ||
Pokemon( | ||
id = 24, | ||
dexNumber = 24, | ||
name = "아보크", | ||
imageUrl = pokemonImageUrl(pokemonId = 24), | ||
types = listOf(Type.of("독")), | ||
), | ||
Pokemon( | ||
id = 25, | ||
dexNumber = 25, | ||
name = "피카츄", | ||
imageUrl = pokemonImageUrl(pokemonId = 25), | ||
types = listOf(Type.of("전기")), | ||
), | ||
Pokemon( | ||
id = 26, | ||
dexNumber = 26, | ||
name = "라이츄", | ||
imageUrl = pokemonImageUrl(pokemonId = 26), | ||
types = listOf(Type.of("전기")), | ||
), | ||
Pokemon( | ||
id = 27, | ||
dexNumber = 27, | ||
name = "모래두지", | ||
imageUrl = pokemonImageUrl(pokemonId = 27), | ||
types = listOf(Type.of("땅")), | ||
), | ||
Pokemon( | ||
id = 28, | ||
dexNumber = 28, | ||
name = "고지", | ||
imageUrl = pokemonImageUrl(pokemonId = 28), | ||
types = listOf(Type.of("땅")), | ||
), | ||
Pokemon( | ||
id = 29, | ||
dexNumber = 29, | ||
name = "니드런", | ||
imageUrl = pokemonImageUrl(pokemonId = 29), | ||
types = listOf(Type.of("독")), | ||
), | ||
Pokemon( | ||
id = 30, | ||
dexNumber = 30, | ||
name = "니드리나", | ||
imageUrl = pokemonImageUrl(pokemonId = 30), | ||
types = listOf(Type.of("독")), | ||
), | ||
) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
android/app/src/main/java/poke/rogue/helper/data/datasource/PokemonDetailDataSource.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 poke.rogue.helper.data.datasource | ||
|
||
import poke.rogue.helper.data.model.PokemonDetail | ||
|
||
interface PokemonDetailDataSource { | ||
fun pokemonDetail(id: Long): PokemonDetail | ||
} |
7 changes: 7 additions & 0 deletions
7
android/app/src/main/java/poke/rogue/helper/data/datasource/PokemonListDataSource.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 poke.rogue.helper.data.datasource | ||
|
||
import poke.rogue.helper.data.model.Pokemon | ||
|
||
interface PokemonListDataSource { | ||
fun pokemons(): List<Pokemon> | ||
} |
25 changes: 25 additions & 0 deletions
25
android/app/src/main/java/poke/rogue/helper/data/model/Pokemon.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,25 @@ | ||
package poke.rogue.helper.data.model | ||
|
||
data class Pokemon( | ||
val id: Long, | ||
val dexNumber: Long, | ||
val name: String, | ||
val imageUrl: String, | ||
val types: List<Type>, | ||
) { | ||
companion object { | ||
private const val DUMMY_POKEMON_NAME = "이상해씨" | ||
private const val DUMMY_IMAGE_URL = | ||
"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/1.png" | ||
private val DUMMY_TYPES = listOf(Type.of("풀"), Type.of("독")) | ||
|
||
val DUMMY = | ||
Pokemon( | ||
id = 1, | ||
dexNumber = 1, | ||
name = DUMMY_POKEMON_NAME, | ||
imageUrl = DUMMY_IMAGE_URL, | ||
types = DUMMY_TYPES, | ||
) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
android/app/src/main/java/poke/rogue/helper/data/model/PokemonDetail.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,29 @@ | ||
package poke.rogue.helper.data.model | ||
|
||
data class PokemonDetail( | ||
val pokemon: Pokemon, | ||
val stats: List<Stat>, | ||
val abilities: List<String>, | ||
val height: Float, | ||
val weight: Float, | ||
) { | ||
companion object { | ||
val DUMMY = | ||
PokemonDetail( | ||
pokemon = Pokemon.DUMMY, | ||
stats = | ||
listOf( | ||
Stat("HP", 45), | ||
Stat("공격", 49), | ||
Stat("방어", 49), | ||
Stat("특수공격", 65), | ||
Stat("특수방어", 65), | ||
Stat("스피드", 45), | ||
Stat("총합", 318), | ||
), | ||
abilities = listOf("그래스메이커", "심록", "엽록소"), | ||
height = 0.7f, | ||
weight = 6.9f, | ||
) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
android/app/src/main/java/poke/rogue/helper/data/model/Stat.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,6 @@ | ||
package poke.rogue.helper.data.model | ||
|
||
data class Stat( | ||
val name: String, | ||
val amount: Int, | ||
) |
30 changes: 30 additions & 0 deletions
30
android/app/src/main/java/poke/rogue/helper/data/model/Type.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,30 @@ | ||
package poke.rogue.helper.data.model | ||
|
||
@JvmInline | ||
value class Type private constructor(val name: String) { | ||
companion object { | ||
private val TYPES: MutableMap<String, Type> = | ||
mutableMapOf( | ||
"노말" to Type("노말"), | ||
"불" to Type("불"), | ||
"물" to Type("물"), | ||
"전기" to Type("전기"), | ||
"풀" to Type("풀"), | ||
"얼음" to Type("얼음"), | ||
"격투" to Type("격투"), | ||
"독" to Type("독"), | ||
"땅" to Type("땅"), | ||
"비행" to Type("비행"), | ||
"에스퍼" to Type("에스퍼"), | ||
"벌레" to Type("벌레"), | ||
"돌" to Type("돌"), | ||
"고스트" to Type("고스트"), | ||
"드래곤" to Type("드래곤"), | ||
"악" to Type("악"), | ||
"강철" to Type("강철"), | ||
"페어리" to Type("페어리"), | ||
) | ||
|
||
fun of(name: String): Type = TYPES.getOrPut(name) { Type(name) } | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...ion/poketmon2/PokeMonItemClickListener.kt → ...sentation/dex/PokeMonItemClickListener.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
2 changes: 1 addition & 1 deletion
2
...presentation/poketmon2/PokemonActivity.kt → ...elper/presentation/dex/PokemonActivity.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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Type
을 value class 로 wrapping 하신 것은 타입이 추가될 경우를 고려한 것인가요??심지는 확장성을 더 중요하게 생각하는 걸까요?
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.
맞습니다.
그리고 lv1 의 로또 미션 때처럼, 18 개의 객체만 미리 만들어두도록 캐싱하면 좋을 거라 생각했습니다.
이 부분은 생각하지 못한 부분이네요.
enum class 로 구현하는 게 좋을 것 같네요.
새 타입이 추가되는 시점은 새 세대의 닌텐도 게임이 추가되는 시점입니다.
그래서 확장성보다 컴파일 시점에 검사할 수 있도록 하는 게 좋아보이네요.
예니 생각을 들어보고, 결론 내어서 수정하면 될 것 같아요
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.
저도 enum class로 구현 좋은 것 같다는 생각입니다 🙃