Skip to content

Commit b5a6238

Browse files
Artem Kholodnyifacebook-github-bot
Artem Kholodnyi
authored andcommitted
Convert FetchState
Reviewed By: oprisnik Differential Revision: D70243747 fbshipit-source-id: 37152effed83dadfce1192c93a5e305dda4a67ff
1 parent b5c436d commit b5a6238

File tree

3 files changed

+44
-93
lines changed

3 files changed

+44
-93
lines changed

imagepipeline-backends/imagepipeline-okhttp3/src/main/java/com/facebook/imagepipeline/backends/okhttp3/OkHttpNetworkFetcher.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ constructor(
5454
) : this(okHttpClient, okHttpClient.dispatcher().executorService())
5555

5656
class OkHttpNetworkFetchState(
57-
consumer: Consumer<EncodedImage>,
57+
consumer: Consumer<EncodedImage?>,
5858
producerContext: ProducerContext
5959
) : FetchState(consumer, producerContext) {
6060
@JvmField var submitTime: Long = 0
@@ -66,7 +66,7 @@ constructor(
6666
if (disableOkHttpCache) CacheControl.Builder().noStore().build() else null
6767

6868
override fun createFetchState(
69-
consumer: Consumer<EncodedImage>,
69+
consumer: Consumer<EncodedImage?>,
7070
context: ProducerContext
7171
): OkHttpNetworkFetchState = OkHttpNetworkFetchState(consumer, context)
7272

imagepipeline/src/main/java/com/facebook/imagepipeline/producers/FetchState.java

-91
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.imagepipeline.producers
9+
10+
import android.net.Uri
11+
import com.facebook.imagepipeline.common.BytesRange
12+
import com.facebook.imagepipeline.image.EncodedImage
13+
14+
/**
15+
* Used by [NetworkFetcher] to encapsulate the state of one network fetch.
16+
*
17+
* Implementations can subclass this to store additional fetch-scoped fields.
18+
*/
19+
open class FetchState(val consumer: Consumer<EncodedImage?>, val context: ProducerContext) {
20+
var lastIntermediateResultTimeMs: Long = 0
21+
22+
/**
23+
* EXPERIMENTAL: Allows the fetcher to set extra status flags to be included in calls to
24+
* [ ][Consumer.onNewResult].
25+
*/
26+
@get:Consumer.Status var onNewResultStatusFlags: Int = 0
27+
28+
/**
29+
* EXPERIMENTAL: Allows the fetcher to identify that the reponse is for an imcomplete portion of
30+
* the whole image by defining the range of bytes being provided.
31+
*/
32+
var responseBytesRange: BytesRange? = null
33+
34+
val id: String
35+
get() = context.id
36+
37+
val listener: ProducerListener2
38+
get() = context.producerListener
39+
40+
val uri: Uri
41+
get() = context.imageRequest.sourceUri
42+
}

0 commit comments

Comments
 (0)