mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
7201f92373
commit
96588f60c1
@ -473,6 +473,15 @@
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</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
|
||||
android:name="channel"
|
||||
|
6
app/src/main/java/io/legado/app/help/ExecutorService.kt
Normal file
6
app/src/main/java/io/legado/app/help/ExecutorService.kt
Normal file
@ -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.dpToPx
|
||||
import io.legado.app.utils.gone
|
||||
import io.legado.app.utils.setTextIfNotEqual
|
||||
import io.legado.app.utils.statusBarHeight
|
||||
import splitties.views.backgroundColor
|
||||
import java.util.Date
|
||||
@ -306,30 +307,13 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun setProgress(textPage: TextPage) = textPage.apply {
|
||||
tvBookName?.apply {
|
||||
if (text != ReadBook.book?.name) {
|
||||
text = ReadBook.book?.name
|
||||
}
|
||||
}
|
||||
tvTitle?.apply {
|
||||
if (text != textPage.title) {
|
||||
text = textPage.title
|
||||
}
|
||||
}
|
||||
tvPage?.text = "${index.plus(1)}/$pageSize"
|
||||
tvBookName?.setTextIfNotEqual(ReadBook.book?.name)
|
||||
tvTitle?.setTextIfNotEqual(textPage.title)
|
||||
tvPage?.setTextIfNotEqual("${index.plus(1)}/$pageSize")
|
||||
val readProgress = readProgress
|
||||
tvTotalProgress?.apply {
|
||||
if (text != readProgress) {
|
||||
text = readProgress
|
||||
}
|
||||
}
|
||||
tvTotalProgress1?.apply {
|
||||
val progress = "${chapterIndex.plus(1)}/${chapterSize}"
|
||||
if (text != progress) {
|
||||
text = progress
|
||||
}
|
||||
}
|
||||
tvPageAndTotal?.text = "${index.plus(1)}/$pageSize $readProgress"
|
||||
tvTotalProgress?.setTextIfNotEqual(readProgress)
|
||||
tvTotalProgress1?.setTextIfNotEqual("${chapterIndex.plus(1)}/${chapterSize}")
|
||||
tvPageAndTotal?.setTextIfNotEqual("${index.plus(1)}/$pageSize $readProgress")
|
||||
}
|
||||
|
||||
fun setAutoPager(autoPager: AutoPager?) {
|
||||
|
@ -36,13 +36,17 @@ class TitleBar @JvmOverloads constructor(
|
||||
var title: CharSequence?
|
||||
get() = toolbar.title
|
||||
set(title) {
|
||||
toolbar.title = title
|
||||
if (toolbar.title != title) {
|
||||
toolbar.title = title
|
||||
}
|
||||
}
|
||||
|
||||
var subtitle: CharSequence?
|
||||
get() = toolbar.subtitle
|
||||
set(subtitle) {
|
||||
toolbar.subtitle = subtitle
|
||||
if (toolbar.subtitle != subtitle) {
|
||||
toolbar.subtitle = subtitle
|
||||
}
|
||||
}
|
||||
|
||||
private val displayHomeAsUp: Boolean
|
||||
@ -198,7 +202,7 @@ class TitleBar @JvmOverloads constructor(
|
||||
toolbar.setSubtitleTextAppearance(context, resId)
|
||||
}
|
||||
|
||||
fun setTextColor(@ColorInt color: Int){
|
||||
fun setTextColor(@ColorInt color: Int) {
|
||||
setTitleTextColor(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.setHtml
|
||||
import io.legado.app.utils.setLayout
|
||||
import io.legado.app.utils.setTextAsync
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.ext.tables.TablePlugin
|
||||
@ -75,8 +76,9 @@ class TextDialog() : BaseDialogFragment(R.layout.dialog_text_view) {
|
||||
.build()
|
||||
.setMarkdown(binding.textView, content)
|
||||
}
|
||||
|
||||
Mode.HTML.name -> binding.textView.setHtml(content)
|
||||
else -> binding.textView.text = content
|
||||
else -> binding.textView.setTextAsync(content)
|
||||
}
|
||||
time = it.getLong("time", 0L)
|
||||
}
|
||||
|
@ -25,13 +25,17 @@ import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.view.menu.MenuPopupHelper
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.core.graphics.record
|
||||
import androidx.core.graphics.withTranslation
|
||||
import androidx.core.text.PrecomputedTextCompat
|
||||
import androidx.core.view.get
|
||||
import androidx.core.widget.TextViewCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.globalExecutor
|
||||
import io.legado.app.lib.theme.TintHelper
|
||||
import splitties.systemservices.inputMethodManager
|
||||
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")
|
||||
fun PopupMenu.show(x: Int, y: Int) {
|
||||
kotlin.runCatching {
|
||||
|
Loading…
Reference in New Issue
Block a user