Fixed backups not visible
This commit is contained in:
parent
c5c4144973
commit
6ff3eb2e2a
4 changed files with 14 additions and 20 deletions
|
@ -58,11 +58,10 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
|
|||
}
|
||||
|
||||
private fun checkIsEmpty() {
|
||||
binding.emptyText.setText(R.string.no_backups_found)
|
||||
(backupAdapter!!.itemCount == 0).run {
|
||||
binding.empty.isVisible = this
|
||||
binding.backupTitle.isVisible = this
|
||||
}
|
||||
val isEmpty = backupAdapter!!.itemCount == 0
|
||||
binding.empty.isVisible = isEmpty
|
||||
binding.backupTitle.isVisible = !isEmpty
|
||||
binding.backupRecyclerview.isVisible = !isEmpty
|
||||
}
|
||||
|
||||
fun setupRecyclerview() {
|
||||
|
|
|
@ -2,12 +2,11 @@ package code.name.monkey.retromusic.fragments.backup
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import code.name.monkey.retromusic.helper.BackupHelper
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import kotlin.system.exitProcess
|
||||
|
@ -15,15 +14,13 @@ import kotlin.system.exitProcess
|
|||
|
||||
class BackupViewModel : ViewModel() {
|
||||
private val backupsMutableLiveData = MutableLiveData<List<File>>()
|
||||
val backupsLiveData = backupsMutableLiveData
|
||||
val backupsLiveData: LiveData<List<File>> = backupsMutableLiveData
|
||||
|
||||
fun loadBackups() {
|
||||
viewModelScope.launch {
|
||||
File(BackupHelper.backupRootPath).listFiles { file, _ ->
|
||||
return@listFiles file.extension == BackupHelper.BACKUP_EXTENSION
|
||||
}?.toList()?.let {
|
||||
backupsMutableLiveData.value = it
|
||||
}
|
||||
File(BackupHelper.backupRootPath).listFiles { _, name ->
|
||||
return@listFiles name.endsWith(BackupHelper.BACKUP_EXTENSION)
|
||||
}?.toList()?.let {
|
||||
backupsMutableLiveData.value = it
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ object BackupHelper {
|
|||
|
||||
val backupRootPath =
|
||||
Environment.getExternalStorageDirectory().toString() + "/RetroMusic/Backups/"
|
||||
const val BACKUP_EXTENSION = "zip"
|
||||
const val BACKUP_EXTENSION = "rmbak"
|
||||
private const val APPEND_EXTENSION = ".$BACKUP_EXTENSION"
|
||||
private const val DATABASES_PATH = "databases"
|
||||
private const val SETTINGS_PATH = "prefs"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue