Tusky-App-Android/app/src/main/java/com/keylesspalace/tusky/util
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
..
AbsoluteTimeFormatter.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
ActivityExensions.kt Better screen transitions (#4285) 2024-02-25 16:20:15 +01:00
AlertDialogExtensions.kt Fix some warnings & recreate lint-baseline.xml (#4278) 2024-02-25 16:20:26 +01:00
AsciiFolding.kt Fix the tag span generation for tags with nonascii characters (#2700) 2022-09-17 19:06:45 +02:00
AttachmentHelper.kt Add option to not crop image previews (#2832) 2022-12-01 21:20:46 +01:00
BindingHolder.kt add ktlint plugin to project and apply default code style (#2209) 2021-06-28 21:13:24 +02:00
BlurHashDecoder.kt add ktlint plugin to project and apply default code style (#2209) 2021-06-28 21:13:24 +02:00
CardViewMode.kt add ktlint plugin to project and apply default code style (#2209) 2021-06-28 21:13:24 +02:00
CompositeWithOpaqueBackground.kt fix memory leak in CompositeWithOpaqueBackground (#4150) 2023-12-10 07:37:54 +01:00
CryptoUtil.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
CustomEmojiHelper.kt Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
CustomFragmentStateAdapter.kt add ktlint plugin to project and apply default code style (#2209) 2021-06-28 21:13:24 +02:00
Either.kt Remove redundant crossinline (#4348) 2024-03-29 21:12:49 +01:00
EmptyPagingSource.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
FlowExtensions.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
FocalPointUtil.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
GlideExtensions.kt Replace RxJava3 code with coroutines (#4290) 2024-02-29 15:28:48 +01:00
GlideModule.kt support animated PNGs and WEBPs (#2244) 2021-10-09 10:45:41 +02:00
HttpHeaderLink.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
IOUtils.kt Optimize I/O code using Okio (#4366) 2024-04-10 21:52:55 +02:00
IconUtils.kt Convert util/{HttpHeaderLink,PairedList,TimestampUtils,ThemeUtils} to Kotlin (#3046) 2022-12-31 13:01:35 +01:00
ImageLoadingHelper.kt Composite semi-transparent avatars over a solid background (#3874) 2023-08-08 23:09:59 +02:00
Lazy.kt Use unsafeLazy to simplify thread unsafe lazy initializations (#3276) 2023-02-20 20:14:54 +01:00
LinkHelper.kt Fix some warnings & recreate lint-baseline.xml (#4278) 2024-02-25 16:20:26 +01:00
ListStatusAccessibilityDelegate.kt Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
ListUtils.kt update Kotlin to 1.7.10 and fix some (new?) warnings (#2647) 2022-08-07 19:36:09 +02:00
LocaleExtensions.kt Code cleanups (#3264) 2023-02-20 19:58:37 +01:00
LocaleManager.kt update ktlint plugin to 11.3.1, format code (#3442) 2023-03-13 13:16:39 +01:00
LocaleUtils.kt Machine translation of posts (#4307) 2024-03-09 16:12:18 +01:00
MediaUtils.kt Optimize I/O code using Okio (#4366) 2024-04-10 21:52:55 +02:00
NoUnderlineURLSpan.kt Kotlin 1.9.0 (#3835) 2023-08-02 09:04:24 +02:00
NotificationTypeConverter.kt update ktlint plugin to 11.3.1, format code (#3442) 2023-03-13 13:16:39 +01:00
NumberUtils.kt Replace shortNumber() with formatNumber() (#3519) 2023-06-10 16:29:26 +02:00
PairedList.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
PickMediaFiles.kt add ktlint plugin to project and apply default code style (#2209) 2021-06-28 21:13:24 +02:00
RelativeTimeUpdater.kt Replace RxJava3 code with coroutines (#4290) 2024-02-29 15:28:48 +01:00
Resource.kt Convert some sealed classes to interfaces (#4347) 2024-03-29 20:11:53 +01:00
RickRoll.kt add ktlint plugin to project and apply default code style (#2209) 2021-06-28 21:13:24 +02:00
ShareShortcutHelper.kt Replace RxJava3 code with coroutines (#4290) 2024-02-29 15:28:48 +01:00
SharedPreferencesExtensions.kt New settings (#891) 2018-11-12 21:09:39 +01:00
Single.kt Replace RxJava3 code with coroutines (#4290) 2024-02-29 15:28:48 +01:00
SmartLengthInputFilter.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
SpanUtils.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
StatusDisplayOptions.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
StatusParsingHelper.kt Support code blocks (#4090) 2023-11-01 09:22:23 +01:00
StatusViewHelper.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
StringUtils.kt Replace java.util.Random with kotlin Random object (#4364) 2024-04-10 21:47:27 +02:00
ThemeUtils.kt fix theme preference defaults (#4061) 2023-10-14 14:20:20 +02:00
ThrowableExtensions.kt upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
TimestampUtils.kt Revert "make timestamp abbreviations plurals (#4202)" (#4230) 2024-01-28 19:48:35 +01:00
TouchDelegateHelper.kt fix crash in TouchDelegateHelper when not all views are available (#3016) 2022-12-07 19:34:54 +01:00
ViewBindingExtensions.kt Simplify and reduce overhead of lazy view binding in Fragments (#4269) 2024-02-23 20:10:33 +01:00
ViewDataUtils.kt Machine translation of posts (#4307) 2024-03-09 16:12:18 +01:00
ViewExtensions.kt Ensure textview fields can be copy/pasted (#3707) 2023-06-11 18:39:48 +02:00