mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Minor cleanup
This commit is contained in:
parent
0e0e346bd0
commit
96ed04f7cd
3 changed files with 19 additions and 19 deletions
|
@ -15,8 +15,8 @@ import com.lagradost.cloudstream3.databinding.DownloadHeaderEpisodeBinding
|
|||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
import com.lagradost.cloudstream3.ui.download.button.DownloadStatusTell
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.fixVisual
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadHelper
|
||||
|
||||
|
@ -116,7 +116,7 @@ class DownloadAdapter(
|
|||
}
|
||||
|
||||
downloadHeaderTitle.text = d.name
|
||||
val mbString = formatShortFileSize(itemView.context, card.totalBytes)
|
||||
val formattedSizeString = formatShortFileSize(itemView.context, card.totalBytes)
|
||||
|
||||
if (card.child != null) {
|
||||
downloadHeaderGotoChild.isVisible = false
|
||||
|
@ -131,7 +131,7 @@ class DownloadAdapter(
|
|||
downloadButton.applyMetaData(card.child.id, card.currentBytes, card.totalBytes)
|
||||
// We will let the view model handle this
|
||||
downloadButton.doSetProgress = false
|
||||
downloadHeaderInfo.text = formatShortFileSize(downloadHeaderInfo.context, card.totalBytes)
|
||||
downloadHeaderInfo.text = formattedSizeString
|
||||
} else downloadButton.doSetProgress = true
|
||||
|
||||
downloadButton.setDefaultClickListener(card.child, downloadHeaderInfo, mediaClickCallback)
|
||||
|
@ -152,7 +152,7 @@ class DownloadAdapter(
|
|||
R.plurals.episodes,
|
||||
card.totalDownloads
|
||||
),
|
||||
mbString
|
||||
formattedSizeString
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
// You probably formatted incorrectly
|
||||
|
@ -173,7 +173,7 @@ class DownloadAdapter(
|
|||
val d = card.data
|
||||
|
||||
binding.apply {
|
||||
val posDur = DataStoreHelper.getViewPos(d.id)
|
||||
val posDur = getViewPos(d.id)
|
||||
downloadChildEpisodeProgress.apply {
|
||||
isVisible = posDur != null
|
||||
posDur?.let {
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.lagradost.cloudstream3.utils.DataStore.getFolderName
|
|||
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
||||
import com.lagradost.cloudstream3.utils.DataStore.getKeys
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadHelper
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager.getDownloadFileInfoAndUpdateSettings
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
@ -57,7 +57,7 @@ class DownloadViewModel : ViewModel() {
|
|||
// Gets all children downloads
|
||||
withContext(Dispatchers.IO) {
|
||||
children.forEach { c ->
|
||||
val childFile = VideoDownloadManager.getDownloadFileInfoAndUpdateSettings(context, c.id) ?: return@forEach
|
||||
val childFile = getDownloadFileInfoAndUpdateSettings(context, c.id) ?: return@forEach
|
||||
|
||||
if (childFile.fileLength <= 1) return@forEach
|
||||
val len = childFile.totalBytes
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.lagradost.cloudstream3.ui.download.button
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.Formatter
|
||||
import android.text.format.Formatter.formatShortFileSize
|
||||
import android.util.AttributeSet
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
|
@ -36,7 +36,7 @@ abstract class BaseFetchButton(context: Context, attributeSet: AttributeSet) :
|
|||
lateinit var progressBar: ContentLoadingProgressBar
|
||||
var progressText: TextView? = null
|
||||
|
||||
/*val gid: String? get() = sessionIdToGid[persistentId]
|
||||
/* val gid: String? get() = sessionIdToGid[persistentId]
|
||||
|
||||
// used for resuming data
|
||||
var _lastRequestOverride: UriRequest? = null
|
||||
|
@ -46,7 +46,7 @@ abstract class BaseFetchButton(context: Context, attributeSet: AttributeSet) :
|
|||
_lastRequestOverride = value
|
||||
}
|
||||
|
||||
var files: List<AbstractClient.JsonFile> = emptyList()*/
|
||||
var files: List<AbstractClient.JsonFile> = emptyList() */
|
||||
protected var isZeroBytes: Boolean = true
|
||||
|
||||
fun inflate(@LayoutRes layout: Int) {
|
||||
|
@ -93,6 +93,7 @@ abstract class BaseFetchButton(context: Context, attributeSet: AttributeSet) :
|
|||
abstract fun setStatus(status: VideoDownloadManager.DownloadType?)
|
||||
|
||||
fun getStatus(id:Int, downloadedBytes: Long, totalBytes: Long): DownloadStatusTell {
|
||||
// some extra padding for just in case
|
||||
return VideoDownloadManager.downloadStatus[id]
|
||||
?: if (downloadedBytes > 1024L && downloadedBytes + 1024L >= totalBytes) {
|
||||
DownloadStatusTell.IsDone
|
||||
|
@ -138,13 +139,12 @@ abstract class BaseFetchButton(context: Context, attributeSet: AttributeSet) :
|
|||
} else {
|
||||
if (doSetProgress) {
|
||||
progressText?.apply {
|
||||
val currentMbString =
|
||||
Formatter.formatShortFileSize(context, downloadedBytes)
|
||||
val totalMbString = Formatter.formatShortFileSize(context, totalBytes)
|
||||
val currentFormattedSizeString = formatShortFileSize(context, downloadedBytes)
|
||||
val totalFormattedSizeString = formatShortFileSize(context, totalBytes)
|
||||
text =
|
||||
//if (isTextPercentage) "%d%%".format(setCurrentBytes * 100L / setTotalBytes) else
|
||||
// if (isTextPercentage) "%d%%".format(setCurrentBytes * 100L / setTotalBytes) else
|
||||
context?.getString(R.string.download_size_format)
|
||||
?.format(currentMbString, totalMbString)
|
||||
?.format(currentFormattedSizeString, totalFormattedSizeString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,8 +182,8 @@ abstract class BaseFetchButton(context: Context, attributeSet: AttributeSet) :
|
|||
|
||||
override fun onAttachedToWindow() {
|
||||
VideoDownloadManager.downloadStatusEvent += ::downloadStatusEvent
|
||||
//VideoDownloadManager.downloadDeleteEvent += ::downloadDeleteEvent
|
||||
//VideoDownloadManager.downloadEvent += ::downloadEvent
|
||||
// VideoDownloadManager.downloadDeleteEvent += ::downloadDeleteEvent
|
||||
// VideoDownloadManager.downloadEvent += ::downloadEvent
|
||||
VideoDownloadManager.downloadProgressEvent += ::downloadProgressEvent
|
||||
|
||||
val pid = persistentId
|
||||
|
@ -197,8 +197,8 @@ abstract class BaseFetchButton(context: Context, attributeSet: AttributeSet) :
|
|||
|
||||
override fun onDetachedFromWindow() {
|
||||
VideoDownloadManager.downloadStatusEvent -= ::downloadStatusEvent
|
||||
//VideoDownloadManager.downloadDeleteEvent -= ::downloadDeleteEvent
|
||||
//VideoDownloadManager.downloadEvent -= ::downloadEvent
|
||||
// VideoDownloadManager.downloadDeleteEvent -= ::downloadDeleteEvent
|
||||
// VideoDownloadManager.downloadEvent -= ::downloadEvent
|
||||
VideoDownloadManager.downloadProgressEvent -= ::downloadProgressEvent
|
||||
|
||||
super.onDetachedFromWindow()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue