Skip to content

Conversation

@hansh0101
Copy link
Contributor

๐Ÿ“Œ Related Issue

๐Ÿ“ What's-New

  • ํ•„์ˆ˜๊ณผ์ œ 1. SharedPreferences๋ฅผ ์‚ฌ์šฉํ•œ ์ž๋™๋กœ๊ทธ์ธ / ์ž๋™๋กœ๊ทธ์ธ ํ•ด์ œ ๊ตฌํ˜„
  • ์„ฑ์žฅ๊ณผ์ œ 1. Navigation Component๋ฅผ ์‚ฌ์šฉํ•œ ์˜จ๋ณด๋”ฉ ํ™”๋ฉด ๋งŒ๋“ค๊ธฐ
  • ๋„์ „๊ณผ์ œ 1. Room์„ ์‚ฌ์šฉํ•œ ์ž๋™๋กœ๊ทธ์ธ ๋กœ์ง ๋งŒ๋“ค๊ธฐ

โž• Additional

1์ฐจ ์„ธ๋ฏธ๋‚˜

  • Hilt๋ฅผ ์‚ฌ์šฉํ•ด ์˜์กด์„ฑ ์ฃผ์ž…
  • Room์„ ์‚ฌ์šฉํ•ด ๋‚ด๋ถ€ DB๋ฅผ ํ™œ์šฉํ•œ ํšŒ์›๊ฐ€์ž…, ๋กœ๊ทธ์ธ, ํšŒ์›์ •๋ณด ์ˆ˜์ •
  • EncryptedSharedPreference๋ฅผ ์‚ฌ์šฉํ•ด ์•„์ด๋”” ๊ธฐ์–ตํ•˜๊ธฐ

2์ฐจ ์„ธ๋ฏธ๋‚˜

  • Room์„ ์ด์šฉํ•ด RecyclerView Item ์ด๋™, ์‚ญ์ œ ์‹œ ๋‚ด๋ถ€ DB์—์„œ๋„ ์—…๋ฐ์ดํŠธ
  • (Encrypted)SharedPreference๋ฅผ ์‚ฌ์šฉํ•ด ์ž๋™ ๋กœ๊ทธ์ธ ๊ตฌํ˜„
  • FrameLayout์„ ํ™œ์šฉ, RecyclerView Item ์‚ญ์ œ ์‹œ๋„ ์‹œ DELETE ๋ฒ„ํŠผ ๋ˆŒ๋Ÿฌ์•ผ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋„๋ก MyItemTouchHelper ๊ตฌํ˜„

3์ฐจ ์„ธ๋ฏธ๋‚˜

  • Navigation Component๋ฅผ ์ด์šฉํ•ด BottomNavigationView ๊ตฌํ˜„

4์ฐจ ์„ธ๋ฏธ๋‚˜

  • Github API ํ˜ธ์ถœ ํšŸ์ˆ˜ ์ œํ•œ ์™„ํ™”๋ฅผ ์œ„ํ•ด Header๋ฅผ ์ถ”๊ฐ€ํ•œ Interceptor ๊ตฌํ˜„
  • ํšŒ์›๊ฐ€์ž… ์‹œ Github ID๋ฅผ ID๋กœ ์ž…๋ ฅํ•˜๋„๋ก ์œ ๋„, ๋กœ๊ทธ์ธ ์‹œ ํ•ด๋‹น Github ID์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ํ‘œ์‹œํ•˜๋„๋ก ๊ตฌํ˜„

7์ฐจ ์„ธ๋ฏธ๋‚˜

  • StateFlow๋ฅผ ํ™œ์šฉํ•œ Presentation Layer์—์„œ์˜ UI ์กฐ์ž‘ ๊ตฌํ˜„

- SharedPreferences๋ฅผ ํ™œ์šฉํ•œ ์ž๋™ ๋กœ๊ทธ์ธ ๊ตฌํ˜„
- SharedPreferences๋ฅผ ํ™œ์šฉํ•œ ์ž๋™ ๋กœ๊ทธ์ธ ๊ตฌํ˜„
- Navigation Componenet๋ฅผ ํ™œ์šฉํ•œ ์˜จ๋ณด๋”ฉ ๊ตฌํ˜„
- Room์„ ์‚ฌ์šฉํ•œ ์ž๋™ ๋กœ๊ทธ์ธ ๊ตฌํ˜„
- StateFlow ์‚ฌ์šฉํ•œ ์ƒํƒœ ๊ฐฑ์‹ 
@hansh0101 hansh0101 self-assigned this Jun 10, 2022
@hansh0101 hansh0101 linked an issue Jun 10, 2022 that may be closed by this pull request
3 tasks
Copy link
Member

