Conversation
스탑워치 구현
yunjaena
left a comment
There was a problem hiding this comment.
수고 많으셨습니다!! 커맨트 드린 부분 수정해주시면 좋을 것 같아요 👍
| import android.widget.Toast | ||
| import androidx.core.view.GravityCompat | ||
| import com.google.android.material.navigation.NavigationView | ||
| import kotlinx.android.synthetic.main.activity_main.* |
There was a problem hiding this comment.
Kotlin Android Extensions Deprecated 해당 기능은 deprecated되어서 DataBinding으로 대체하는게 좋아보입니다.
| override fun onNavigationItemSelected(item: MenuItem): Boolean { //네비게이션 메뉴 아이템 클릭시 수행 | ||
| when (item.itemId) | ||
| { | ||
| R.id.A -> { |
There was a problem hiding this comment.
보통 id는 소문자로 사용합니다. 그리고 다른 사람들도 알아볼 수 있게 menu_a 와 같이 지으면 좋을 것 같네요~!
|
|
||
| class Timer : AppCompatActivity() { | ||
| var isWorking : Boolean =false | ||
| @RequiresApi(Build.VERSION_CODES.O) |
There was a problem hiding this comment.
해당 annotation은 Oreo 이상 부터 사용할 수 있다는 뜻인데 이전 버전에서도 돌아 갈 수 있게 대응을 해주면 좋을 것 같네요
| setContentView(R.layout.activity_timer) | ||
|
|
||
| start.setOnClickListener { | ||
| if(isWorking==false){ |
There was a problem hiding this comment.
| if(isWorking==false){ | |
| if(!isWorking){ |
으로 변경 하면 좋겠습니다
| isWorking=true | ||
|
|
||
| runOnUiThread { | ||
| timeTxt.text="${String.format("%02d",min)}:${String.format("%02d",sec)}:${String.format("%02d",milli)}" |
There was a problem hiding this comment.
String.format을 각자 할 필요없이 한번에 할 수 있습니다 :)
| } | ||
| } | ||
|
|
||
| private fun stopTimer(){ |
There was a problem hiding this comment.
해당 기능을 onDestroy 할때도 호출해서 resource 정리를 하면 좋을 것 같네요
| private fun resetHandler() { | ||
| val handler:Handler = object : Handler(Looper.getMainLooper()){ | ||
| override fun handleMessage(msg: Message) { | ||
| timeTxt.setText("00:00:00") |
There was a problem hiding this comment.
해당 텍스트를 strings.xml에 선언해서 사용하면 좋을 것 같습니다.
| timerTask=timer(period = 10){ | ||
| time++ | ||
|
|
||
| val min = (time/100)/60 |
There was a problem hiding this comment.
안드로이드 스튜디오에 정렬 기능을 사용해 주세요 ~!
스탑워치 구현입니다.