Fixed crash when downloading more than one file consecutively

This commit is contained in:
Sylvain Berfini 2021-01-28 17:11:15 +01:00
parent b3ebaae360
commit 7545961ffb

View file

@ -72,10 +72,14 @@ class ChatMessageContentViewModel(
offset: Int, offset: Int,
total: Int total: Int
) { ) {
val percent = offset * 100 / total if (c.filePath == content.filePath) {
if (!c.filePath.isNullOrEmpty() && !content.filePath.isNullOrEmpty() && c.filePath == content.filePath) { val percent = offset * 100 / total
Log.d("[Content] Download progress is: $offset / $total ($percent%)") Log.d("[Content] Download progress is: $offset / $total ($percent%)")
downloadProgress.postValue(percent) downloadProgress.postValue(percent)
if (offset == total) {
chatMessage.removeListener(this)
}
} }
} }