Fix ANR when deleting a video during story creation.
This commit is contained in:
parent
2a4ccf69b2
commit
f2707d053d
2 changed files with 10 additions and 3 deletions
|
@ -12,6 +12,7 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
|||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.core.Maybe
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.disposables.Disposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
|
@ -123,9 +124,11 @@ class MediaSelectionViewModel(
|
|||
}
|
||||
|
||||
disposables += selectedMediaSubject
|
||||
.subscribeOn(Schedulers.io())
|
||||
.map { media -> Stories.MediaTransform.getSendRequirements(media) }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMapSingle { media ->
|
||||
Single.fromCallable {
|
||||
Stories.MediaTransform.getSendRequirements(media)
|
||||
}.subscribeOn(Schedulers.io())
|
||||
}
|
||||
.subscribeBy { requirements ->
|
||||
store.update {
|
||||
it.copy(storySendRequirements = requirements)
|
||||
|
@ -495,12 +498,14 @@ class MediaSelectionViewModel(
|
|||
putBoolean(BUNDLE_IS_IMAGE, true)
|
||||
}
|
||||
}
|
||||
|
||||
is VideoEditorFragment.Data -> {
|
||||
value.bundle.apply {
|
||||
putParcelable(BUNDLE_URI, key)
|
||||
putBoolean(BUNDLE_IS_IMAGE, false)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
|
|
@ -273,6 +273,8 @@ object Stories {
|
|||
@JvmStatic
|
||||
@WorkerThread
|
||||
fun getVideoDuration(uri: Uri): Long {
|
||||
ThreadUtil.assertNotMainThread()
|
||||
|
||||
var duration = 0L
|
||||
var player: ExoPlayer? = null
|
||||
val countDownLatch = CountDownLatch(1)
|
||||
|
|
Loading…
Add table
Reference in a new issue