-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Okio instead of
java.io
for image processing (#691)
- Loading branch information
Showing
6 changed files
with
132 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/src/main/java/eu/kanade/tachiyomi/data/coil/BufferedSourceFetcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package eu.kanade.tachiyomi.data.coil | ||
|
||
import coil3.ImageLoader | ||
import coil3.decode.DataSource | ||
import coil3.decode.ImageSource | ||
import coil3.fetch.FetchResult | ||
import coil3.fetch.Fetcher | ||
import coil3.fetch.SourceFetchResult | ||
import coil3.request.Options | ||
import okio.BufferedSource | ||
|
||
class BufferedSourceFetcher( | ||
private val data: BufferedSource, | ||
private val options: Options, | ||
) : Fetcher { | ||
|
||
override suspend fun fetch(): FetchResult { | ||
return SourceFetchResult( | ||
source = ImageSource( | ||
source = data, | ||
fileSystem = options.fileSystem, | ||
), | ||
mimeType = null, | ||
dataSource = DataSource.MEMORY, | ||
) | ||
} | ||
|
||
class Factory : Fetcher.Factory<BufferedSource> { | ||
|
||
override fun create( | ||
data: BufferedSource, | ||
options: Options, | ||
imageLoader: ImageLoader, | ||
): Fetcher { | ||
return BufferedSourceFetcher(data, options) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.