Use of newest jetbrains kourtines + more insets fixed

This commit is contained in:
Jay 2019-10-26 22:43:57 -07:00
parent 1f6230c5a3
commit 7a7ada3125
11 changed files with 32 additions and 19 deletions

View File

@ -35,7 +35,7 @@ android {
defaultConfig {
applicationId "eu.kanade.tachiyomi"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 29
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 41
@ -228,7 +228,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
final coroutines_version = '0.22.2'
final coroutines_version = '1.3.2'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
}

View File

@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

View File

@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.source.online.fetchAllImageUrlsFromPageList
import eu.kanade.tachiyomi.util.*
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.async
import okhttp3.Response
import rx.Observable
import rx.android.schedulers.AndroidSchedulers

View File

@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.extension.util.ExtensionInstaller
import eu.kanade.tachiyomi.extension.util.ExtensionLoader
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.util.launchNow
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.async
import rx.Observable
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers

View File

@ -7,7 +7,7 @@ import android.content.IntentFilter
import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.extension.model.LoadResult
import eu.kanade.tachiyomi.util.launchNow
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.async
/**
* Broadcast receiver that listens for the system's packages installed, updated or removed, and only
@ -91,7 +91,11 @@ internal class ExtensionInstallReceiver(private val listener: Listener) :
private suspend fun getExtensionFromIntent(context: Context, intent: Intent?): LoadResult {
val pkgName = getPackageNameFromIntent(intent) ?:
return LoadResult.Error("Package name not found")
return async { ExtensionLoader.loadExtensionFromPkgName(context, pkgName) }.await()
/*var result:LoadResult = LoadResult.Error("")
launchNow {
result = async { ExtensionLoader.loadExtensionFromPkgName(context, pkgName) }.await()
}*/
return ExtensionLoader.loadExtensionFromPkgName(context, pkgName)
}
/**

View File

@ -13,8 +13,8 @@ import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory
import eu.kanade.tachiyomi.util.Hash
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get

View File

@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.source.online.LoginSource
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.setting.preferenceCategory
import eu.kanade.tachiyomi.util.LocaleHelper
import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener
import eu.kanade.tachiyomi.widget.preference.LoginPreference
import eu.kanade.tachiyomi.widget.preference.SourceLoginDialog
import kotlinx.android.synthetic.main.extension_detail_controller.*
@ -90,6 +91,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
extension_prefs_recycler.layoutManager = LinearLayoutManager(context)
extension_prefs_recycler.adapter = PreferenceGroupAdapter(screen)
extension_prefs_recycler.addItemDecoration(DividerItemDecoration(context, VERTICAL))
extension_prefs_recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
if (screen.preferenceCount == 0) {
extension_prefs_empty_view.show(R.drawable.ic_no_settings,

View File

@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig
import eu.kanade.tachiyomi.util.ImageUtil
import eu.kanade.tachiyomi.util.plusAssign
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.async
import rx.Completable
import rx.Observable
import rx.schedulers.Schedulers

View File

@ -35,7 +35,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig.ZoomType
import eu.kanade.tachiyomi.util.*
import eu.kanade.tachiyomi.widget.ViewPagerAdapter
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.async
import rx.Observable
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
@ -258,8 +258,10 @@ class PagerPageHolder(
bytesStream.close()
launchUI {
val image = async { BitmapFactory.decodeByteArray(bytesArray, 0, bytesArray.size) }
imageView.background = ImageUtil.autoSetBackground(image.await())
val image = async { BitmapFactory.decodeByteArray(bytesArray, 0,
bytesArray.size) }
imageView.background = ImageUtil.autoSetBackground(image
.await())
page.bg = imageView.background
}
}

View File

@ -1,13 +1,16 @@
package eu.kanade.tachiyomi.util
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.CoroutineStart
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Job
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlin.coroutines.EmptyCoroutineContext
fun launchUI(block: suspend CoroutineScope.() -> Unit): Job =
launch(UI, CoroutineStart.DEFAULT, null, block)
GlobalScope.launch(Dispatchers.Main,CoroutineStart.DEFAULT,block)
// .DEFAULT, null, block)
fun launchNow(block: suspend CoroutineScope.() -> Unit): Job =
launch(UI, CoroutineStart.UNDISPATCHED, null, block)
GlobalScope.launch(Dispatchers.Main,CoroutineStart.UNDISPATCHED,block)

View File

@ -78,6 +78,7 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:clipToPadding="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"