diff --git a/app/build.gradle b/app/build.gradle index 18d4ac8ed..356d95bb4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,6 +38,14 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" project.ext.set("archivesBaseName", name + "_" + version) multiDexEnabled true + javaCompileOptions { + annotationProcessorOptions { + arguments = [ + "room.incremental" : "true", + "room.expandProjection": "true" + ] + } + } } buildTypes { release { diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 571b32139..ddb8b3f10 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -16,6 +16,7 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.Bus import io.legado.app.constant.PreferKey +import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.storage.Backup import io.legado.app.lib.theme.ATH import io.legado.app.service.BaseReadAloudService @@ -27,7 +28,6 @@ import io.legado.app.ui.main.my.MyFragment import io.legado.app.ui.main.rss.RssFragment import io.legado.app.utils.* import kotlinx.android.synthetic.main.activity_main.* -import kotlinx.coroutines.launch class MainActivity : VMBaseActivity(R.layout.activity_main), BottomNavigationView.OnNavigationItemSelectedListener, @@ -116,25 +116,23 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), override fun finish() { if (!BuildConfig.DEBUG) { - launch { - backup() - super.finish() - } - } else { - super.finish() + backup() } + super.finish() } - private suspend fun backup() { - val backupPath = getPrefString(PreferKey.backupPath) - if (backupPath?.isNotEmpty() == true) { - val uri = Uri.parse(backupPath) - val doc = DocumentFile.fromTreeUri(this, uri) - if (doc?.canWrite() == true) { - Backup.backup(this@MainActivity, uri) + private fun backup() { + Coroutine.async { + val backupPath = getPrefString(PreferKey.backupPath) + if (backupPath?.isNotEmpty() == true) { + val uri = Uri.parse(backupPath) + val doc = DocumentFile.fromTreeUri(this@MainActivity, uri) + if (doc?.canWrite() == true) { + Backup.backup(this@MainActivity, uri) + } + } else { + Backup.backup(this@MainActivity, null) } - } else { - Backup.backup(this@MainActivity, null) } } diff --git a/app/src/main/java/io/legado/app/ui/widget/BadgeView.kt b/app/src/main/java/io/legado/app/ui/widget/BadgeView.kt index a0764724e..b644ad5fb 100644 --- a/app/src/main/java/io/legado/app/ui/widget/BadgeView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/BadgeView.kt @@ -77,6 +77,7 @@ class BadgeView @JvmOverloads constructor( val typedArray = context.obtainStyledAttributes(attrs, R.styleable.BadgeView) val radios = typedArray.getDimensionPixelOffset(R.styleable.BadgeView_bv_radius, 8) + typedArray.recycle() if (layoutParams !is LayoutParams) { val layoutParams = LayoutParams( @@ -107,17 +108,9 @@ class BadgeView @JvmOverloads constructor( } fun setBackground(dipRadius: Float, badgeColor: Int) { - val radius = dip2Px(dipRadius) - val radiusArray = floatArrayOf( - radius.toFloat(), - radius.toFloat(), - radius.toFloat(), - radius.toFloat(), - radius.toFloat(), - radius.toFloat(), - radius.toFloat(), - radius.toFloat() - ) + val radius = dip2Px(dipRadius).toFloat() + val radiusArray = + floatArrayOf(radius, radius, radius, radius, radius, radius, radius, radius) val roundRect = RoundRectShape(radiusArray, null, null) val bgDrawable = ShapeDrawable(roundRect) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 1fba2ce2e..a0a4170d8 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -41,11 +41,11 @@ class FontSelectDialog : DialogFragment(), FontAdapter.CallBack { lateinit var job: Job private val fontFolderRequestCode = 35485 - private lateinit var adapter: FontAdapter private val fontFolder = App.INSTANCE.filesDir.absolutePath + File.separator + "Fonts" + File.separator override val coroutineContext: CoroutineContext get() = job + Main + private var adapter: FontAdapter? = null override fun onStart() { super.onStart() @@ -144,7 +144,7 @@ class FontSelectDialog : DialogFragment(), pathName.name.toLowerCase().matches(".*\\.[ot]tf".toRegex()) }?.let { withContext(Main) { - adapter.setItems(it.toList()) + adapter?.setItems(it.toList()) } } } catch (e: Exception) { @@ -161,7 +161,7 @@ class FontSelectDialog : DialogFragment(), file.listFiles { pathName -> pathName.name.toLowerCase().matches(".*\\.[ot]tf".toRegex()) }?.let { - adapter.setItems(it.toList()) + adapter?.setItems(it.toList()) } } catch (e: Exception) { toast(e.localizedMessage ?: "") diff --git a/app/src/main/res/layout/item_bookshelf_grid.xml b/app/src/main/res/layout/item_bookshelf_grid.xml index c36b288c5..ca639edd4 100644 --- a/app/src/main/res/layout/item_bookshelf_grid.xml +++ b/app/src/main/res/layout/item_bookshelf_grid.xml @@ -44,29 +44,21 @@ android:layout_height="26dp" android:layout_gravity="right" android:visibility="invisible" - app:loading_color="@color/colorAccent" app:loading_width="2dp" tools:ignore="RtlHardcoded" /> - - - - - + app:layout_constraintBottom_toBottomOf="@id/iv_cover" + tools:ignore="RtlHardcoded" />