Merge branch 'develop' into new-default-privacy-values
This commit is contained in:
commit
e734bac009
|
@ -5,6 +5,7 @@ import com.bumptech.glide.load.DataSource
|
|||
import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
|
@ -17,32 +18,41 @@ suspend fun <R> RequestBuilder<R>.submitAsync(
|
|||
height: Int = Target.SIZE_ORIGINAL
|
||||
): R {
|
||||
return suspendCancellableCoroutine { continuation ->
|
||||
val target = addListener(
|
||||
object : RequestListener<R> {
|
||||
override fun onLoadFailed(
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<R>,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
continuation.resumeWithException(e ?: GlideException("Image loading failed"))
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onResourceReady(
|
||||
resource: R & Any,
|
||||
model: Any,
|
||||
target: Target<R>?,
|
||||
dataSource: DataSource,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
if (target?.request?.isComplete == true) {
|
||||
continuation.resume(resource)
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
).submit(width, height)
|
||||
val target = addListener(ContinuationRequestListener(continuation))
|
||||
.submit(width, height)
|
||||
continuation.invokeOnCancellation { target.cancel(true) }
|
||||
}
|
||||
}
|
||||
|
||||
private class ContinuationRequestListener<R>(continuation: Continuation<R>) : RequestListener<R> {
|
||||
private var continuation: Continuation<R>? = continuation
|
||||
|
||||
override fun onLoadFailed(
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<R>,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
continuation?.let {
|
||||
continuation = null
|
||||
it.resumeWithException(e ?: GlideException("Image loading failed"))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onResourceReady(
|
||||
resource: R & Any,
|
||||
model: Any,
|
||||
target: Target<R>?,
|
||||
dataSource: DataSource,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
continuation?.let {
|
||||
if (target?.request?.isComplete == true) {
|
||||
continuation = null
|
||||
it.resume(resource)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ retrofit = "2.11.0"
|
|||
robolectric = "4.13"
|
||||
sparkbutton = "4.2.0"
|
||||
touchimageview = "3.6"
|
||||
truth = "1.4.3"
|
||||
truth = "1.4.4"
|
||||
turbine = "1.1.0"
|
||||
unified-push = "2.4.0"
|
||||
xmlwriter = "1.0.4"
|
||||
|
|
|
@ -4772,6 +4772,14 @@
|
|||
<sha256 value="24cb026df29484105ab9288c493188b1cd29ecb47dc61254f5fb818b51b60280" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="com.google.truth" name="truth" version="1.4.4">
|
||||
<artifact name="truth-1.4.4.jar">
|
||||
<sha256 value="52c86cddadc31bc8457c1e15689fc6b75e2e97ce2a83d8b54b795d556d489f8c" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
<artifact name="truth-1.4.4.pom">
|
||||
<sha256 value="def5ddc6bfa34a47dc33695db7309b8aca14fd5569dfd6d11ae9bc084318ee26" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="com.google.truth" name="truth-parent" version="1.4.2">
|
||||
<artifact name="truth-parent-1.4.2.pom">
|
||||
<sha256 value="1065626a84aaa9f228c37fc43b53c3e5901a344e2b31feea0115e10e7b130d17" origin="Generated by Gradle"/>
|
||||
|
@ -4782,6 +4790,11 @@
|
|||
<sha256 value="cc5bb8f448a2ddd130f55959ee6ba8b307a41b24c65a1c0bfd7d7a58bc0c55d2" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="com.google.truth" name="truth-parent" version="1.4.4">
|
||||
<artifact name="truth-parent-1.4.4.pom">
|
||||
<sha256 value="29c973f0fce3172b1b18bc7c9be2fbdc7ea1f0fa0801639e477ea5b66eebb49d" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="com.googlecode.juniversalchardet" name="juniversalchardet" version="1.0.3">
|
||||
<artifact name="juniversalchardet-1.0.3.jar">
|
||||
<sha256 value="757bfe906193b8b651e79dc26cd67d6b55d0770a2cdfb0381591504f779d4a76" origin="Generated by Gradle"/>
|
||||
|
|
Loading…
Reference in New Issue