@yeoncheong yeoncheong left a comment

Choose a reason for hiding this comment

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

์ตœ๊ณ ์˜ ์Šค์Šน๋‹˜ (_ _)


var autoLogin: Boolean
set(value) = dataStore.edit { putBoolean("AUTO_LOGIN", value) }
get() = dataStore.getBoolean("AUTO_LOGIN", false)
Copy link
Member

Choose a reason for hiding this comment

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

sharedPreference๋ณด๋‹ค dataStore๋ฅผ ์‚ฌ์šฉํ•˜์˜€์„ ๋•Œ์˜ ์ด์ ์ด ๋ฌด์—‡์ด ์žˆ๋‚˜์š”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DataStore๋ฅผ ๊ณต๋ถ€ํ•ด๋ณด๋ ค๊ณ  ํ•˜๊ธด ํ–ˆ๋Š”๋ฐ, ๊ฒฐ๊ณผ์ ์œผ๋กœ ๋ณด๋ฉด ์ € dataStore๋ผ๋Š” ์• ๋Š” SharedPreferences์ž…๋‹ˆ๋‹ค. ์™œ๋ƒ๋ฉด context.getSharedPreferences() ๋ฉ”์„œ๋“œ๋กœ ๊ฐ€์ ธ์˜ค๊ธฐ ๋•Œ๋ฌธ์ด์ฃ .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

์ œ๊ฐ€ ๊ณต๋ถ€ํ•ด๋ณด๋ ค๊ณ  ํ•œ ์ด์œ ๋Š” ์ด๋Ÿฐ 3๊ฐ€์ง€ ํŠน์ง•์ด ์žˆ์–ด์„œ๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

  • DataStore๋Š” ์ฝ”๋ฃจํ‹ด๊ณผ Flow๋ฅผ ํ†ตํ•ด ์ฝ๊ณ  ์“ฐ๊ธฐ์— ๋Œ€ํ•œ ๋น„๋™๊ธฐ API๋ฅผ ์ œ๊ณตํ•œ๋‹ค.
  • DataStore๋Š” UI ์Šค๋ ˆ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด๋„ ์•ˆ์ „ํ•˜๋‹ค.
  • runtime exception์œผ๋กœ๋ถ€ํ„ฐ ์•ˆ์ „ํ•˜๋‹ค.

