优化
This commit is contained in:
@@ -473,6 +473,15 @@
|
|||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
android:resource="@xml/file_paths" />
|
android:resource="@xml/file_paths" />
|
||||||
</provider>
|
</provider>
|
||||||
|
<provider
|
||||||
|
android:name="androidx.startup.InitializationProvider"
|
||||||
|
android:authorities="${applicationId}.androidx-startup"
|
||||||
|
android:exported="false"
|
||||||
|
tools:node="merge">
|
||||||
|
<meta-data
|
||||||
|
android:name="androidx.emoji2.text.EmojiCompatInitializer"
|
||||||
|
tools:node="remove" />
|
||||||
|
</provider>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="channel"
|
android:name="channel"
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package io.legado.app.help
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
|
val globalExecutor: ExecutorService by lazy { Executors.newSingleThreadExecutor() }
|
||||||
@@ -22,6 +22,7 @@ import io.legado.app.ui.widget.BatteryView
|
|||||||
import io.legado.app.utils.activity
|
import io.legado.app.utils.activity
|
||||||
import io.legado.app.utils.dpToPx
|
import io.legado.app.utils.dpToPx
|
||||||
import io.legado.app.utils.gone
|
import io.legado.app.utils.gone
|
||||||
|
import io.legado.app.utils.setTextIfNotEqual
|
||||||
import io.legado.app.utils.statusBarHeight
|
import io.legado.app.utils.statusBarHeight
|
||||||
import splitties.views.backgroundColor
|
import splitties.views.backgroundColor
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@@ -306,30 +307,13 @@ class PageView(context: Context) : FrameLayout(context) {
|
|||||||
*/
|
*/
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
fun setProgress(textPage: TextPage) = textPage.apply {
|
fun setProgress(textPage: TextPage) = textPage.apply {
|
||||||
tvBookName?.apply {
|
tvBookName?.setTextIfNotEqual(ReadBook.book?.name)
|
||||||
if (text != ReadBook.book?.name) {
|
tvTitle?.setTextIfNotEqual(textPage.title)
|
||||||
text = ReadBook.book?.name
|
tvPage?.setTextIfNotEqual("${index.plus(1)}/$pageSize")
|
||||||
}
|
|
||||||
}
|
|
||||||
tvTitle?.apply {
|
|
||||||
if (text != textPage.title) {
|
|
||||||
text = textPage.title
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tvPage?.text = "${index.plus(1)}/$pageSize"
|
|
||||||
val readProgress = readProgress
|
val readProgress = readProgress
|
||||||
tvTotalProgress?.apply {
|
tvTotalProgress?.setTextIfNotEqual(readProgress)
|
||||||
if (text != readProgress) {
|
tvTotalProgress1?.setTextIfNotEqual("${chapterIndex.plus(1)}/${chapterSize}")
|
||||||
text = readProgress
|
tvPageAndTotal?.setTextIfNotEqual("${index.plus(1)}/$pageSize $readProgress")
|
||||||
}
|
|
||||||
}
|
|
||||||
tvTotalProgress1?.apply {
|
|
||||||
val progress = "${chapterIndex.plus(1)}/${chapterSize}"
|
|
||||||
if (text != progress) {
|
|
||||||
text = progress
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tvPageAndTotal?.text = "${index.plus(1)}/$pageSize $readProgress"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setAutoPager(autoPager: AutoPager?) {
|
fun setAutoPager(autoPager: AutoPager?) {
|
||||||
|
|||||||
@@ -36,13 +36,17 @@ class TitleBar @JvmOverloads constructor(
|
|||||||
var title: CharSequence?
|
var title: CharSequence?
|
||||||
get() = toolbar.title
|
get() = toolbar.title
|
||||||
set(title) {
|
set(title) {
|
||||||
toolbar.title = title
|
if (toolbar.title != title) {
|
||||||
|
toolbar.title = title
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var subtitle: CharSequence?
|
var subtitle: CharSequence?
|
||||||
get() = toolbar.subtitle
|
get() = toolbar.subtitle
|
||||||
set(subtitle) {
|
set(subtitle) {
|
||||||
toolbar.subtitle = subtitle
|
if (toolbar.subtitle != subtitle) {
|
||||||
|
toolbar.subtitle = subtitle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val displayHomeAsUp: Boolean
|
private val displayHomeAsUp: Boolean
|
||||||
@@ -198,7 +202,7 @@ class TitleBar @JvmOverloads constructor(
|
|||||||
toolbar.setSubtitleTextAppearance(context, resId)
|
toolbar.setSubtitleTextAppearance(context, resId)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTextColor(@ColorInt color: Int){
|
fun setTextColor(@ColorInt color: Int) {
|
||||||
setTitleTextColor(color)
|
setTitleTextColor(color)
|
||||||
setSubTitleTextColor(color)
|
setSubTitleTextColor(color)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import io.legado.app.lib.theme.primaryColor
|
|||||||
import io.legado.app.utils.applyTint
|
import io.legado.app.utils.applyTint
|
||||||
import io.legado.app.utils.setHtml
|
import io.legado.app.utils.setHtml
|
||||||
import io.legado.app.utils.setLayout
|
import io.legado.app.utils.setLayout
|
||||||
|
import io.legado.app.utils.setTextAsync
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
import io.noties.markwon.Markwon
|
import io.noties.markwon.Markwon
|
||||||
import io.noties.markwon.ext.tables.TablePlugin
|
import io.noties.markwon.ext.tables.TablePlugin
|
||||||
@@ -75,8 +76,9 @@ class TextDialog() : BaseDialogFragment(R.layout.dialog_text_view) {
|
|||||||
.build()
|
.build()
|
||||||
.setMarkdown(binding.textView, content)
|
.setMarkdown(binding.textView, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
Mode.HTML.name -> binding.textView.setHtml(content)
|
Mode.HTML.name -> binding.textView.setHtml(content)
|
||||||
else -> binding.textView.text = content
|
else -> binding.textView.setTextAsync(content)
|
||||||
}
|
}
|
||||||
time = it.getLong("time", 0L)
|
time = it.getLong("time", 0L)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,13 +25,17 @@ import android.widget.TextView
|
|||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.view.menu.MenuPopupHelper
|
import androidx.appcompat.view.menu.MenuPopupHelper
|
||||||
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.graphics.record
|
import androidx.core.graphics.record
|
||||||
import androidx.core.graphics.withTranslation
|
import androidx.core.graphics.withTranslation
|
||||||
|
import androidx.core.text.PrecomputedTextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
|
import androidx.core.widget.TextViewCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
|
import io.legado.app.help.globalExecutor
|
||||||
import io.legado.app.lib.theme.TintHelper
|
import io.legado.app.lib.theme.TintHelper
|
||||||
import splitties.systemservices.inputMethodManager
|
import splitties.systemservices.inputMethodManager
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
@@ -216,6 +220,23 @@ fun TextView.setHtml(html: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun AppCompatTextView.setTextAsync(charSequence: CharSequence) {
|
||||||
|
globalExecutor.execute {
|
||||||
|
val precomputedText = PrecomputedTextCompat.create(
|
||||||
|
charSequence, TextViewCompat.getTextMetricsParams(this),
|
||||||
|
)
|
||||||
|
post {
|
||||||
|
setPrecomputedText(precomputedText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun TextView.setTextIfNotEqual(charSequence: CharSequence?) {
|
||||||
|
if (text != charSequence) {
|
||||||
|
text = charSequence
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
fun PopupMenu.show(x: Int, y: Int) {
|
fun PopupMenu.show(x: Int, y: Int) {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
|
|||||||
Reference in New Issue
Block a user