-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
104 changed files
with
2,975 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/example/util/simpletimetracker/ui/MainActivityViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.example.util.simpletimetracker.ui | ||
|
||
import androidx.lifecycle.MediatorLiveData | ||
import com.example.util.simpletimetracker.core.base.BaseViewModel | ||
import com.example.util.simpletimetracker.core.extension.set | ||
import com.example.util.simpletimetracker.core.repo.AutomaticBackupRepo | ||
import com.example.util.simpletimetracker.core.repo.AutomaticExportRepo | ||
import com.example.util.simpletimetracker.core.repo.DataEditRepo | ||
import com.example.util.simpletimetracker.core.repo.FileWorkRepo | ||
import com.example.util.simpletimetracker.domain.extension.orFalse | ||
import com.example.util.simpletimetracker.feature_settings.viewModel.delegate.SettingsFileWorkDelegate | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class MainActivityViewModel @Inject constructor( | ||
private val dataEditRepo: DataEditRepo, | ||
private val automaticBackupRepo: AutomaticBackupRepo, | ||
private val automaticExportRepo: AutomaticExportRepo, | ||
private val fileWorkRepo: FileWorkRepo, | ||
private val settingsFileWorkDelegate: SettingsFileWorkDelegate, | ||
) : BaseViewModel() { | ||
|
||
val progressVisibility: MediatorLiveData<Boolean> = MediatorLiveData<Boolean>().apply { | ||
addSource(automaticBackupRepo.inProgress) { updateProgress() } | ||
addSource(automaticExportRepo.inProgress) { updateProgress() } | ||
addSource(dataEditRepo.inProgress) { updateProgress() } | ||
addSource(fileWorkRepo.inProgress) { updateProgress() } | ||
} | ||
|
||
fun onVisible() { | ||
settingsFileWorkDelegate.onAppVisible() | ||
} | ||
|
||
private fun updateProgress() { | ||
val visible = dataEditRepo.inProgress.value.orFalse() || | ||
automaticBackupRepo.inProgress.value.orFalse() || | ||
automaticExportRepo.inProgress.value.orFalse() || | ||
fileWorkRepo.inProgress.value.orFalse() | ||
|
||
progressVisibility.set(visible) | ||
// Here to check that if automatic update finishes with error while app is opened. | ||
settingsFileWorkDelegate.onFileWork() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,5 @@ | |
android:indeterminate="true" /> | ||
|
||
</FrameLayout> | ||
|
||
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
core/src/main/java/com/example/util/simpletimetracker/core/base/ViewModelDelegate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.