-
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
[2주차/필수/XML] Android UI 구현 심화 #7
Conversation
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
|
||
// ViewModel 의존성 설정 | ||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2" |
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.
뷰모델 접수 시작 ㄷㄷ 멋있다
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.
코드 깔끔하고 넘 좋은디?! 고생 많았다 라따뚜이 코딩,,
binding = ActivityMainBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
val userId = intent.getStringExtra("ID") |
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 써서 구현해보는 건 어떤가요?!
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.
슬슬 data 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.
고생 많으셨습니다~~!!!! 코드가 손댈곳이 많이 줄었는데요?!
binding = ActivityMainBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
val userId = intent.getStringExtra("ID") |
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.
슬슬 data class와 직렬화에 대해 공부해볼까요?
val currentFragment = supportFragmentManager.findFragmentById(binding.fcvMain.id) | ||
if (currentFragment == null) { | ||
supportFragmentManager.beginTransaction() | ||
.add(binding.fcvMain.id, HomeFragment()) | ||
.commit() | ||
} |
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.
함수 분리해주시면 좋을거같아요!
putString("ID", userId) | ||
putString("PW", userPw) | ||
putString("Name", userName) | ||
putString("Place", userPlace) |
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.
뷰모델을 넣었으니 그곳에서 관리해보는건 어떤가요
private fun replaceFragment(fragment: Fragment) { | ||
supportFragmentManager.beginTransaction() | ||
.replace(binding.fcvMain.id, fragment) | ||
.commit() | ||
} |
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.
뭐야 위에랑 코드 중복되잖아요 ㅋㅋㅋㅋㅋㅋ
intent.putExtra("ID", userId) | ||
intent.putExtra("PW", userPw) | ||
intent.putExtra("Name", userName) | ||
intent.putExtra("Place", userPlace) |
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.
묶어주시면 편안할듯 아린님 코드에 파트장님이 리뷰 남기셨네용
val ID_MIN_LENGTH = 6 | ||
val ID_MAX_LENGTH = 10 | ||
val PW_MIN_LENGTH = 8 | ||
val PW_MAX_LENGTH = 12 |
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.
const val은 어떠신가요
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} |
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 fun onDestroyView() { | |
super.onDestroyView() | |
_binding = null | |
} | |
override fun onDestroyView() { | |
_binding = null | |
super.onDestroyView() | |
} |
이쪽이 안정성이 더 좋습니다!! 이유는 뭘까요?!
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.
뭐야 민재 어댑터 왤케 잘썼어
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.
아! 데이터 클래스가 이미 있네요 직렬화로 넘기는 방법을 배워볼까요?!
binding.tvMyPageShowId.text = userId | ||
binding.tvMyPageShowPw.text = userPw | ||
binding.tvMyPageShowName.text = userName | ||
binding.tvMyPageShowPlace.text = userPlace |
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.
with(binding)
<item | ||
android:id="@+id/menu_home" | ||
android:icon="@drawable/ic_home_white_24" | ||
android:title="홈" /> |
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.
여기두 string 써주시면 굿굿~~~
companion object { | ||
const val TYPE_MY_PROFILE = 0 | ||
const val TYPE_FRIEND_PROFILE = 1 | ||
} |
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 fun getItemCount(): Int { | ||
return friendList.size + 1 |
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.
여기 +1 해서 어디에 나타나나욤?
} | ||
|
||
override fun getItemViewType(position: Int): Int { | ||
return if (position == 0) TYPE_MY_PROFILE else TYPE_FRIEND_PROFILE |
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.
이렇게 구분하는 함수를 만들 수도 있겠네여
is MyProfileViewHolder -> { | ||
holder.onBind(myProfile) | ||
} | ||
|
||
is FriendViewHolder -> { | ||
holder.onBind(friendList[position - 1]) |
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.
너무 깔끔해요!!!!
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.
너무 수고하셨습니다~ 엄청 많이 고민하고 공부하신게 느껴졌어용! 많이 배우고 갑니당
|
||
binding.btnSignInSignUp.setOnClickListener { | ||
val intent = Intent(this, SignUpActivity::class.java) | ||
startActivity(intent) |
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.
클릭리스너도 함수화 해주는 건 어떨까요?
|
||
private fun showToast(message: String) { | ||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show() | ||
} |
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.
토스트 부분도 함수로 만들어주는 거 좋은 것 같아용!!
navigateToSignInActivity() | ||
} | ||
} | ||
} |
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.
안드를 이제 시작했는데 when 이리 잘 쓰다니... 이 부분은 말 그대로 검증하는 부분이니까 뷰모델로 빼도 괜찮을 것 같아용!! 비즈니스 로직만 한 번 분리해보셔요~
name = "Charles Barkley", | ||
place = "USA, Philadelphia", | ||
selfDescription = "CHUCK CHUCK" | ||
) |
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.
코리조 없는 거 서운이슈...
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" |
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.
width가 match이니까 start랑 end 값은 주지 않아도 괜찮아요! 우리의 소중한 리소스를 절약해봐요 ㅎㅎ
Related issue 🛠
Work Description ✏️
Screenshot 📸
2._XML_.mp4
Uncompleted Tasks 😅
To Reviewers 📢
피를 토하며 열심히 해보았습니다.. 굉장히 험난했지만 1주차 과제때에 비해 코드가 굉장히 나아지지 않았나 스스로 생각하며 위안을 얻어 봅니다..!