mirror of
https://github.com/BetterAndroid/PanguText.git
synced 2025-09-04 01:35:37 +08:00
refactor: add withoutTextWatchers for injectPanguText function in PanguText
This commit is contained in:
@@ -33,6 +33,7 @@ import com.highcapable.pangutext.android.PanguText
|
|||||||
import com.highcapable.pangutext.android.PanguTextConfig
|
import com.highcapable.pangutext.android.PanguTextConfig
|
||||||
import com.highcapable.pangutext.android.R
|
import com.highcapable.pangutext.android.R
|
||||||
import com.highcapable.pangutext.android.core.PanguTextWatcher
|
import com.highcapable.pangutext.android.core.PanguTextWatcher
|
||||||
|
import com.highcapable.pangutext.android.core.TextViewDelegate.Companion.delegate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of [PanguTextConfig].
|
* Create a new instance of [PanguTextConfig].
|
||||||
@@ -57,9 +58,11 @@ fun PanguTextConfig(copyFromGlobal: Boolean = true, body: PanguTextConfig.() ->
|
|||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun TextView.injectPanguText(injectHint: Boolean = true, config: PanguTextConfig = PanguText.globalConfig) {
|
fun TextView.injectPanguText(injectHint: Boolean = true, config: PanguTextConfig = PanguText.globalConfig) {
|
||||||
if (!config.isEnabled) return
|
if (!config.isEnabled) return
|
||||||
|
|
||||||
setTextWithPangu(this.text, config)
|
this.delegate.withoutTextWatchers {
|
||||||
if (injectHint) setHintWithPangu(this.hint, config)
|
setTextWithPangu(this.text, config)
|
||||||
|
if (injectHint) setHintWithPangu(this.hint, config)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user