Skip to content

Commit 1c04568

Browse files
yonghanJubngsh
andcommitted
🚚 RunningRepository.kt -> RunningDataManager.kt 이름 변경
Co-authored-by: bngsh <[email protected]>
1 parent cef6ad0 commit 1c04568

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

presentation/src/main/java/com/whyranoid/presentation/running/RunningRepository.kt renamed to presentation/src/main/java/com/whyranoid/presentation/running/RunningDataManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import javax.inject.Inject
99
import javax.inject.Singleton
1010

1111
@Singleton
12-
class RunningRepository @Inject constructor() {
12+
class RunningDataManager @Inject constructor() {
1313
private var _runningState = MutableStateFlow<RunningState>(
1414
RunningState.NotRunning()
1515
)

presentation/src/main/java/com/whyranoid/presentation/running/RunningViewModel.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import javax.inject.Inject
2424
class RunningViewModel @Inject constructor(
2525
@ApplicationContext context: Context,
2626
startRunningUseCase: StartRunningUseCase,
27-
private val runningRepository: RunningRepository
27+
private val runningDataManager: RunningDataManager
2828
) : ViewModel() {
2929

30-
val runningState = runningRepository.runningState
30+
val runningState = runningDataManager.runningState
3131

3232
private val _trackingModeState = MutableStateFlow(TrackingMode.FOLLOW)
3333
val trackingModeState get() = _trackingModeState.asStateFlow()
@@ -36,7 +36,7 @@ class RunningViewModel @Inject constructor(
3636
val eventFlow get() = _eventFlow.asSharedFlow()
3737

3838
init {
39-
if (runningRepository.runningState.value is RunningState.NotRunning) {
39+
if (runningDataManager.runningState.value is RunningState.NotRunning) {
4040
viewModelScope.launch {
4141
startRunningUseCase()
4242
}
@@ -67,7 +67,7 @@ class RunningViewModel @Inject constructor(
6767
}
6868

6969
fun onCheckingPauseOrResume() {
70-
when (runningRepository.runningState.value) {
70+
when (runningDataManager.runningState.value) {
7171
is RunningState.Running -> onPauseButtonClicked()
7272
is RunningState.Paused -> onResumeButtonClicked()
7373
else -> return
@@ -93,11 +93,11 @@ class RunningViewModel @Inject constructor(
9393
}
9494

9595
private fun onPauseButtonClicked() {
96-
runningRepository.pauseRunning()
96+
runningDataManager.pauseRunning()
9797
}
9898

9999
private fun onResumeButtonClicked() {
100-
runningRepository.resumeRunning()
100+
runningDataManager.resumeRunning()
101101
}
102102

103103
private fun emitEvent(event: Event) {
@@ -108,7 +108,7 @@ class RunningViewModel @Inject constructor(
108108

109109
fun onFinishButtonClicked() {
110110
// TODO: 액티비티에 이벤트 알려주기
111-
runningRepository.finishRunning()
111+
runningDataManager.finishRunning()
112112
}
113113

114114
companion object {

presentation/src/main/java/com/whyranoid/presentation/running/RunningWorker.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import kotlinx.coroutines.delay
2929
class RunningWorker @AssistedInject constructor(
3030
@Assisted private val context: Context,
3131
@Assisted params: WorkerParameters,
32-
private val runningRepository: RunningRepository
32+
private val runningDataManager: RunningDataManager
3333
) : CoroutineWorker(context, params) {
3434

3535
private val fusedLocationClient = LocationServices.getFusedLocationProviderClient(context)
@@ -39,18 +39,18 @@ class RunningWorker @AssistedInject constructor(
3939

4040
override suspend fun doWork(): Result {
4141
if (startTracking().not()) {
42-
runningRepository.finishRunning()
42+
runningDataManager.finishRunning()
4343
return Result.failure()
4444
}
4545

4646
setForeground(createForegroundInfo(context.getString(R.string.running_notification_content)))
4747

48-
while ((runningRepository.runningState.value is RunningState.NotRunning).not()) {
48+
while ((runningDataManager.runningState.value is RunningState.NotRunning).not()) {
4949
delay(UPDATE_INTERVAL_MS)
50-
when (runningRepository.runningState.value) {
50+
when (runningDataManager.runningState.value) {
5151
is RunningState.NotRunning -> break
5252
is RunningState.Paused -> continue
53-
is RunningState.Running -> runningRepository.tick()
53+
is RunningState.Running -> runningDataManager.tick()
5454
}
5555
}
5656
fusedLocationClient.removeLocationUpdates(locationCallback)
@@ -100,9 +100,9 @@ class RunningWorker @AssistedInject constructor(
100100
locationCallback = object : LocationCallback() {
101101
override fun onLocationResult(locationResult: LocationResult) {
102102
locationResult.lastLocation?.let { location ->
103-
runningRepository.setRunningState(location)
103+
runningDataManager.setRunningState(location)
104104
} ?: run {
105-
runningRepository.pauseRunning()
105+
runningDataManager.pauseRunning()
106106
}
107107
}
108108
}
@@ -113,12 +113,12 @@ class RunningWorker @AssistedInject constructor(
113113
locationCallback,
114114
Looper.getMainLooper()
115115
)
116-
runningRepository.startRunning()
116+
runningDataManager.startRunning()
117117
return true
118118
} catch (e: SecurityException) {
119-
runningRepository.pauseRunning()
119+
runningDataManager.pauseRunning()
120120
} catch (e: Exception) {
121-
runningRepository.pauseRunning()
121+
runningDataManager.pauseRunning()
122122
}
123123
return false
124124
}

0 commit comments

Comments
 (0)