All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.com.sceyt.chatuikit.persistence.file_transfer.TransferData.kt Maven / Gradle / Ivy

There is a newer version: 1.7.2
Show newest version
package com.sceyt.chatuikit.persistence.file_transfer

data class TransferData(
        val messageTid: Long,
        val progressPercent: Float,
        var state: TransferState,
        var filePath: String?,
        val url: String?,
        val thumbData: ThumbData? = null,
        val fileLoadedSize: String? = null,
        val fileTotalSize: String? = null
) {
    fun isCalculatedLoadedSize() = !fileLoadedSize.isNullOrBlank() && !fileTotalSize.isNullOrBlank()

    fun isTransferring() = state == TransferState.Downloading || state == TransferState.Uploading || state == TransferState.Preparing

    companion object {

        fun TransferData.withPrettySizes(fileSize: Long): TransferData {
            FileTransferHelper.getFilePrettySizes(fileSize, progressPercent).run {
                return copy(
                    fileLoadedSize = first,
                    fileTotalSize = second)
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy