Skip to content

Commit 8010f30

Browse files
authored
[Merge] fix-run-vibration -> develop
[FIX] setOnlyAlertOnce 추가를 통한 소리/진동 제한
2 parents 3d45ced + 4dc009f commit 8010f30

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

app/src/main/java/com/runnect/runnect/presentation/run/RunActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import com.runnect.runnect.data.dto.TimerData
3636
import com.runnect.runnect.databinding.ActivityRunBinding
3737
import com.runnect.runnect.presentation.endrun.EndRunActivity
3838
import com.runnect.runnect.presentation.run.TimerService.Companion.EXTRA_TIMER_VALUE
39+
import com.runnect.runnect.presentation.run.TimerService.Companion.TIMER_UPDATE_ACTION
3940
import com.runnect.runnect.util.extension.round
4041

4142
class RunActivity : BindingActivity<ActivityRunBinding>(R.layout.activity_run),
@@ -123,7 +124,7 @@ class RunActivity : BindingActivity<ActivityRunBinding>(R.layout.activity_run),
123124
override fun onStart() {
124125
super.onStart()
125126
// Timer 결과값을 받기 위해 브로드캐스트 리시버 등록
126-
registerReceiver(timerReceiver, IntentFilter(TimerService.TIMER_UPDATE_ACTION))
127+
registerReceiver(timerReceiver, IntentFilter(TIMER_UPDATE_ACTION))
127128
}
128129

129130
override fun onStop() {

app/src/main/java/com/runnect/runnect/presentation/run/TimerService.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ class TimerService : Service() {
3939
return START_STICKY
4040
}
4141

42+
fun notifyStartRun() {
43+
if (player == null) {
44+
player = MediaPlayer.create(this@TimerService, R.raw.start_run)
45+
player?.setOnCompletionListener { mediaPlayer ->
46+
mediaPlayer.release() // 재생이 끝나면 MediaPlayer 객체를 해제합니다.
47+
}
48+
}
49+
player?.start()
50+
}
51+
4252
fun startTimer() {
4353
timer = Timer()
4454
timer?.scheduleAtFixedRate(object : TimerTask() {
@@ -86,6 +96,7 @@ class TimerService : Service() {
8696
.setColor(ContextCompat.getColor(this@TimerService, R.color.M1))
8797
.setContentTitle("러닝")
8898
.setContentText("00:00:00")
99+
.setOnlyAlertOnce(true)
89100
.setOngoing(true) // true 일 경우 알림 리스트에서 클릭하거나 좌우로 드래그해도 사라지지 않음
90101

91102
val notificationIntent = Intent(this@TimerService, RunActivity::class.java)
@@ -119,16 +130,6 @@ class TimerService : Service() {
119130
startForeground(NOTI_ID, notification)
120131
}
121132

122-
fun notifyStartRun() {
123-
if (player == null) {
124-
player = MediaPlayer.create(this@TimerService, R.raw.start_run)
125-
player?.setOnCompletionListener { mediaPlayer ->
126-
mediaPlayer.release() // 재생이 끝나면 MediaPlayer 객체를 해제합니다.
127-
}
128-
}
129-
player?.start()
130-
}
131-
132133
companion object {
133134
const val TIMER_UPDATE_ACTION = "TIMER_UPDATE_ACTION"
134135
const val EXTRA_TIMER_VALUE = "EXTRA_TIMER_VALUE"

0 commit comments

Comments
 (0)