-
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
Week2 #4
Week2 #4
Conversation
} | ||
|
||
override fun onCreate() { | ||
prefs = UserSharedPreferences(applicationContext) |
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.
참고로 여기에 this를 써도 됩니다!
this의 경우 Application 이 클래스 자체를 의미하는데, Activity가 Context 그 자체인만큼, Application 또한 앱의 Context 그 자체입니다. 따라서 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.
this로 수정하였습니다!
this.logout() | ||
this.withdrawal() |
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.
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.
대환이 형이 this를 쓰는 것이 명시적일 수도 있다 라고 하셔서 그냥 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.
취향차이 입니다 ㅎ
val user = User( | ||
etSignupId.text.toString(), | ||
etSignupPassword.text.toString(), | ||
etSignupName.text.toString(), | ||
etSignupSpecialty.text.toString(), | ||
) | ||
|
||
if (user.id?.length !in 6..10) { | ||
showShortToast(getString(R.string.sign_up_id_err_msg)) | ||
} else if (password.length !in 8..12) { | ||
} else if (user.password?.length !in 8..12) { | ||
showShortToast(getString(R.string.sign_up_password_err_msg)) | ||
} else if (name.isEmpty()) { | ||
} else if (user.name?.isEmpty() == true) { | ||
showShortToast(getString(R.string.sign_up_name_err_msg)) | ||
} else if (specialty.isEmpty()) { | ||
} else if (user.specialty?.isEmpty() == true) { | ||
showShortToast(getString(R.string.sign_up_specialty_err_msg)) |
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.
섬세하다 ㄷㄷ
} | ||
|
||
fun setString(key: String, value: String?) { | ||
prefs.edit().putString(key, value).apply() |
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.
edit 확장함수를 사용하면 더욱 깔끔한 코드가 될 수 있습니다 !
@SuppressLint("ApplySharedPref")
public inline fun SharedPreferences.edit(
commit: Boolean = false,
action: SharedPreferences.Editor.() -> Unit
) {
val editor = edit()
action(editor)
if (commit) {
editor.commit()
} else {
editor.apply()
}
}
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.
이 방식도 한번 사용해보도록 하겠습니다!!
android:id="@+id/tv_dog_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="강아지 이름" |
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.
만약 tools를 사용하시면,
왜 리소스 추출을 안 했냐는 질문을 피할 수 있습니다 ㅎㅎ
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 const val SIZE_SMALL = "소형견" | ||
private const val SIZE_MEDIUM = "중형견" | ||
private const val SIZE_LARGE = "대형견" | ||
} |
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.
companion object를 사용한 이유가 단순히 코드를 간결하게 하기 위함인지 궁금합니다..!
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.
그냥 "소형견" 이런 식으로 사용하면 나중에 오타가 나거나 수정이 필요할 때 불편할 것이라고 생각되어서 이렇게 작성했는데 저도 자세한 이유는 찾아봐야겠네요..ㅎ
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.
리뷰가 늦어져 죄송해요 ㅎ
요즘 일때매 신경을 많이 못썼는데, 이제 많이 볼게용 고생하셨습니다.
import org.android.go.sopt.util.UserSharedPreferences | ||
|
||
class SoptApplication : Application() { | ||
companion object{ |
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.
companion object 는 kotlin 에서 주로 최하단에 위치합니다
(위에둬도 상관은 없지만..ㅎ)
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 onCreate() { | ||
prefs = UserSharedPreferences(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.
sharedPreferences 를 왜 사용하며, 앱 구동 및 종료시 메모리에서 어떻게 동작하는지,
왜 companion object (java static) 으로 구성하는지 를 공부해보면 좋겠네요
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.
넵 한번 공부해보도록 하겠습니다!!!
this.logout() | ||
this.withdrawal() |
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.
취향차이 입니다 ㅎ
Issue Number
필수과제 수행
심화 과제
부족한 부분