Tusky-App-Android/app/src/main/java/com/keylesspalace/tusky/util
Christophe Beyls 40fde54e0b
Replace RxJava3 code with coroutines (#4290)
This pull request removes the remaining RxJava code and replaces it with
coroutine-equivalent implementations.

- Remove all duplicate methods in `MastodonApi`:
- Methods returning a RxJava `Single` have been replaced by suspending
methods returning a `NetworkResult` in order to be consistent with the
new code.
- _sync_/_async_ method variants are replaced with the _async_ version
only (suspending method), and `runBlocking{}` is used to make the async
variant synchronous.
- Create a custom coroutine-based implementation of `Single` for usage
in Java code where launching a coroutine is not possible. This class can
be deleted after remaining Java code has been converted to Kotlin.
- `NotificationsFragment.java` can subscribe to `EventHub` events by
calling the new lifecycle-aware `EventHub.subscribe()` method. This
allows using the `SharedFlow` as single source of truth for all events.
- Rx Autodispose is replaced by `lifecycleScope.launch()` which will
automatically cancel the coroutine when the Fragment view/Activity is
destroyed.
- Background work is launched in the existing injectable
`externalScope`, since using `GlobalScope` is discouraged.
`externalScope` has been changed to be a `@Singleton` and to use the
main dispatcher by default.
- Transform `ShareShortcutHelper` to an injectable utility class so it
can use the application `Context` and `externalScope` as provided
dependencies to launch a background coroutine.
- Implement a custom Glide extension method
`RequestBuilder.submitAsync()` to do the same thing as
`RequestBuilder.submit().get()` in a non-blocking way. This way there is
no need to switch to a background dispatcher and block a background
thread, and cancellation is supported out-of-the-box.
- An utility method `Fragment.updateRelativeTimePeriodically()` has been
added to remove duplicate logic in `TimelineFragment` and
`NotificationsFragment`, and the logic is now implemented using a simple
coroutine instead of `Observable.interval()`. Note that the periodic
update now happens between onStart and onStop instead of between
onResume and onPause, since the Fragment is not interactive but is still
visible in the started state.
- Rewrite `BottomSheetActivityTest` using coroutines tests.
- Remove all RxJava library dependencies.
2024-02-29 15:28:48 +01: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 upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
CustomFragmentStateAdapter.kt add ktlint plugin to project and apply default code style (#2209) 2021-06-28 21:13:24 +02:00
Either.kt add ktlint plugin to project and apply default code style (#2209) 2021-06-28 21:13:24 +02: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 upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01: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 upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01: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 upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
MediaUtils.kt Replace RxJava3 code with coroutines (#4290) 2024-02-29 15:28:48 +01: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 upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +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 Fix Timeline not loading (#2398) 2022-03-28 18:39:16 +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 upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
ViewExtensions.kt Ensure textview fields can be copy/pasted (#3707) 2023-06-11 18:39:48 +02:00