@AndroidEntryPoint
class OnBoardingFirstFragment : BaseFragment<FragmentOnBoardingFirstBinding>() {
override val TAG: String
get() = OnBoardingFirstFragment::class.java.simpleName
Copy link
Member

Choose a reason for hiding this comment

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

TAG์˜ ์—ญํ• ์€ ๋ฌด์—‡์ธ๊ฐ€์š”?

Copy link
Contributor Author

@hansh0101 hansh0101 Jun 14, 2022

Choose a reason for hiding this comment

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

์ด๊ฑด 1์ฐจ ์„ธ๋ฏธ๋‚˜ ๊ณผ์ œ๋ฅผ ํ•  ๋•Œ ์ƒ๋ช…์ฃผ๊ธฐ๋ฅผ Log๋กœ ๋‚จ๊ธฐ๊ณ  ์‹ถ์–ด์„œ ์‚ฌ์šฉํ•œ TAG์ž…๋‹ˆ๋‹ค. OnBoardingFirstFragment::class.java์˜ simpleName์€ ๋ง ๊ทธ๋Œ€๋กœ ์ด Fragment์˜ name, ์ฆ‰ OnBoardingFirstFragment๊ฐ€ ๋ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด TAG๋Š” BaseFragment์—์„œ ์ƒ๋ช…์ฃผ๊ธฐ ์ฝœ๋ฐฑ ๋ฉ”์„œ๋“œ(onCreateView, onViewCreated ๋“ฑ)์—์„œ Log๋ฅผ ๋‚จ๊ธธ ๋•Œ TAG๋กœ์„œ ์ž‘์šฉํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ €๊ฐ™์€ ๊ฒฝ์šฐ๋Š” lifecycle์— observer๋ฅผ ๋ถ™์—ฌ ์ƒ๋ช…์ฃผ๊ธฐ๋งˆ๋‹ค Log๋ฅผ ๋‚จ๊ธฐ๋„๋ก ํ–ˆ์Šต๋‹ˆ๋‹ค.

https://github.com/KINGSAMJO/iOS_Seunghyeon/blob/seminar%2F7/app/src/main/java/co/kr/sopt_seminar_30th/util/MyDefaultLifecycleObserver.kt

์œ„ ๋งํฌ๋Š” ์ œ๊ฐ€ DefaultLifecycleObserver๋ฅผ ์ƒ์†๋ฐ›์•„ ๊ตฌํ˜„ํ•œ Observer์ž…๋‹ˆ๋‹ค.

val isEmpty: LiveData<Boolean> get() = _isEmpty

private var _isEmailIncorrect = SingleLiveEvent<Boolean>()
val isEmailIncorrect: LiveData<Boolean> get() = _isEmailIncorrect
Copy link
Member

Choose a reason for hiding this comment

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

LiveData๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ get()์ด ํ•„์š”ํ•œ ์ด์œ ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€์š”? ๊ฐ’์ด ๊ณ„์† ๋ณ€๊ฒฝ๋ ๊ฑฐ๋ผ๋ฉด MutableLiveData๋ฅผ ์‚ฌ์šฉํ•ด๋„ ๋˜์ง€ ์•Š๋‚˜์š”?

Copy link
Contributor Author

@hansh0101 hansh0101 Jun 14, 2022

Choose a reason for hiding this comment

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

get()์„ ์‚ฌ์šฉํ•ด ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์€ ๊ฐ’์„ ๊ณ„์† ๋ณ€๊ฒฝ์‹œํ‚ค๊ธฐ์˜ ๋ชฉ์ ๋ณด๋‹ค๋Š” ํด๋ž˜์Šค ์™ธ๋ถ€์—์„œ ๊ฐ’์„ ๋งˆ์Œ๋Œ€๋กœ ๋ณ€๊ฒฝํ•˜์ง€ ๋ชปํ•˜๋„๋ก ํ•˜๋Š” ๊ฒƒ์— ๋” ํฐ ๋ชฉ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ €์˜ ๊ฒฝ์šฐ ์ผ๋ฐ˜์ ์œผ๋กœ _ prefix๊ฐ€ ๋ถ™์€ MutableLiveData ๋ณ€์ˆ˜๋Š” ViewModel ํด๋ž˜์Šค ์•ˆ์—์„œ๋งŒ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ private์œผ๋กœ ์ง€์ •ํ•˜๊ณ  ViewModel ํด๋ž˜์Šค ์™ธ๋ถ€์—์„œ LiveData์˜ ๊ฐ’์„ ์ฐธ์กฐํ•˜๊ณ  ์‹ถ์„ ๊ฒฝ์šฐ์—๋Š” val๋กœ ์„ ์–ธํ•ด set(value)๋ฅผ ๋ถˆ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•œ ๋’ค get()์œผ๋กœ ์›๋ณธ ๋ฐ์ดํ„ฐ(_ prefix๊ฐ€ ๋ถ™์€)์˜ ๊ฐ’์„ ๊ฐ€์ ธ์˜ค๋Š” ํ˜•ํƒœ์ž…๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ฌด๋ถ„๋ณ„ํ•˜๊ฒŒ ViewModel ํด๋ž˜์Šค์˜ ์™ธ๋ถ€์—์„œ MutableLiveData ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋Š” ํ–‰์œ„๋ฅผ ๋ง‰์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด LiveData ๊ฐ’์˜ ์กฐ์ž‘์€ ViewModel ํด๋ž˜์Šค ์•ˆ์—์„œ๋งŒ ์ผ์–ด๋‚˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ถ”ํ›„์— ์œ ์ง€๋ณด์ˆ˜๋ฅผ ํ•˜๊ฒŒ ๋˜๊ฑฐ๋‚˜ ์ฝ”๋“œ์— ์ˆ˜์ •์„ ํ•˜๊ฑฐ๋‚˜ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ๋•Œ LiveData์˜ ๊ฐ’์„ ์กฐ์ž‘ํ•˜๋Š” ๋ถ€๋ถ„์€ ViewModel ํด๋ž˜์Šค ์•ˆ์—๋งŒ ์žˆ์œผ๋‹ˆ ViewModel ํด๋ž˜์Šค ์ฝ”๋“œ๋งŒ ๋ณด๋ฉด ๋œ๋‹ค๋Š” ์žฅ์ ์ด ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Assignment] 7์ฐจ ์„ธ๋ฏธ๋‚˜ ๊ณผ์ œ

3 participants