-
Notifications
You must be signed in to change notification settings - Fork 1
[김예란_Android] 6주차 과제 제출 #6
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
base: main
Are you sure you want to change the base?
Conversation
kongwoojin
left a comment
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.
👍
| var time = 0 | ||
| var isRunning = false | ||
| var lapList = mutableListOf<String>() | ||
| var timerJob: Job? = null | ||
| var timerTask: Timer? = null | ||
| var lapAdapter = LapAdapter(lapList) |
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 처리를 해도 좋을 것 같아요
| recyclerView.adapter = lapAdapter | ||
| textViewTime.text = "00:00:00" | ||
|
|
||
| fun formatTime(millis: Int): String { |
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 minutes = ((millis % 3600000) / 60000) | ||
| val seconds = ((millis % 60000) / 1000) | ||
| val ms = ((millis % 1000) / 10) | ||
| return String.format(Locale.US, "%02d:%02d:%02d", minutes, seconds, ms) |
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.
Locale이 US인 이유가 있나요?
| isRunning = true | ||
| timerJob = lifecycleScope.launch { | ||
| while (isRunning) { | ||
| delay(10) |
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.
Coroutine에서 delay를 10ms만큼 준다고 실제 10ms만큼만 delay가 생기지 않습니다.
예를 들어, delay(1000)에 대해 전후에 System.currentTimeMillis()를 로그로 찍어보면, 실제로 1000ms만큼 차이가 나는 것이 아니라 오차가 발생하는 것을 확인할 수 있습니다.
왜 이런 현상이 발생하는지도 알아보시면 좋을 것 같아요.
|
|
||
| buttonLap.setOnClickListener{ | ||
| val currentTime = textViewTime.text.toString() | ||
| lapList.add(0, currentTime) |
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.
0번 인덱스에 추가하는 방법도 좋은 방법이지만, recyclerview 자체를 반대로 뒤집을 수도 있어요
KYM-P
left a comment
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.
뭐지 너무 잘하셨습니다.
No description provided.