Skip to content

Assignment7#3

Open
Ssunghyn wants to merge 1 commit intomainfrom
Assignment7
Open

Assignment7#3
Ssunghyn wants to merge 1 commit intomainfrom
Assignment7

Conversation

@Ssunghyn
Copy link
Owner

스탑워치 구현입니다.

스탑워치 구현
@Ssunghyn Ssunghyn requested review from ksu9080 and yunjaena June 27, 2021 02:40
Copy link
Collaborator

@yunjaena yunjaena left a comment

Choose a reason for hiding this comment

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

수고 많으셨습니다!! 커맨트 드린 부분 수정해주시면 좋을 것 같아요 👍

import android.widget.Toast
import androidx.core.view.GravityCompat
import com.google.android.material.navigation.NavigationView
import kotlinx.android.synthetic.main.activity_main.*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kotlin Android Extensions Deprecated 해당 기능은 deprecated되어서 DataBinding으로 대체하는게 좋아보입니다.

override fun onNavigationItemSelected(item: MenuItem): Boolean { //네비게이션 메뉴 아이템 클릭시 수행
when (item.itemId)
{
R.id.A -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

보통 id는 소문자로 사용합니다. 그리고 다른 사람들도 알아볼 수 있게 menu_a 와 같이 지으면 좋을 것 같네요~!


class Timer : AppCompatActivity() {
var isWorking : Boolean =false
@RequiresApi(Build.VERSION_CODES.O)
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 annotation은 Oreo 이상 부터 사용할 수 있다는 뜻인데 이전 버전에서도 돌아 갈 수 있게 대응을 해주면 좋을 것 같네요

setContentView(R.layout.activity_timer)

start.setOnClickListener {
if(isWorking==false){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if(isWorking==false){
if(!isWorking){

으로 변경 하면 좋겠습니다

isWorking=true

runOnUiThread {
timeTxt.text="${String.format("%02d",min)}:${String.format("%02d",sec)}:${String.format("%02d",milli)}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

String.format을 각자 할 필요없이 한번에 할 수 있습니다 :)

}
}

private fun stopTimer(){
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 기능을 onDestroy 할때도 호출해서 resource 정리를 하면 좋을 것 같네요

private fun resetHandler() {
val handler:Handler = object : Handler(Looper.getMainLooper()){
override fun handleMessage(msg: Message) {
timeTxt.setText("00:00:00")
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 텍스트를 strings.xml에 선언해서 사용하면 좋을 것 같습니다.

timerTask=timer(period = 10){
time++

val min = (time/100)/60
Copy link
Collaborator

Choose a reason for hiding this comment

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

안드로이드 스튜디오에 정렬 기능을 사용해 주세요 ~!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants