Set preview/experimental compiler flags instead of using annotations

(cherry picked from commit 781971ee813b9c3a71558c268365e9495dbc41c2)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
This commit is contained in:
arkon 2020-11-22 11:43:16 -05:00 committed by Jobobby04
parent b4be82d021
commit b25e604bc2
34 changed files with 15 additions and 108 deletions

View File

@ -351,7 +351,14 @@ repositories {
// See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api-markers // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api-markers
tasks.withType(AbstractKotlinCompile).all { tasks.withType(AbstractKotlinCompile).all {
kotlinOptions.freeCompilerArgs += ["-Xopt-in=kotlin.Experimental"] kotlinOptions.freeCompilerArgs += [
"-Xopt-in=kotlin.Experimental",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xuse-experimental=kotlin.ExperimentalStdlibApi",
"-Xuse-experimental=kotlinx.coroutines.FlowPreview",
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlinx.serialization.ExperimentalSerializationApi",
]
} }
// Duplicating Hebrew string assets due to some locale code issues on different devices // Duplicating Hebrew string assets due to some locale code issues on different devices

View File

@ -1,13 +1,8 @@
package eu.kanade.tachiyomi.data.backup.full.models package eu.kanade.tachiyomi.data.backup.full.models
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
/**
* Backup json model
*/
@ExperimentalSerializationApi
@Serializable @Serializable
data class Backup( data class Backup(
@ProtoNumber(1) val backupManga: List<BackupManga>, @ProtoNumber(1) val backupManga: List<BackupManga>,

View File

@ -2,11 +2,9 @@ package eu.kanade.tachiyomi.data.backup.full.models
import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.database.models.CategoryImpl import eu.kanade.tachiyomi.data.database.models.CategoryImpl
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
class BackupCategory( class BackupCategory(
@ProtoNumber(1) var name: String, @ProtoNumber(1) var name: String,

View File

@ -2,11 +2,9 @@ package eu.kanade.tachiyomi.data.backup.full.models
import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Chapter
import eu.kanade.tachiyomi.data.database.models.ChapterImpl import eu.kanade.tachiyomi.data.database.models.ChapterImpl
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupChapter( data class BackupChapter(
// in 1.x some of these values have different names // in 1.x some of these values have different names

View File

@ -4,11 +4,9 @@ import eu.kanade.tachiyomi.data.backup.full.models.metadata.BackupSearchMetadata
import eu.kanade.tachiyomi.data.backup.full.models.metadata.BackupSearchTag import eu.kanade.tachiyomi.data.backup.full.models.metadata.BackupSearchTag
import eu.kanade.tachiyomi.data.backup.full.models.metadata.BackupSearchTitle import eu.kanade.tachiyomi.data.backup.full.models.metadata.BackupSearchTitle
import exh.metadata.metadata.base.FlatMetadata import exh.metadata.metadata.base.FlatMetadata
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupFlatMetadata( data class BackupFlatMetadata(
@ProtoNumber(1) var searchMetadata: BackupSearchMetadata, @ProtoNumber(1) var searchMetadata: BackupSearchMetadata,

View File

@ -1,10 +1,8 @@
package eu.kanade.tachiyomi.data.backup.full.models package eu.kanade.tachiyomi.data.backup.full.models
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupHistory( data class BackupHistory(
@ProtoNumber(0) var url: String, @ProtoNumber(0) var url: String,

View File

@ -4,11 +4,9 @@ import eu.kanade.tachiyomi.data.database.models.ChapterImpl
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.data.database.models.MangaImpl
import eu.kanade.tachiyomi.data.database.models.TrackImpl import eu.kanade.tachiyomi.data.database.models.TrackImpl
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupManga( data class BackupManga(
// in 1.x some of these values have different names // in 1.x some of these values have different names

View File

@ -1,14 +1,12 @@
package eu.kanade.tachiyomi.data.backup.full.models package eu.kanade.tachiyomi.data.backup.full.models
import exh.merged.sql.models.MergedMangaReference import exh.merged.sql.models.MergedMangaReference
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
/* /*
* SY merged manga backup class * SY merged manga backup class
*/ */
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupMergedMangaReference( data class BackupMergedMangaReference(
@ProtoNumber(1) var isInfoManga: Boolean, @ProtoNumber(1) var isInfoManga: Boolean,

View File

@ -1,13 +1,11 @@
package eu.kanade.tachiyomi.data.backup.full.models package eu.kanade.tachiyomi.data.backup.full.models
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
/* /*
* SY saved searches class * SY saved searches class
*/ */
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupSavedSearch( data class BackupSavedSearch(
@ProtoNumber(1) val name: String, @ProtoNumber(1) val name: String,

View File

@ -1,8 +1,6 @@
package eu.kanade.tachiyomi.data.backup.full.models package eu.kanade.tachiyomi.data.backup.full.models
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializer import kotlinx.serialization.Serializer
@ExperimentalSerializationApi
@Serializer(forClass = Backup::class) @Serializer(forClass = Backup::class)
object BackupSerializer object BackupSerializer

View File

@ -1,11 +1,9 @@
package eu.kanade.tachiyomi.data.backup.full.models package eu.kanade.tachiyomi.data.backup.full.models
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupSource( data class BackupSource(
@ProtoNumber(0) var name: String = "", @ProtoNumber(0) var name: String = "",

View File

@ -2,11 +2,9 @@ package eu.kanade.tachiyomi.data.backup.full.models
import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.database.models.Track
import eu.kanade.tachiyomi.data.database.models.TrackImpl import eu.kanade.tachiyomi.data.database.models.TrackImpl
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupTracking( data class BackupTracking(
// in 1.x some of these values have different types or names // in 1.x some of these values have different types or names

View File

@ -1,11 +1,9 @@
package eu.kanade.tachiyomi.data.backup.full.models.metadata package eu.kanade.tachiyomi.data.backup.full.models.metadata
import exh.metadata.sql.models.SearchMetadata import exh.metadata.sql.models.SearchMetadata
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupSearchMetadata( data class BackupSearchMetadata(
@ProtoNumber(1) var uploader: String? = null, @ProtoNumber(1) var uploader: String? = null,

View File

@ -1,11 +1,9 @@
package eu.kanade.tachiyomi.data.backup.full.models.metadata package eu.kanade.tachiyomi.data.backup.full.models.metadata
import exh.metadata.sql.models.SearchTag import exh.metadata.sql.models.SearchTag
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupSearchTag( data class BackupSearchTag(
@ProtoNumber(1) var namespace: String? = null, @ProtoNumber(1) var namespace: String? = null,

View File

@ -1,11 +1,9 @@
package eu.kanade.tachiyomi.data.backup.full.models.metadata package eu.kanade.tachiyomi.data.backup.full.models.metadata
import exh.metadata.sql.models.SearchTitle import exh.metadata.sql.models.SearchTitle
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializable @Serializable
data class BackupSearchTitle( data class BackupSearchTitle(
@ProtoNumber(1) var title: String, @ProtoNumber(1) var title: String,

View File

@ -9,7 +9,6 @@ import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.lang.asObservable import eu.kanade.tachiyomi.util.lang.asObservable
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
@ -29,7 +28,6 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param page the page number to retrieve. * @param page the page number to retrieve.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchPopularManga(page: Int): Observable<MangasPage> { final override fun fetchPopularManga(page: Int): Observable<MangasPage> {
return fetchPopularMangaFlow(page).asObservable() return fetchPopularMangaFlow(page).asObservable()
} }
@ -73,7 +71,6 @@ abstract class SuspendHttpSource : HttpSource() {
* @param query the search query. * @param query the search query.
* @param filters the list of filters to apply. * @param filters the list of filters to apply.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> { final override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
return fetchSearchMangaSuspended(page, query, filters).asObservable() return fetchSearchMangaSuspended(page, query, filters).asObservable()
} }
@ -116,7 +113,6 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param page the page number to retrieve. * @param page the page number to retrieve.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchLatestUpdates(page: Int): Observable<MangasPage> { final override fun fetchLatestUpdates(page: Int): Observable<MangasPage> {
return fetchLatestUpdatesFlow(page).asObservable() return fetchLatestUpdatesFlow(page).asObservable()
} }
@ -158,7 +154,6 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param manga the manga to be updated. * @param manga the manga to be updated.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchMangaDetails(manga: SManga): Observable<SManga> { final override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
return fetchMangaDetailsFlow(manga).asObservable() return fetchMangaDetailsFlow(manga).asObservable()
} }
@ -203,7 +198,6 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param manga the manga to look for chapters. * @param manga the manga to look for chapters.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> { final override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
return try { return try {
fetchChapterListFlow(manga).asObservable() fetchChapterListFlow(manga).asObservable()
@ -256,7 +250,6 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param chapter the chapter whose page list has to be fetched. * @param chapter the chapter whose page list has to be fetched.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchPageList(chapter: SChapter): Observable<List<Page>> { final override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
return fetchPageListFlow(chapter).asObservable() return fetchPageListFlow(chapter).asObservable()
} }
@ -301,7 +294,6 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param page the page whose source image has to be fetched. * @param page the page whose source image has to be fetched.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchImageUrl(page: Page): Observable<String> { final override fun fetchImageUrl(page: Page): Observable<String> {
return fetchImageUrlFlow(page).asObservable() return fetchImageUrlFlow(page).asObservable()
} }
@ -345,7 +337,6 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param page the page whose source image has to be downloaded. * @param page the page whose source image has to be downloaded.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchImage(page: Page): Observable<Response> { final override fun fetchImage(page: Page): Observable<Response> {
return fetchImageFlow(page).asObservable() return fetchImageFlow(page).asObservable()
} }

View File

@ -51,7 +51,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.serialization.ExperimentalSerializationApi
import okhttp3.CacheControl import okhttp3.CacheControl
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.Headers import okhttp3.Headers
@ -120,7 +119,6 @@ class MangaDex(delegate: HttpSource, val context: Context) :
return MangaHandler(client, headers, listOf(mdLang), preferences.mangaDexForceLatestCovers().get()).fetchChapterListObservable(manga) return MangaHandler(client, headers, listOf(mdLang), preferences.mangaDexForceLatestCovers().get()).fetchChapterListObservable(manga)
} }
@ExperimentalSerializationApi
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> { override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
return if (chapter.scanlator == "MangaPlus") { return if (chapter.scanlator == "MangaPlus") {
client.newCall(mangaPlusPageListRequest(chapter)) client.newCall(mangaPlusPageListRequest(chapter))

View File

@ -43,7 +43,6 @@ import exh.util.executeOnIO
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
@ -122,7 +121,6 @@ class MigrationListController(bundle: Bundle? = null) :
} }
} }
@OptIn(ExperimentalCoroutinesApi::class)
private suspend fun runMigrations(mangas: List<MigratingManga>) { private suspend fun runMigrations(mangas: List<MigratingManga>) {
throttleManager.resetThrottle() throttleManager.resetThrottle()
if (config == null) return if (config == null) return
@ -335,7 +333,6 @@ class MigrationListController(bundle: Bundle? = null) :
} }
} }
@ExperimentalCoroutinesApi
fun useMangaForMigration(manga: Manga, source: Source) { fun useMangaForMigration(manga: Manga, source: Source) {
val firstIndex = selectedPosition ?: return val firstIndex = selectedPosition ?: return
val migratingManga = adapter?.getItem(firstIndex) ?: return val migratingManga = adapter?.getItem(firstIndex) ?: return

View File

@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.ui.browse.migration.advanced.process.MigrationListCon
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrationInterface import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrationInterface
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -100,7 +99,6 @@ class SearchController(
} else router.popController(this) } else router.popController(this)
} }
@ExperimentalCoroutinesApi
override fun onMangaClick(manga: Manga) { override fun onMangaClick(manga: Manga) {
if (targetController is MigrationListController) { if (targetController is MigrationListController) {
val migrationListController = targetController as? MigrationListController val migrationListController = targetController as? MigrationListController

View File

@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.merge
@ -53,7 +52,6 @@ class MangaChaptersHeaderAdapter(
} }
inner class HeaderViewHolder(private val view: View) : RecyclerView.ViewHolder(view) { inner class HeaderViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
@ExperimentalCoroutinesApi
fun bind() { fun bind() {
binding.chaptersLabel.text = if (numChapters == null) { binding.chaptersLabel.text = if (numChapters == null) {
view.context.getString(R.string.chapters) view.context.getString(R.string.chapters)

View File

@ -29,7 +29,6 @@ import exh.util.makeSearchChip
import exh.util.setChipsExtended import exh.util.setChipsExtended
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.merge
@ -112,7 +111,6 @@ class MangaInfoItemAdapter(
* @param manga manga object containing information about manga. * @param manga manga object containing information about manga.
* @param source the source of the manga. * @param source the source of the manga.
*/ */
@ExperimentalCoroutinesApi
private fun setMangaInfo(manga: Manga, source: Source?) { private fun setMangaInfo(manga: Manga, source: Source?) {
// Manga info section // Manga info section
val hasInfoContent = !manga.description.isNullOrBlank() || !manga.genre.isNullOrBlank() val hasInfoContent = !manga.description.isNullOrBlank() || !manga.genre.isNullOrBlank()

View File

@ -17,7 +17,6 @@ import eu.kanade.tachiyomi.ui.base.controller.DialogController
import kotlinx.android.synthetic.main.track_search_dialog.view.progress import kotlinx.android.synthetic.main.track_search_dialog.view.progress
import kotlinx.android.synthetic.main.track_search_dialog.view.track_search import kotlinx.android.synthetic.main.track_search_dialog.view.track_search
import kotlinx.android.synthetic.main.track_search_dialog.view.track_search_list import kotlinx.android.synthetic.main.track_search_dialog.view.track_search_list
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
@ -95,7 +94,6 @@ class TrackSearchDialog : DialogController {
adapter = null adapter = null
} }
@FlowPreview
override fun onAttach(view: View) { override fun onAttach(view: View) {
super.onAttach(view) super.onAttach(view)
dialogView!!.track_search.textChanges() dialogView!!.track_search.textChanges()

View File

@ -70,7 +70,6 @@ import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
import exh.util.defaultReaderType import exh.util.defaultReaderType
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel import kotlinx.coroutines.cancel
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
@ -938,7 +937,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
/** /**
* Class that handles the user preferences of the reader. * Class that handles the user preferences of the reader.
*/ */
@FlowPreview
private inner class ReaderConfig { private inner class ReaderConfig {
/** /**
@ -1059,7 +1057,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
/** /**
* Sets the custom brightness overlay according to [enabled]. * Sets the custom brightness overlay according to [enabled].
*/ */
@FlowPreview
private fun setCustomBrightness(enabled: Boolean) { private fun setCustomBrightness(enabled: Boolean) {
if (enabled) { if (enabled) {
preferences.customBrightnessValue().asFlow() preferences.customBrightnessValue().asFlow()
@ -1074,7 +1071,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
/** /**
* Sets the color filter overlay according to [enabled]. * Sets the color filter overlay according to [enabled].
*/ */
@FlowPreview
private fun setColorFilter(enabled: Boolean) { private fun setColorFilter(enabled: Boolean) {
if (enabled) { if (enabled) {
preferences.colorFilterValue().asFlow() preferences.colorFilterValue().asFlow()

View File

@ -32,7 +32,6 @@ import kotlin.coroutines.resumeWithException
* Util functions for bridging RxJava and coroutines. Taken from TachiyomiEH/SY. * Util functions for bridging RxJava and coroutines. Taken from TachiyomiEH/SY.
*/ */
@ExperimentalCoroutinesApi
suspend fun <T> Single<T>.await(subscribeOn: Scheduler? = null): T { suspend fun <T> Single<T>.await(subscribeOn: Scheduler? = null): T {
return suspendCancellableCoroutine { continuation -> return suspendCancellableCoroutine { continuation ->
val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this
@ -59,7 +58,6 @@ suspend fun <T> Single<T>.await(subscribeOn: Scheduler? = null): T {
suspend fun <T> PreparedOperation<T>.await(): T = asRxSingle().await() suspend fun <T> PreparedOperation<T>.await(): T = asRxSingle().await()
suspend fun <T> PreparedGetObject<T>.await(): T? = asRxSingle().await() suspend fun <T> PreparedGetObject<T>.await(): T? = asRxSingle().await()
@ExperimentalCoroutinesApi
suspend fun Completable.awaitSuspending(subscribeOn: Scheduler? = null) { suspend fun Completable.awaitSuspending(subscribeOn: Scheduler? = null) {
return suspendCancellableCoroutine { continuation -> return suspendCancellableCoroutine { continuation ->
val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this
@ -183,7 +181,6 @@ private suspend fun <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutin
internal fun <T> CancellableContinuation<T>.unsubscribeOnCancellation(sub: Subscription) = internal fun <T> CancellableContinuation<T>.unsubscribeOnCancellation(sub: Subscription) =
invokeOnCancellation { sub.unsubscribe() } invokeOnCancellation { sub.unsubscribe() }
@ExperimentalCoroutinesApi
fun <T : Any> Observable<T>.asFlow(): Flow<T> = callbackFlow { fun <T : Any> Observable<T>.asFlow(): Flow<T> = callbackFlow {
val observer = object : Observer<T> { val observer = object : Observer<T> {
override fun onNext(t: T) { override fun onNext(t: T) {
@ -202,7 +199,6 @@ fun <T : Any> Observable<T>.asFlow(): Flow<T> = callbackFlow {
awaitClose { subscription.unsubscribe() } awaitClose { subscription.unsubscribe() }
} }
@ExperimentalCoroutinesApi
fun <T : Any> Flow<T>.asObservable(backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE): Observable<T> { fun <T : Any> Flow<T>.asObservable(backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE): Observable<T> {
return Observable.create( return Observable.create(
{ emitter -> { emitter ->

View File

@ -48,7 +48,6 @@ fun String.byteSize(): Int {
* Returns a string containing the first [n] bytes from this string, or the entire string if this * Returns a string containing the first [n] bytes from this string, or the entire string if this
* string is shorter. * string is shorter.
*/ */
@OptIn(ExperimentalStdlibApi::class)
fun String.takeBytes(n: Int): String { fun String.takeBytes(n: Int): String {
val bytes = toByteArray(Charsets.UTF_8) val bytes = toByteArray(Charsets.UTF_8)
return if (bytes.size <= n) { return if (bytes.size <= n) {

View File

@ -20,7 +20,6 @@ import exh.metadata.metadata.base.insertFlatMetadata
import exh.savedsearches.JsonSavedSearch import exh.savedsearches.JsonSavedSearch
import exh.util.cancellable import exh.util.cancellable
import exh.util.jobScheduler import exh.util.jobScheduler
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.toList import kotlinx.coroutines.flow.toList
@ -31,7 +30,6 @@ import kotlinx.serialization.json.Json
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.lang.RuntimeException import java.lang.RuntimeException
@OptIn(FlowPreview::class)
object DebugFunctions { object DebugFunctions {
val app: Application by injectLazy() val app: Application by injectLazy()
val db: DatabaseHelper by injectLazy() val db: DatabaseHelper by injectLazy()

View File

@ -1,7 +1,6 @@
package exh.debug package exh.debug
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import kotlinx.coroutines.ExperimentalCoroutinesApi
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.Locale import java.util.Locale
@ -19,7 +18,6 @@ enum class DebugToggles(val default: Boolean) {
val prefKey = "eh_debug_toggle_${name.toLowerCase(Locale.getDefault())}" val prefKey = "eh_debug_toggle_${name.toLowerCase(Locale.getDefault())}"
@OptIn(ExperimentalCoroutinesApi::class)
var enabled: Boolean var enabled: Boolean
get() = prefs.flowPrefs.getBoolean(prefKey, default).get() get() = prefs.flowPrefs.getBoolean(prefKey, default).get()
set(value) { set(value) {

View File

@ -29,7 +29,6 @@ import exh.util.cancellable
import exh.util.jobScheduler import exh.util.jobScheduler
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
@ -130,7 +129,6 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
return true return true
} }
@OptIn(FlowPreview::class)
private suspend fun startUpdating() { private suspend fun startUpdating() {
logger.d("Update job started!") logger.d("Update job started!")
val startTime = System.currentTimeMillis() val startTime = System.currentTimeMillis()

View File

@ -3,7 +3,6 @@ package exh.md.handlers
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import exh.md.handlers.serializers.MangaPlusSerializer import exh.md.handlers.serializers.MangaPlusSerializer
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.protobuf.ProtoBuf import kotlinx.serialization.protobuf.ProtoBuf
import okhttp3.Headers import okhttp3.Headers
import okhttp3.Interceptor import okhttp3.Interceptor
@ -26,7 +25,6 @@ class MangaPlusHandler(currentClient: OkHttpClient) {
.addInterceptor { imageIntercept(it) } .addInterceptor { imageIntercept(it) }
.build() .build()
@ExperimentalSerializationApi
fun fetchPageList(chapterId: String): List<Page> { fun fetchPageList(chapterId: String): List<Page> {
val response = client.newCall(pageListRequest(chapterId)).execute() val response = client.newCall(pageListRequest(chapterId)).execute()
return pageListParse(response) return pageListParse(response)
@ -39,7 +37,6 @@ class MangaPlusHandler(currentClient: OkHttpClient) {
) )
} }
@ExperimentalSerializationApi
private fun pageListParse(response: Response): List<Page> { private fun pageListParse(response: Response): List<Page> {
val result = ProtoBuf.decodeFromByteArray(MangaPlusSerializer, response.body!!.bytes()) val result = ProtoBuf.decodeFromByteArray(MangaPlusSerializer, response.body!!.bytes())

View File

@ -5,7 +5,6 @@ import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import exh.md.utils.MdUtil import exh.md.utils.MdUtil
import kotlinx.serialization.ExperimentalSerializationApi
import okhttp3.CacheControl import okhttp3.CacheControl
import okhttp3.Headers import okhttp3.Headers
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
@ -15,7 +14,6 @@ import rx.Observable
// Unused, kept for reference todo // Unused, kept for reference todo
class PageHandler(val client: OkHttpClient, val headers: Headers, private val imageServer: String, val dataSaver: String?) { class PageHandler(val client: OkHttpClient, val headers: Headers, private val imageServer: String, val dataSaver: String?) {
@ExperimentalSerializationApi
fun fetchPageList(chapter: SChapter): Observable<List<Page>> { fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
if (chapter.scanlator.equals("MangaPlus")) { if (chapter.scanlator.equals("MangaPlus")) {
return client.newCall(pageListRequest(chapter)) return client.newCall(pageListRequest(chapter))

View File

@ -1,22 +1,18 @@
package exh.md.handlers.serializers package exh.md.handlers.serializers
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.Serializer import kotlinx.serialization.Serializer
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@ExperimentalSerializationApi
@Serializer(forClass = MangaPlusResponse::class) @Serializer(forClass = MangaPlusResponse::class)
object MangaPlusSerializer object MangaPlusSerializer
@ExperimentalSerializationApi
@Serializable @Serializable
data class MangaPlusResponse( data class MangaPlusResponse(
@ProtoNumber(1) val success: SuccessResult? = null, @ProtoNumber(1) val success: SuccessResult? = null,
@ProtoNumber(2) val error: ErrorResult? = null @ProtoNumber(2) val error: ErrorResult? = null
) )
@ExperimentalSerializationApi
@Serializable @Serializable
data class ErrorResult( data class ErrorResult(
@ProtoNumber(1) val action: Action, @ProtoNumber(1) val action: Action,
@ -26,14 +22,12 @@ data class ErrorResult(
enum class Action { DEFAULT, UNAUTHORIZED, MAINTAINENCE, GEOIP_BLOCKING } enum class Action { DEFAULT, UNAUTHORIZED, MAINTAINENCE, GEOIP_BLOCKING }
@ExperimentalSerializationApi
@Serializable @Serializable
data class Popup( data class Popup(
@ProtoNumber(1) val subject: String, @ProtoNumber(1) val subject: String,
@ProtoNumber(2) val body: String @ProtoNumber(2) val body: String
) )
@ExperimentalSerializationApi
@Serializable @Serializable
data class SuccessResult( data class SuccessResult(
@ProtoNumber(1) val isFeaturedUpdated: Boolean? = false, @ProtoNumber(1) val isFeaturedUpdated: Boolean? = false,
@ -44,19 +38,15 @@ data class SuccessResult(
@ProtoNumber(11) val webHomeView: WebHomeView? = null @ProtoNumber(11) val webHomeView: WebHomeView? = null
) )
@ExperimentalSerializationApi
@Serializable @Serializable
data class TitleRankingView(@ProtoNumber(1) val titles: List<Title> = emptyList()) data class TitleRankingView(@ProtoNumber(1) val titles: List<Title> = emptyList())
@ExperimentalSerializationApi
@Serializable @Serializable
data class AllTitlesView(@ProtoNumber(1) val titles: List<Title> = emptyList()) data class AllTitlesView(@ProtoNumber(1) val titles: List<Title> = emptyList())
@ExperimentalSerializationApi
@Serializable @Serializable
data class WebHomeView(@ProtoNumber(2) val groups: List<UpdatedTitleGroup> = emptyList()) data class WebHomeView(@ProtoNumber(2) val groups: List<UpdatedTitleGroup> = emptyList())
@ExperimentalSerializationApi
@Serializable @Serializable
data class TitleDetailView( data class TitleDetailView(
@ProtoNumber(1) val title: Title, @ProtoNumber(1) val title: Title,
@ -75,11 +65,9 @@ data class TitleDetailView(
enum class UpdateTiming { NOT_REGULARLY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY, DAY } enum class UpdateTiming { NOT_REGULARLY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY, DAY }
@ExperimentalSerializationApi
@Serializable @Serializable
data class MangaViewer(@ProtoNumber(1) val pages: List<MangaPlusPage> = emptyList()) data class MangaViewer(@ProtoNumber(1) val pages: List<MangaPlusPage> = emptyList())
@ExperimentalSerializationApi
@Serializable @Serializable
data class Title( data class Title(
@ProtoNumber(1) val titleId: Int, @ProtoNumber(1) val titleId: Int,
@ -91,7 +79,6 @@ data class Title(
@ProtoNumber(7) val language: Language? = Language.ENGLISH @ProtoNumber(7) val language: Language? = Language.ENGLISH
) )
@ExperimentalSerializationApi
@Serializable @Serializable
enum class Language(val id: Int) { enum class Language(val id: Int) {
@ProtoNumber(0) @ProtoNumber(0)
@ -101,20 +88,17 @@ enum class Language(val id: Int) {
SPANISH(1) SPANISH(1)
} }
@ExperimentalSerializationApi
@Serializable @Serializable
data class UpdatedTitleGroup( data class UpdatedTitleGroup(
@ProtoNumber(1) val groupName: String, @ProtoNumber(1) val groupName: String,
@ProtoNumber(2) val titles: List<UpdatedTitle> = emptyList() @ProtoNumber(2) val titles: List<UpdatedTitle> = emptyList()
) )
@ExperimentalSerializationApi
@Serializable @Serializable
data class UpdatedTitle( data class UpdatedTitle(
@ProtoNumber(1) val title: Title? = null @ProtoNumber(1) val title: Title? = null
) )
@ExperimentalSerializationApi
@Serializable @Serializable
data class Chapter( data class Chapter(
@ProtoNumber(1) val titleId: Int, @ProtoNumber(1) val titleId: Int,
@ -125,11 +109,9 @@ data class Chapter(
@ProtoNumber(7) val endTimeStamp: Int @ProtoNumber(7) val endTimeStamp: Int
) )
@ExperimentalSerializationApi
@Serializable @Serializable
data class MangaPlusPage(@ProtoNumber(1) val page: MangaPage? = null) data class MangaPlusPage(@ProtoNumber(1) val page: MangaPage? = null)
@ExperimentalSerializationApi
@Serializable @Serializable
data class MangaPage( data class MangaPage(
@ProtoNumber(1) val imageUrl: String, @ProtoNumber(1) val imageUrl: String,

View File

@ -2,7 +2,6 @@ package exh.md.similar
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.NetworkHelper
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType import okhttp3.MediaType.Companion.toMediaType
import okhttp3.ResponseBody import okhttp3.ResponseBody
@ -28,7 +27,6 @@ interface SimilarHttpService {
.build() .build()
} }
@ExperimentalSerializationApi
fun create(): SimilarHttpService { fun create(): SimilarHttpService {
// actual builder, which will parse the underlying json file // actual builder, which will parse the underlying json file
val adapter = Retrofit.Builder() val adapter = Retrofit.Builder()

View File

@ -1,12 +1,10 @@
package exh.util package exh.util
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ensureActive import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlin.coroutines.coroutineContext import kotlin.coroutines.coroutineContext
@FlowPreview
fun <T> Flow<T>.cancellable() = onEach { fun <T> Flow<T>.cancellable() = onEach {
coroutineContext.ensureActive() coroutineContext.ensureActive()
} }

View File

@ -6,7 +6,6 @@ import kotlinx.coroutines.CancellableContinuation
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.InternalCoroutinesApi import kotlinx.coroutines.InternalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.channels.awaitClose
@ -51,7 +50,6 @@ fun <T> Observable<T>.melt(): Observable<T> {
return rs return rs
} }
@ExperimentalCoroutinesApi
suspend fun <T> Single<T>.await(subscribeOn: Scheduler? = null): T { suspend fun <T> Single<T>.await(subscribeOn: Scheduler? = null): T {
return suspendCancellableCoroutine { continuation -> return suspendCancellableCoroutine { continuation ->
val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this
@ -78,7 +76,6 @@ suspend fun <T> Single<T>.await(subscribeOn: Scheduler? = null): T {
suspend fun <T> PreparedOperation<T>.await(): T = asRxSingle().await() suspend fun <T> PreparedOperation<T>.await(): T = asRxSingle().await()
suspend fun <T> PreparedGetObject<T>.await(): T? = asRxSingle().await() suspend fun <T> PreparedGetObject<T>.await(): T? = asRxSingle().await()
@ExperimentalCoroutinesApi
suspend fun Completable.awaitSuspending(subscribeOn: Scheduler? = null) { suspend fun Completable.awaitSuspending(subscribeOn: Scheduler? = null) {
return suspendCancellableCoroutine { continuation -> return suspendCancellableCoroutine { continuation ->
val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this
@ -136,33 +133,33 @@ suspend fun <T> Single<T>.await(): T = suspendCancellableCoroutine { cont ->
) )
} }
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class) @OptIn(InternalCoroutinesApi::class)
suspend fun <T> Observable<T>.awaitFirst(): T = first().awaitOne() suspend fun <T> Observable<T>.awaitFirst(): T = first().awaitOne()
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class) @OptIn(InternalCoroutinesApi::class)
suspend fun <T> Observable<T>.awaitFirstOrDefault(default: T): T = firstOrDefault(default).awaitOne() suspend fun <T> Observable<T>.awaitFirstOrDefault(default: T): T = firstOrDefault(default).awaitOne()
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class) @OptIn(InternalCoroutinesApi::class)
suspend fun <T> Observable<T>.awaitFirstOrNull(): T? = firstOrDefault(null).awaitOne() suspend fun <T> Observable<T>.awaitFirstOrNull(): T? = firstOrDefault(null).awaitOne()
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class) @OptIn(InternalCoroutinesApi::class)
suspend fun <T> Observable<T>.awaitFirstOrElse(defaultValue: () -> T): T = switchIfEmpty( suspend fun <T> Observable<T>.awaitFirstOrElse(defaultValue: () -> T): T = switchIfEmpty(
Observable.fromCallable( Observable.fromCallable(
defaultValue defaultValue
) )
).first().awaitOne() ).first().awaitOne()
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class) @OptIn(InternalCoroutinesApi::class)
suspend fun <T> Observable<T>.awaitLast(): T = last().awaitOne() suspend fun <T> Observable<T>.awaitLast(): T = last().awaitOne()
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class) @OptIn(InternalCoroutinesApi::class)
suspend fun <T> Observable<T>.awaitSingle(): T = single().awaitOne() suspend fun <T> Observable<T>.awaitSingle(): T = single().awaitOne()
suspend fun <T> Observable<T>.awaitSingleOrDefault(default: T): T = singleOrDefault(default).awaitOne() suspend fun <T> Observable<T>.awaitSingleOrDefault(default: T): T = singleOrDefault(default).awaitOne()
suspend fun <T> Observable<T>.awaitSingleOrNull(): T? = singleOrDefault(null).awaitOne() suspend fun <T> Observable<T>.awaitSingleOrNull(): T? = singleOrDefault(null).awaitOne()
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class) @OptIn(InternalCoroutinesApi::class)
private suspend fun <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutine { cont -> private suspend fun <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutine { cont ->
cont.unsubscribeOnCancellation( cont.unsubscribeOnCancellation(
subscribe( subscribe(
@ -202,7 +199,6 @@ private suspend fun <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutin
internal fun <T> CancellableContinuation<T>.unsubscribeOnCancellation(sub: Subscription) = internal fun <T> CancellableContinuation<T>.unsubscribeOnCancellation(sub: Subscription) =
invokeOnCancellation { sub.unsubscribe() } invokeOnCancellation { sub.unsubscribe() }
@ExperimentalCoroutinesApi
fun <T : Any> Observable<T>.asFlow(): Flow<T> = callbackFlow { fun <T : Any> Observable<T>.asFlow(): Flow<T> = callbackFlow {
val observer = object : Observer<T> { val observer = object : Observer<T> {
override fun onNext(t: T) { override fun onNext(t: T) {
@ -221,7 +217,6 @@ fun <T : Any> Observable<T>.asFlow(): Flow<T> = callbackFlow {
awaitClose { subscription.unsubscribe() } awaitClose { subscription.unsubscribe() }
} }
@ExperimentalCoroutinesApi
fun <T : Any> Flow<T>.asObservable(backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE): Observable<T> { fun <T : Any> Flow<T>.asObservable(backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE): Observable<T> {
return Observable.create( return Observable.create(
{ emitter -> { emitter ->