diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..c4e4683
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+BCSD_Android_2025-1
\ No newline at end of file
diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml
new file mode 100644
index 0000000..4a53bee
--- /dev/null
+++ b/.idea/AndroidProjectSystem.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..b86273d
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
new file mode 100644
index 0000000..b268ef3
--- /dev/null
+++ b/.idea/deploymentTargetSelector.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..639c779
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/migrations.xml b/.idea/migrations.xml
new file mode 100644
index 0000000..f8051a6
--- /dev/null
+++ b/.idea/migrations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..74dd639
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..16660f1
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/bcsd_android_2025_1/LapAdapter.kt b/app/src/main/java/com/example/bcsd_android_2025_1/LapAdapter.kt
new file mode 100644
index 0000000..de08281
--- /dev/null
+++ b/app/src/main/java/com/example/bcsd_android_2025_1/LapAdapter.kt
@@ -0,0 +1,39 @@
+package com.example.bcsd_android_2025_1
+
+import android.view.LayoutInflater
+import android.view.View
+import android.widget.TextView
+import android.view.ViewGroup
+import androidx.recyclerview.widget.RecyclerView
+
+class LapAdapter : RecyclerView.Adapter() {
+
+ private val lapList = mutableListOf()
+
+ class LapViewHolder(View: View) : RecyclerView.ViewHolder(View) {
+ val lapText: TextView = View.findViewById(R.id.text_lap)
+ }
+
+ fun addLap(time: String) {
+ lapList.add(0, LapItem(time))
+ notifyItemInserted(0)
+ }
+
+ fun clearLaps() {
+ lapList.clear()
+ notifyDataSetChanged()
+ }
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LapViewHolder {
+ val view = LayoutInflater.from(parent.context).inflate(R.layout.item_lap, parent, false)
+ return LapViewHolder(view)
+ }
+
+ override fun onBindViewHolder(holder: LapViewHolder, position: Int) {
+ holder.lapText.text = lapList[position].time
+ }
+
+ override fun getItemCount(): Int {
+ return lapList.size
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/bcsd_android_2025_1/LapItem.kt b/app/src/main/java/com/example/bcsd_android_2025_1/LapItem.kt
new file mode 100644
index 0000000..70de622
--- /dev/null
+++ b/app/src/main/java/com/example/bcsd_android_2025_1/LapItem.kt
@@ -0,0 +1,3 @@
+package com.example.bcsd_android_2025_1
+
+data class LapItem(val time : String)
\ No newline at end of file
diff --git a/app/src/main/java/com/example/bcsd_android_2025_1/MainActivity.kt b/app/src/main/java/com/example/bcsd_android_2025_1/MainActivity.kt
index 3ffa0eb..a4f51d1 100644
--- a/app/src/main/java/com/example/bcsd_android_2025_1/MainActivity.kt
+++ b/app/src/main/java/com/example/bcsd_android_2025_1/MainActivity.kt
@@ -1,14 +1,113 @@
package com.example.bcsd_android_2025_1
import android.os.Bundle
-import androidx.activity.enableEdgeToEdge
+import android.os.SystemClock
+import android.widget.Button
+import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
-import androidx.core.view.ViewCompat
-import androidx.core.view.WindowInsetsCompat
+import androidx.recyclerview.widget.LinearLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.cancel
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.isActive
+import kotlinx.coroutines.launch
class MainActivity : AppCompatActivity() {
+
+ private lateinit var timerTextView: TextView
+ private lateinit var startPauseButton: Button
+ private lateinit var stopButton: Button
+ private lateinit var lapButton: Button
+ private lateinit var lapRecyclerView: RecyclerView
+ private lateinit var lapAdapter: LapAdapter
+
+ private var startTime = 0L
+ private var elapsedTime = 0L
+ private var isRunning = false
+ private var timeJob: Job? = null
+
+ private var coroutineScope = CoroutineScope(Dispatchers.Main)
+
+ private fun nowTime(ms: Long): String {
+ val minutes = (ms / 60000).toInt()
+ val seconds = ((ms % 60000) / 1000).toInt()
+ val millseconds = ((ms % 1000) / 10).toInt()
+ val timeString = getString(R.string.now_time, minutes, seconds, millseconds)
+ return timeString
+ }
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
+
+ timerTextView = findViewById(R.id.textview_timer)
+ startPauseButton = findViewById(R.id.button_start_pause)
+ stopButton = findViewById(R.id.button_stop)
+ lapButton = findViewById(R.id.button_lap)
+ lapRecyclerView = findViewById(R.id.lap_recyclerview)
+ lapAdapter = LapAdapter()
+
+ lapRecyclerView.adapter = lapAdapter
+ lapRecyclerView.layoutManager = LinearLayoutManager(this)
+
+ startPauseButton.setOnClickListener {
+ if (isRunning) {
+ pauseTimer()
+ } else {
+ startTimer()
+ }
+ }
+ stopButton.setOnClickListener {
+ stopTimer()
+ }
+ lapButton.setOnClickListener {
+ if (isRunning) {
+ val currentTime = SystemClock.elapsedRealtime() - startTime
+ val lapTime = nowTime(currentTime)
+
+ lapAdapter.addLap(lapTime)
+ lapRecyclerView.scrollToPosition(0)
+ }
+ }
+ }
+
+ private fun startTimer() {
+ startTime = SystemClock.elapsedRealtime() - elapsedTime
+ isRunning = true
+ startPauseButton.text = getString(R.string.text_pause)
+
+ timeJob = coroutineScope.launch {
+ while (isActive) {
+ val elapsed = SystemClock.elapsedRealtime() - startTime
+ timerTextView.text = nowTime(elapsed)
+ delay(10L)
+ }
+ }
+ }
+
+ private fun pauseTimer() {
+ elapsedTime = SystemClock.elapsedRealtime() - startTime
+ timeJob?.cancel()
+ isRunning = false
+ startPauseButton.text = getString(R.string.text_start)
+ }
+
+ private fun stopTimer() {
+ timeJob?.cancel()
+ startTime = 0L
+ elapsedTime = 0L
+ isRunning = false
+ timerTextView.text = getString(R.string.start_time)
+ startPauseButton.text = getString(R.string.text_start)
+ lapAdapter.clearLaps()
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ timeJob?.cancel()
+ coroutineScope.cancel()
}
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 311f3cb..23acf34 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,19 +1,62 @@
+ android:padding="16dp">
+
+
+
+
+
+
+
+
+ app:layout_constraintEnd_toEndOf="parent"
+ android:layout_marginTop="30dp"/>
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_lap.xml b/app/src/main/res/layout/item_lap.xml
new file mode 100644
index 0000000..5042b0c
--- /dev/null
+++ b/app/src/main/res/layout/item_lap.xml
@@ -0,0 +1,9 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index c8524cd..3bc3663 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -2,4 +2,5 @@
#FF000000
#FFFFFFFF
+ #00AA00
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c6c4daf..d1e3c5f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,3 +1,9 @@
BCSD_Android_2025-1
+ 00 : 00 : 00
+ %02d : %02d :%02d
+ Pause
+ Start
+ Stop
+ Lap
\ No newline at end of file