Fix crash when playing video (#3179)
This commit is contained in:
parent
59637c4a6b
commit
e4375522ff
@ -3,6 +3,7 @@ Changes in Element 1.1.5 (2021-XX-XX)
|
|||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Fix crash during Realm migration
|
- Fix crash during Realm migration
|
||||||
|
- Fix crash when playing video (#3179)
|
||||||
|
|
||||||
Changes in Element 1.1.4 (2021-04-09)
|
Changes in Element 1.1.4 (2021-04-09)
|
||||||
===================================================
|
===================================================
|
||||||
|
@ -28,8 +28,10 @@ import com.bumptech.glide.signature.ObjectKey
|
|||||||
import im.vector.app.core.extensions.vectorComponent
|
import im.vector.app.core.extensions.vectorComponent
|
||||||
import im.vector.app.core.files.LocalFilesHelper
|
import im.vector.app.core.files.LocalFilesHelper
|
||||||
import im.vector.app.features.media.ImageContentRenderer
|
import im.vector.app.features.media.ImageContentRenderer
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@ -121,10 +123,12 @@ class VectorGlideDataFetcher(context: Context,
|
|||||||
url = data.url,
|
url = data.url,
|
||||||
elementToDecrypt = data.elementToDecrypt)
|
elementToDecrypt = data.elementToDecrypt)
|
||||||
}
|
}
|
||||||
result.fold(
|
withContext(Dispatchers.Main) {
|
||||||
{ callback.onDataReady(it.inputStream()) },
|
result.fold(
|
||||||
{ callback.onLoadFailed(it as? Exception ?: IOException(it.localizedMessage)) }
|
{ callback.onDataReady(it.inputStream()) },
|
||||||
)
|
{ callback.onLoadFailed(it as? Exception ?: IOException(it.localizedMessage)) }
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// val url = contentUrlResolver.resolveFullSize(data.url)
|
// val url = contentUrlResolver.resolveFullSize(data.url)
|
||||||
// ?: return
|
// ?: return
|
||||||
|
@ -31,8 +31,10 @@ import im.vector.lib.attachmentviewer.AttachmentInfo
|
|||||||
import im.vector.lib.attachmentviewer.AttachmentSourceProvider
|
import im.vector.lib.attachmentviewer.AttachmentSourceProvider
|
||||||
import im.vector.lib.attachmentviewer.ImageLoaderTarget
|
import im.vector.lib.attachmentviewer.ImageLoaderTarget
|
||||||
import im.vector.lib.attachmentviewer.VideoLoaderTarget
|
import im.vector.lib.attachmentviewer.VideoLoaderTarget
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.android.sdk.api.session.events.model.isVideoMessage
|
import org.matrix.android.sdk.api.session.events.model.isVideoMessage
|
||||||
import org.matrix.android.sdk.api.session.file.FileService
|
import org.matrix.android.sdk.api.session.file.FileService
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||||
@ -162,10 +164,12 @@ abstract class BaseAttachmentProvider<Type>(
|
|||||||
elementToDecrypt = data.elementToDecrypt
|
elementToDecrypt = data.elementToDecrypt
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
result.fold(
|
withContext(Dispatchers.Main) {
|
||||||
{ target.onVideoFileReady(info.uid, it) },
|
result.fold(
|
||||||
{ target.onVideoFileLoadFailed(info.uid) }
|
{ target.onVideoFileReady(info.uid, it) },
|
||||||
)
|
{ target.onVideoFileLoadFailed(info.uid) }
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,10 @@ package im.vector.app.features.media
|
|||||||
import im.vector.app.core.date.VectorDateFormatter
|
import im.vector.app.core.date.VectorDateFormatter
|
||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.lib.attachmentviewer.AttachmentInfo
|
import im.vector.lib.attachmentviewer.AttachmentInfo
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.android.sdk.api.session.file.FileService
|
import org.matrix.android.sdk.api.session.file.FileService
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||||
@ -87,7 +89,9 @@ class DataAttachmentRoomProvider(
|
|||||||
elementToDecrypt = item.elementToDecrypt
|
elementToDecrypt = item.elementToDecrypt
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
callback(result.getOrNull())
|
withContext(Dispatchers.Main) {
|
||||||
|
callback(result.getOrNull())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,10 @@ package im.vector.app.features.media
|
|||||||
import im.vector.app.core.date.VectorDateFormatter
|
import im.vector.app.core.date.VectorDateFormatter
|
||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.lib.attachmentviewer.AttachmentInfo
|
import im.vector.lib.attachmentviewer.AttachmentInfo
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.api.session.file.FileService
|
import org.matrix.android.sdk.api.session.file.FileService
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
@ -134,7 +136,9 @@ class RoomEventsAttachmentProvider(
|
|||||||
url = messageContent.getFileUrl(),
|
url = messageContent.getFileUrl(),
|
||||||
elementToDecrypt = messageContent.encryptedFileInfo?.toElementToDecrypt())
|
elementToDecrypt = messageContent.encryptedFileInfo?.toElementToDecrypt())
|
||||||
}
|
}
|
||||||
callback(result.getOrNull())
|
withContext(Dispatchers.Main) {
|
||||||
|
callback(result.getOrNull())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,10 @@ import im.vector.app.R
|
|||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.core.error.ErrorFormatter
|
import im.vector.app.core.error.ErrorFormatter
|
||||||
import im.vector.app.core.files.LocalFilesHelper
|
import im.vector.app.core.files.LocalFilesHelper
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import org.matrix.android.sdk.internal.crypto.attachments.ElementToDecrypt
|
import org.matrix.android.sdk.internal.crypto.attachments.ElementToDecrypt
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -83,21 +85,23 @@ class VideoContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
|||||||
url = data.url,
|
url = data.url,
|
||||||
elementToDecrypt = data.elementToDecrypt)
|
elementToDecrypt = data.elementToDecrypt)
|
||||||
}
|
}
|
||||||
result.fold(
|
withContext(Dispatchers.Main) {
|
||||||
{ data ->
|
result.fold(
|
||||||
thumbnailView.isVisible = false
|
{ data ->
|
||||||
loadingView.isVisible = false
|
thumbnailView.isVisible = false
|
||||||
videoView.isVisible = true
|
loadingView.isVisible = false
|
||||||
|
videoView.isVisible = true
|
||||||
|
|
||||||
videoView.setVideoPath(data.path)
|
videoView.setVideoPath(data.path)
|
||||||
videoView.start()
|
videoView.start()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
loadingView.isVisible = false
|
loadingView.isVisible = false
|
||||||
errorView.isVisible = true
|
errorView.isVisible = true
|
||||||
errorView.text = errorFormatter.toHumanReadable(it)
|
errorView.text = errorFormatter.toHumanReadable(it)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -124,21 +128,23 @@ class VideoContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
|||||||
url = data.url,
|
url = data.url,
|
||||||
elementToDecrypt = null)
|
elementToDecrypt = null)
|
||||||
}
|
}
|
||||||
result.fold(
|
withContext(Dispatchers.Main) {
|
||||||
{ data ->
|
result.fold(
|
||||||
thumbnailView.isVisible = false
|
{ data ->
|
||||||
loadingView.isVisible = false
|
thumbnailView.isVisible = false
|
||||||
videoView.isVisible = true
|
loadingView.isVisible = false
|
||||||
|
videoView.isVisible = true
|
||||||
|
|
||||||
videoView.setVideoPath(data.path)
|
videoView.setVideoPath(data.path)
|
||||||
videoView.start()
|
videoView.start()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
loadingView.isVisible = false
|
loadingView.isVisible = false
|
||||||
errorView.isVisible = true
|
errorView.isVisible = true
|
||||||
errorView.text = errorFormatter.toHumanReadable(it)
|
errorView.text = errorFormatter.toHumanReadable(it)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user