Skip to content

Commit

Permalink
Timer Added
Browse files Browse the repository at this point in the history
  • Loading branch information
bgmylc committed Jan 19, 2022
1 parent b9cbe3e commit 1bc408a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions app/src/main/java/com/begumyolcu/sayacapp/SayacTimer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.begumyolcu.sayacapp

import android.os.Handler
import android.os.Looper
import timber.log.Timber

class SayacTimer() {
var sayilanSaniye = 0

private var handler = Handler(Looper.getMainLooper())
private lateinit var runnable: Runnable

fun startTimer() {
runnable = Runnable {
sayilanSaniye++
Timber.i("Timer saniyesi : $sayilanSaniye")
handler.postDelayed(runnable, 1000)
}
handler.postDelayed(runnable, 1000)
}

fun stopTimer() {
handler.removeCallbacks(runnable)
}

}

0 comments on commit 1bc408a

Please sign in to comment.