mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Fix updateStorageInfo messages
This commit is contained in:
parent
bd9c88464e
commit
43121e5760
1 changed files with 11 additions and 5 deletions
|
@ -102,14 +102,14 @@ class DownloadFragment : Fragment() {
|
||||||
binding?.downloadLoading?.isVisible = false
|
binding?.downloadLoading?.isVisible = false
|
||||||
}
|
}
|
||||||
observe(downloadsViewModel.availableBytes) {
|
observe(downloadsViewModel.availableBytes) {
|
||||||
updateStorageInfo(view.context, it, binding?.downloadFreeTxt, binding?.downloadFree)
|
updateStorageInfo(view.context, it, R.string.free_storage, binding?.downloadFreeTxt, binding?.downloadFree)
|
||||||
}
|
}
|
||||||
observe(downloadsViewModel.usedBytes) {
|
observe(downloadsViewModel.usedBytes) {
|
||||||
updateStorageInfo(view.context, it, binding?.downloadUsedTxt, binding?.downloadUsed)
|
updateStorageInfo(view.context, it, R.string.used_storage, binding?.downloadUsedTxt, binding?.downloadUsed)
|
||||||
binding?.downloadStorageAppbar?.isVisible = it > 0
|
binding?.downloadStorageAppbar?.isVisible = it > 0
|
||||||
}
|
}
|
||||||
observe(downloadsViewModel.downloadBytes) {
|
observe(downloadsViewModel.downloadBytes) {
|
||||||
updateStorageInfo(view.context, it, binding?.downloadAppTxt, binding?.downloadApp)
|
updateStorageInfo(view.context, it, R.string.app_storage, binding?.downloadAppTxt, binding?.downloadApp)
|
||||||
}
|
}
|
||||||
|
|
||||||
val adapter = DownloadAdapter(
|
val adapter = DownloadAdapter(
|
||||||
|
@ -177,8 +177,14 @@ class DownloadFragment : Fragment() {
|
||||||
downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent += it }
|
downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent += it }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateStorageInfo(context: Context, bytes: Long, textView: TextView?, view: View?) {
|
private fun updateStorageInfo(
|
||||||
textView?.text = getString(R.string.storage_size_format).format(getString(R.string.free_storage), formatShortFileSize(context, bytes))
|
context: Context,
|
||||||
|
bytes: Long,
|
||||||
|
stringRes: Int,
|
||||||
|
textView: TextView?,
|
||||||
|
view: View?
|
||||||
|
) {
|
||||||
|
textView?.text = getString(R.string.storage_size_format).format(getString(stringRes), formatShortFileSize(context, bytes))
|
||||||
view?.setLayoutWidth(bytes)
|
view?.setLayoutWidth(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue