-
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
week4: 4차 필수과제 진행(xml) #10
Conversation
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 lateinit var binding: ActivitySigninBinding | ||
|
||
private val binding by lazy { ActivitySigninBinding.inflate(layoutInflater) } | ||
private val viewModel by viewModels<SignInViewModel>() |
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.
by viewModels로 초기화될 수 있는 건 몰랐는데 알아갑니당 ㅎㅎ
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.
성장속도 무엇...
@SerialName("code") | ||
val status: Int, |
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.
code, status 통일이 안되어 있는데 이유가 있으실까여?
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.
ㅋㅋㅋㅋㅋㅋㅋㅋ
memberId?.let { memberId -> | ||
ServicePool.authService.getUserInfo(memberId.toInt()).enqueue(object : | ||
Callback<ResponseUserInfoDto> { | ||
override fun onResponse( | ||
call: Call<ResponseUserInfoDto>, | ||
response: Response<ResponseUserInfoDto> | ||
) { | ||
if (response.isSuccessful) { | ||
val userInfo = response.body()?.data | ||
|
||
userInfo?.let { | ||
binding.tvMyPageId.text = " ${it.authenticationId}" | ||
binding.tvMyPagePw.text = " ${it.nickname}" | ||
binding.tvMyPagePhoneNumber.text = " ${it.phone}" | ||
} | ||
} else { | ||
Toast.makeText(requireContext(), "회원 정보를 가져오는데 실패했습니다.", 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.
여기도 뷰모델로 리팩토링하시면 깔끔할 듯 합니당 !
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.
이제 슬슬 MVVM 패턴을 익히실 때입니다...!
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.
이제 슬슬 MVVM 패턴을 익히실 때입니다...!
왜 이런 생각을 하셨는지 궁금합니다!
private fun moveToSignInActivity() { | ||
_navigateToSignIn.value = true | ||
} | ||
|
||
fun doneNavigatingToSignIn() { | ||
_navigateToSignIn.value = false | ||
} |
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.
더 좋은 방법이 있을 것 같습니다!
app/src/main/res/values/strings.xml
Outdated
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.
snake 네이밍 방식으로 하면 모든 글자가 소문자여야 하는 걸로 알고이써요!
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.
성장속도 무엇...
selfDescription = "It's DAME TIME." | ||
), | ||
HomeViewObject.FriendProfile( | ||
profileImage = R.drawable.charlesbarkley_profile, | ||
name = "Charles Barkley", | ||
place = "USA, Philadelphia", | ||
phoneNumber = "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.
여기 mock 데이터는 없어도 되지 않을까용...?
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/build.gradle
Outdated
|
||
// Network | ||
implementation 'com.squareup.retrofit2:retrofit:2.9.0' | ||
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1' | ||
implementation 'com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0' | ||
|
||
// define a BOM and its version | ||
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.10.0")) | ||
|
||
// define any required OkHttp artifacts without version | ||
implementation("com.squareup.okhttp3:okhttp") | ||
implementation("com.squareup.okhttp3:logging-interceptor") |
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 userName = intent.getStringExtra("Name") | ||
val userPlace = intent.getStringExtra("Place") | ||
val memberId = intent.getStringExtra("memberId") // null일 경우에는 0으로 처리 | ||
Log.e("MainActivity", "memberId: ${memberId}") |
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 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.
함수분리를 해주심이 어떨까요?
else -> { | ||
showToast(getString(R.string.toast_SignInActivity_ValidSignIn)) | ||
navigateToMainActivity(userId, userPw, userName, userPlace) | ||
private fun initObserver() { |
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 initViews() { |
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 = binding.etSignUpId.text.toString() | ||
val password = binding.etSignUpPw.text.toString() | ||
val nickname = binding.etSignUpName.text.toString() | ||
val phoneNumber = binding.etSignUpPhoneNumber.text.toString() |
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) 어떠세요?
@SerialName("code") | ||
val status: Int, |
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.
ㅋㅋㅋㅋㅋㅋㅋㅋ
@@ -8,69 +8,69 @@ class HomeViewModel : ViewModel() { | |||
val mockMyProfile = HomeViewObject.MyProfile( | |||
profileImage = R.drawable.sonminjae_profile, | |||
name = "Son minjae", | |||
place = "Korea, Seoul", | |||
phoneNumber = "Korea, Seoul", | |||
selfDescription = "i can win", | |||
enable = true, | |||
) | |||
val mockFriendProfileList = listOf( |
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.
이친구는 이제 날려주셔도 좋지 않을까요~~!!
memberId?.let { memberId -> | ||
ServicePool.authService.getUserInfo(memberId.toInt()).enqueue(object : | ||
Callback<ResponseUserInfoDto> { | ||
override fun onResponse( | ||
call: Call<ResponseUserInfoDto>, | ||
response: Response<ResponseUserInfoDto> | ||
) { | ||
if (response.isSuccessful) { | ||
val userInfo = response.body()?.data | ||
|
||
userInfo?.let { | ||
binding.tvMyPageId.text = " ${it.authenticationId}" | ||
binding.tvMyPagePw.text = " ${it.nickname}" | ||
binding.tvMyPagePhoneNumber.text = " ${it.phone}" | ||
} | ||
} else { | ||
Toast.makeText(requireContext(), "회원 정보를 가져오는데 실패했습니다.", 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.
이제 슬슬 MVVM 패턴을 익히실 때입니다...!
private fun moveToSignInActivity() { | ||
_navigateToSignIn.value = true | ||
} | ||
|
||
fun doneNavigatingToSignIn() { | ||
_navigateToSignIn.value = false | ||
} |
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.
안녕하세요 민재님, 민재님의 리뷰어를 맡게된 권용민이라고 합니다!
필수 과제에 xml과 compose가 있는데요 xml은 제가, compose는 준원님께서 리뷰해주실 예정입니다.
코드에 정답이 없으며, 저희 또한 많이 부족한 사람이므로 공통 로직에서 저와 준원님의 의견이 상충될 수 있습니다. 혹시 그런 상황이 발생한다면, 민재님께서 생각하시는대로 진행하고 말씀해주시면 됩니다!
또 제가 리뷰해드린 내용이라고 해서 정답은 아닙니다. 사람마다 생각이 다를 수 있으며, 제가 틀렸을 수도 있습니다. 납득이 되지 않으면 언제든 질문주시고, 민재님의 생각을 말씀해주세요!
과제하느라 고생하셨습니다! 잘부탁드립니다!
모든 리뷰에 1~5에 해당하는 번호를 남겼습니다. 해당 번호들은 중요도를 나타냅니다.
1,2번은 changes requested,
3번은 comment,
4,5번은 추가정보 정도로 생각해주시면 좋을 것 같습니다.
showToast(getString(R.string.toast_SignInActivity_ValidSignIn)) | ||
navigateToMainActivity(userId, userPw, userName, userPlace) | ||
private fun initObserver() { | ||
viewModel.liveData.observe(this) { |
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]
뷰모델에 존재하는 상태의 변수명이 liveData
인 이유가 있을까요?
변수명은 타입을 나타내기보다 어떤 역할을 하는지 알 수 있게 해주는 것이 좋습니다.
만약 다른 사람이 혹은 몇개월 후의 민재님이 이 코드를 보았을때 어떤 정보를 관찰하고 있는지 알 수 있을까요?
SignInState -> | ||
Toast.makeText(this,SignInState.message,Toast.LENGTH_SHORT).show() | ||
if(SignInState.isSuccess) { | ||
val intent = Intent(this@SignInActivity,MainActivity::class.java).apply{ | ||
SignInState.memberId?.let { memberId -> putExtra("memberId",memberId) } | ||
} | ||
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.
[1]
변수명의 첫 글자는 소문자로 하는 것이 코틀린 공식 컨벤션입니다.
대문자를 사용하게 되면 위와 같이 SignInState.message
, SignInState.memberId
라고 썼을 때 다른 사람들은 SignInState
가 인스턴스라고 인지하기 어렵습니다. object 혹은 companion object로 인지할 확률히 매우 높습니다.
) | ||
|
||
companion object { | ||
val defalutUser = UserInfo() |
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.
[3]
이 친구의 용도는 뭘까요?
companion object { | ||
fun newInstance(memberId: String?): MyPageFragment { | ||
val fragment = MyPageFragment() | ||
val args = Bundle().apply { | ||
putString("memberId", memberId) | ||
} | ||
fragment.arguments = args | ||
return fragment | ||
} | ||
} |
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.tvMyPagePhoneNumber.text = " ${it.phone}" | ||
} | ||
} else { | ||
Toast.makeText(requireContext(), "회원 정보를 가져오는데 실패했습니다.", Toast.LENGTH_SHORT) |
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.
[2]
문자를 하드코딩 하는 것과 strings.xml
에 넣는 것의 기준이 뭘까요?
|
||
class SignUpViewModel : ViewModel() { | ||
private val authService by lazy { ServicePool.authService } | ||
val liveData = MutableLiveData<SignUpState>() |
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]
위에서 했던 리뷰와 같습니다.
val navigateToSignIn: LiveData<Boolean> | ||
get() = _navigateToSignIn |
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]
navigateToSignIn
만 봐서는 로그인으로 갈 수 있는 지를 나타내는 변수인지 알 수 없습니다.
그래서 보통 Boolean
형태의 변수에는 is
혹은 can
과 같은 접두사가 붙습니다.
canNavigateToSignIn
과 같은 형태가 된다면 더 의미가 와닿을 것 같습니다.
private val _navigateToSignIn = MutableLiveData<Boolean>() | ||
val navigateToSignIn: LiveData<Boolean> | ||
get() = _navigateToSignIn |
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.
[5]
여기서는 backing property
로 잘 만들어주셨네요!
위에서 리뷰드린 내용이었었는데, 알고 계셨던 거라면 수정해주시고, 모르고 사용하셨더라면 backing property
에 대해 알아보시면 좋을 것 같습니다.
isSuccess = true, | ||
message = "회원가입 성공! 유저의 ID는 $userId 입니둥" | ||
) | ||
Log.d("SignUp", "data: $data, userId: $userId") |
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.
[5]
개발 중에 작성하신 로그는 지워주시는게 좋습니다!
val error = response.message() | ||
liveData.value = SignUpState( | ||
isSuccess = false, | ||
message = "회원가입 실패 $error" |
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.
[2]
위에서 말씀드렸던 내용이지만, 민재님께서 문자를 하드 코딩하는 것과 strings.xml
에 넣는 것을 구분한 기준이 무엇일까요?
Related issue 🛠
Work Description ✏️
Screenshot 📸
4._XML_.1.mp4
Uncompleted Tasks 😅
To Reviewers 📢
해냈습니다..! Open API 연결 완료했습니다! 리팩토링과 함께 비밀번호 변경 기능도 구현 시도해보겠습니다!