Tusky-App-Android/app/src/main/java/com/keylesspalace/tusky/components
Christophe Beyls 65af26993b
Optimize I/O code using Okio (#4366)
This pull request takes advantage of the Okio library to simplify, fix
or improve performance of some I/O related code in Tusky.

- Return early or throw `FileNotFoundException` early in case
`contentResolver.openInputStream()` returns `null` instead of throwing
`NullPointerException` later. Change the signature of
`Closeable.closeQuietly()` to only accept a non-null `Closeable`.
- Reimplement `Uri.copyToFile()` using Okio. This takes advantage of the
built-in high-performance buffers of the library so a buffer doesn't
need to be allocated or managed manually. The new implementation also
makes sure that the input and output streams are always closed, as the
original code could in some cases return without properly closing a
stream.
- Reimplement `ProgressRequestBody` as `Uri.asRequestBody()` (adding to
the existing extension functions available in the Okio library to create
a `RequestBody`). The new implementation uses Okio's `Buffer` instead of
a manually managed byte array, which allows to avoid copying bytes from
one buffer to the next. The max number of bytes read at once was
increased from 2K to 8K to improve performance. Avoid division by zero
in case `contentLength` is `0`. Finally, this implementation now takes a
`Uri` as input instead of an `InputStream`, because a `RequestBody` must
be replayable in case Okio retries the request, and an `InputStream` can
only be used once.
2024-04-10 21:52:55 +02:00
..
account Replace java.util.Random with kotlin Random object (#4364) 2024-04-10 21:47:27 +02:00
accountlist Replace RxJava3 code with coroutines (#4290) 2024-02-29 15:28:48 +01:00
announcements Migrate LiveData to Flow (#4337) 2024-03-27 11:34:17 +01:00
compose Optimize I/O code using Okio (#4366) 2024-04-10 21:52:55 +02:00
conversation Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
domainblocks Don't use mutable shared flows in UI (#4346) 2024-03-29 20:02:12 +01:00
drafts Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
filters Don't use mutable shared flows in UI (#4346) 2024-03-29 20:02:12 +01:00
followedtags Replace RxJava3 code with coroutines (#4290) 2024-02-29 15:28:48 +01:00
instanceinfo fix crash when instance info fails to load (#4335) 2024-03-26 18:25:34 +01:00
login show rules of the correct instance on the auth screen (#4358) 2024-04-05 12:01:54 +02:00
notifications Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
preference Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
report Migrate LiveData to Flow (#4337) 2024-03-27 11:34:17 +01:00
scheduled Replace RxJava3 code with coroutines (#4290) 2024-02-29 15:28:48 +01:00
search Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
timeline Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
trending Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
viewthread Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00