mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
3d50a72c62
commit
31dafd48d4
@ -57,10 +57,10 @@ class AddToBookshelfDialog() : BaseDialogFragment(R.layout.dialog_add_to_bookshe
|
||||
}
|
||||
viewModel.loadStateLiveData.observe(this) {
|
||||
if (it) {
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
binding.bookInfo.invisible()
|
||||
} else {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
}
|
||||
}
|
||||
viewModel.loadErrorLiveData.observe(this) {
|
||||
|
@ -47,7 +47,7 @@ class FileAssociationActivity :
|
||||
override val viewModel by viewModels<FileAssociationViewModel>()
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
viewModel.importBookLiveData.observe(this) { uri ->
|
||||
importBook(uri)
|
||||
}
|
||||
@ -80,19 +80,19 @@ class FileAssociationActivity :
|
||||
}
|
||||
}
|
||||
viewModel.errorLive.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
toastOnUi(it)
|
||||
finish()
|
||||
}
|
||||
viewModel.openBookLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
startActivity<ReadBookActivity> {
|
||||
putExtra("bookUrl", it)
|
||||
}
|
||||
finish()
|
||||
}
|
||||
viewModel.notSupportedLiveData.observe(this) { data ->
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
alert(
|
||||
title = appCtx.getString(R.string.draw),
|
||||
message = appCtx.getString(R.string.file_not_supported, data.second)
|
||||
|
@ -64,7 +64,7 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.setTitle(R.string.import_book_source)
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
initMenu()
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.recyclerView.adapter = adapter
|
||||
@ -93,14 +93,14 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
|
||||
upSelectText()
|
||||
}
|
||||
viewModel.errorLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
binding.tvMsg.apply {
|
||||
text = it
|
||||
visible()
|
||||
}
|
||||
}
|
||||
viewModel.successLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
if (it > 0) {
|
||||
adapter.setItems(viewModel.allSources)
|
||||
upSelectText()
|
||||
|
@ -55,7 +55,7 @@ class ImportHttpTtsDialog() : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.setTitle(R.string.import_tts)
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.tvCancel.visible()
|
||||
@ -83,14 +83,14 @@ class ImportHttpTtsDialog() : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
upSelectText()
|
||||
}
|
||||
viewModel.errorLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
binding.tvMsg.apply {
|
||||
text = it
|
||||
visible()
|
||||
}
|
||||
}
|
||||
viewModel.successLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
if (it > 0) {
|
||||
adapter.setItems(viewModel.allSources)
|
||||
upSelectText()
|
||||
|
@ -41,18 +41,18 @@ class ImportOnLineBookFileDialog : BaseDialogFragment(R.layout.dialog_recycler_v
|
||||
viewModel.initData(bookUrl)
|
||||
binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.setTitle(R.string.download_and_import_file)
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.recyclerView.adapter = adapter
|
||||
viewModel.errorLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
binding.tvMsg.apply {
|
||||
text = it
|
||||
visible()
|
||||
}
|
||||
}
|
||||
viewModel.successLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
if (it > 0) {
|
||||
adapter.setItems(viewModel.allBookFiles)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.setTitle(R.string.import_replace_rule)
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
initMenu()
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.recyclerView.adapter = adapter
|
||||
@ -88,14 +88,14 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
|
||||
upSelectText()
|
||||
}
|
||||
viewModel.errorLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
binding.tvMsg.apply {
|
||||
text = it
|
||||
visible()
|
||||
}
|
||||
}
|
||||
viewModel.successLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
if (it > 0) {
|
||||
adapter.setItems(viewModel.allRules)
|
||||
upSelectText()
|
||||
|
@ -63,7 +63,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.setTitle(R.string.import_rss_source)
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
initMenu()
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.recyclerView.adapter = adapter
|
||||
@ -92,14 +92,14 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
|
||||
upSelectText()
|
||||
}
|
||||
viewModel.errorLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
binding.tvMsg.apply {
|
||||
text = it
|
||||
visible()
|
||||
}
|
||||
}
|
||||
viewModel.successLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
if (it > 0) {
|
||||
adapter.setItems(viewModel.allSources)
|
||||
upSelectText()
|
||||
|
@ -54,7 +54,7 @@ class ImportThemeDialog() : BaseDialogFragment(R.layout.dialog_recycler_view) {
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.setTitle(R.string.import_theme)
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.tvCancel.visible()
|
||||
@ -82,14 +82,14 @@ class ImportThemeDialog() : BaseDialogFragment(R.layout.dialog_recycler_view) {
|
||||
upSelectText()
|
||||
}
|
||||
viewModel.errorLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
binding.tvMsg.apply {
|
||||
text = it
|
||||
visible()
|
||||
}
|
||||
}
|
||||
viewModel.successLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
if (it > 0) {
|
||||
adapter.setItems(viewModel.allSources)
|
||||
upSelectText()
|
||||
|
@ -54,7 +54,7 @@ class ImportTxtTocRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.setTitle(R.string.import_txt_toc_rule)
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.tvCancel.visible()
|
||||
@ -82,14 +82,14 @@ class ImportTxtTocRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
|
||||
upSelectText()
|
||||
}
|
||||
viewModel.errorLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
binding.tvMsg.apply {
|
||||
text = it
|
||||
visible()
|
||||
}
|
||||
}
|
||||
viewModel.successLiveData.observe(this) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
if (it > 0) {
|
||||
adapter.setItems(viewModel.allSources)
|
||||
upSelectText()
|
||||
|
@ -66,7 +66,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
||||
ChangeChapterTocAdapter(requireContext(), this)
|
||||
}
|
||||
private val contentSuccess: (content: String) -> Unit = {
|
||||
binding.loadingToc.hide()
|
||||
binding.loadingToc.gone()
|
||||
callBack?.replaceContent(it)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
@ -267,7 +267,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
||||
this.searchBook = searchBook
|
||||
tocAdapter.setItems(null)
|
||||
binding.clToc.visible()
|
||||
binding.loadingToc.show()
|
||||
binding.loadingToc.visible()
|
||||
val book = searchBook.toBook()
|
||||
viewModel.getToc(book, {
|
||||
binding.clToc.gone()
|
||||
@ -275,7 +275,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
||||
}) { toc: List<BookChapter>, _: BookSource ->
|
||||
tocAdapter.durChapterIndex =
|
||||
BookHelp.getDurChapter(viewModel.chapterIndex, viewModel.chapterTitle, toc)
|
||||
binding.loadingToc.hide()
|
||||
binding.loadingToc.gone()
|
||||
tocAdapter.setItems(toc)
|
||||
binding.recyclerViewToc.scrollToPosition(tocAdapter.durChapterIndex - 5)
|
||||
}
|
||||
@ -321,9 +321,9 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
||||
|
||||
override fun clickChapter(bookChapter: BookChapter, nextChapterUrl: String?) {
|
||||
searchBook?.let {
|
||||
binding.loadingToc.show()
|
||||
binding.loadingToc.visible()
|
||||
viewModel.getContent(it.toBook(), bookChapter, nextChapterUrl, contentSuccess) { msg ->
|
||||
binding.loadingToc.hide()
|
||||
binding.loadingToc.gone()
|
||||
binding.clToc.gone()
|
||||
toastOnUi(msg)
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ class ContentEditDialog : BaseDialogFragment(R.layout.dialog_content_edit) {
|
||||
}
|
||||
viewModel.loadStateLiveData.observe(viewLifecycleOwner) {
|
||||
if (it) {
|
||||
binding.rlLoading.show()
|
||||
binding.rlLoading.visible()
|
||||
} else {
|
||||
binding.rlLoading.hide()
|
||||
binding.rlLoading.gone()
|
||||
}
|
||||
}
|
||||
viewModel.initContent {
|
||||
|
@ -50,7 +50,7 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
|
||||
launch {
|
||||
adapter.addItem(msg)
|
||||
if (state == -1 || state == 1000) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,7 +165,7 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
|
||||
private fun startSearch(key: String) {
|
||||
adapter.clearItems()
|
||||
viewModel.startDebug(key, {
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
}, {
|
||||
toastOnUi("未获取到书源")
|
||||
})
|
||||
|
@ -12,7 +12,6 @@ import io.legado.app.data.entities.DictRule
|
||||
import io.legado.app.databinding.DialogDictBinding
|
||||
import io.legado.app.lib.theme.accentColor
|
||||
import io.legado.app.lib.theme.backgroundColor
|
||||
import io.legado.app.utils.invisible
|
||||
import io.legado.app.utils.setHtml
|
||||
import io.legado.app.utils.setLayout
|
||||
import io.legado.app.utils.toastOnUi
|
||||
@ -60,11 +59,12 @@ class DictDialog() : BaseDialogFragment(R.layout.dialog_dict) {
|
||||
|
||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||
val dictRule = tab.tag as DictRule
|
||||
binding.rotateLoading.visible()
|
||||
viewModel.dict(dictRule, word!!)
|
||||
}
|
||||
})
|
||||
viewModel.dictHtmlData.observe(viewLifecycleOwner) {
|
||||
binding.rotateLoading.invisible()
|
||||
binding.rotateLoading.inVisible()
|
||||
binding.tvDict.setHtml(it)
|
||||
}
|
||||
viewModel.initData {
|
||||
|
@ -6,7 +6,6 @@ import io.legado.app.base.BaseViewModel
|
||||
import io.legado.app.data.entities.DictRule
|
||||
import io.legado.app.help.DefaultData
|
||||
import io.legado.app.utils.toastOnUi
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class DictViewModel(application: Application) : BaseViewModel(application) {
|
||||
var dictRules: List<DictRule>? = null
|
||||
@ -31,16 +30,5 @@ class DictViewModel(application: Application) : BaseViewModel(application) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否包含汉字
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
|
||||
private fun isChinese(str: String): Boolean {
|
||||
val p = Pattern.compile("[\u4e00-\u9fa5]")
|
||||
val m = p.matcher(str)
|
||||
return m.find()
|
||||
}
|
||||
|
||||
}
|
@ -43,9 +43,9 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
||||
private fun upRefresh(binding: ItemBookshelfGridBinding, item: Book) {
|
||||
if (!item.isLocal && callBack.isUpdate(item.bookUrl)) {
|
||||
binding.bvUnread.invisible()
|
||||
binding.rlLoading.show()
|
||||
binding.rlLoading.visible()
|
||||
} else {
|
||||
binding.rlLoading.hide()
|
||||
binding.rlLoading.inVisible()
|
||||
if (AppConfig.showUnread) {
|
||||
binding.bvUnread.setBadgeCount(item.getUnreadChapterNum())
|
||||
binding.bvUnread.setHighlight(item.lastCheckCount > 0)
|
||||
|
@ -52,9 +52,9 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) :
|
||||
private fun upRefresh(binding: ItemBookshelfListBinding, item: Book) {
|
||||
if (!item.isLocal && callBack.isUpdate(item.bookUrl)) {
|
||||
binding.bvUnread.invisible()
|
||||
binding.rlLoading.show()
|
||||
binding.rlLoading.visible()
|
||||
} else {
|
||||
binding.rlLoading.hide()
|
||||
binding.rlLoading.gone()
|
||||
if (AppConfig.showUnread) {
|
||||
binding.bvUnread.setHighlight(item.lastCheckCount > 0)
|
||||
binding.bvUnread.setBadgeCount(item.getUnreadChapterNum())
|
||||
|
@ -113,9 +113,9 @@ class BooksAdapterGrid(context: Context, callBack: CallBack) :
|
||||
private fun upRefresh(binding: ItemBookshelfGridBinding, item: Book) {
|
||||
if (!item.isLocal && callBack.isUpdate(item.bookUrl)) {
|
||||
binding.bvUnread.invisible()
|
||||
binding.rlLoading.show()
|
||||
binding.rlLoading.visible()
|
||||
} else {
|
||||
binding.rlLoading.hide()
|
||||
binding.rlLoading.inVisible()
|
||||
if (AppConfig.showUnread) {
|
||||
binding.bvUnread.setBadgeCount(item.getUnreadChapterNum())
|
||||
binding.bvUnread.setHighlight(item.lastCheckCount > 0)
|
||||
|
@ -128,9 +128,9 @@ class BooksAdapterList(context: Context, callBack: CallBack) :
|
||||
private fun upRefresh(binding: ItemBookshelfListBinding, item: Book) {
|
||||
if (!item.isLocal && callBack.isUpdate(item.bookUrl)) {
|
||||
binding.bvUnread.invisible()
|
||||
binding.rlLoading.show()
|
||||
binding.rlLoading.visible()
|
||||
} else {
|
||||
binding.rlLoading.hide()
|
||||
binding.rlLoading.gone()
|
||||
if (AppConfig.showUnread) {
|
||||
binding.bvUnread.setHighlight(item.lastCheckCount > 0)
|
||||
binding.bvUnread.setBadgeCount(item.getUnreadChapterNum())
|
||||
|
@ -53,7 +53,7 @@ class ExploreAdapter(context: Context, val callBack: CallBack) :
|
||||
if (exIndex == holder.layoutPosition) {
|
||||
ivStatus.setImageResource(R.drawable.ic_arrow_down)
|
||||
rotateLoading.loadingColor = context.accentColor
|
||||
rotateLoading.show()
|
||||
rotateLoading.visible()
|
||||
if (scrollTo >= 0) {
|
||||
callBack.scrollTo(scrollTo)
|
||||
}
|
||||
@ -62,7 +62,7 @@ class ExploreAdapter(context: Context, val callBack: CallBack) :
|
||||
}.onSuccess { kindList ->
|
||||
upKindList(flexbox, item.bookSourceUrl, kindList)
|
||||
}.onFinally {
|
||||
rotateLoading.hide()
|
||||
rotateLoading.gone()
|
||||
if (scrollTo >= 0) {
|
||||
callBack.scrollTo(scrollTo)
|
||||
scrollTo = -1
|
||||
@ -70,7 +70,7 @@ class ExploreAdapter(context: Context, val callBack: CallBack) :
|
||||
}
|
||||
} else kotlin.runCatching {
|
||||
ivStatus.setImageResource(R.drawable.ic_arrow_right)
|
||||
rotateLoading.hide()
|
||||
rotateLoading.gone()
|
||||
recyclerFlexbox(flexbox)
|
||||
flexbox.gone()
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class RssSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, RssSou
|
||||
launch {
|
||||
adapter.addItem(msg)
|
||||
if (state == -1 || state == 1000) {
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.gone()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,7 +68,7 @@ class RssSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, RssSou
|
||||
private fun startDebug() {
|
||||
adapter.clearItems()
|
||||
viewModel.rssSource?.let {
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
viewModel.startDebug(it)
|
||||
} ?: toastOnUi(R.string.error_no_source)
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class RotateLoading @JvmOverloads constructor(
|
||||
|
||||
private var shadowPosition: Int = 0
|
||||
|
||||
var hideMode = GONE
|
||||
private var hideMode = GONE
|
||||
|
||||
var isStarted = false
|
||||
private set
|
||||
@ -78,10 +78,6 @@ class RotateLoading @JvmOverloads constructor(
|
||||
)
|
||||
speedOfDegree =
|
||||
typedArray.getInt(R.styleable.RotateLoading_loading_speed, DEFAULT_SPEED_OF_DEGREE)
|
||||
hideMode = when (typedArray.getInt(R.styleable.RotateLoading_hide_mode, 2)) {
|
||||
1 -> INVISIBLE
|
||||
else -> GONE
|
||||
}
|
||||
typedArray.recycle()
|
||||
}
|
||||
speedOfArc = (speedOfDegree / 4).toFloat()
|
||||
@ -174,13 +170,21 @@ class RotateLoading @JvmOverloads constructor(
|
||||
removeCallbacks(hidden)
|
||||
}
|
||||
|
||||
fun show() {
|
||||
fun visible() {
|
||||
removeCallbacks(shown)
|
||||
removeCallbacks(hidden)
|
||||
post(shown)
|
||||
}
|
||||
|
||||
fun hide() {
|
||||
fun inVisible() {
|
||||
hideMode = INVISIBLE
|
||||
removeCallbacks(shown)
|
||||
removeCallbacks(hidden)
|
||||
stopInternal()
|
||||
}
|
||||
|
||||
fun gone() {
|
||||
hideMode = GONE
|
||||
removeCallbacks(shown)
|
||||
removeCallbacks(hidden)
|
||||
stopInternal()
|
||||
|
@ -44,12 +44,12 @@ class LoadMoreView(context: Context, attrs: AttributeSet? = null) : FrameLayout(
|
||||
fun startLoad() {
|
||||
isLoading = true
|
||||
binding.tvText.invisible()
|
||||
binding.rotateLoading.show()
|
||||
binding.rotateLoading.visible()
|
||||
}
|
||||
|
||||
fun stopLoad() {
|
||||
isLoading = false
|
||||
binding.rotateLoading.hide()
|
||||
binding.rotateLoading.inVisible()
|
||||
}
|
||||
|
||||
fun hasMore() {
|
||||
|
@ -11,6 +11,7 @@ import java.io.File
|
||||
import java.lang.Character.codePointCount
|
||||
import java.lang.Character.offsetByCodePoints
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
|
||||
fun String?.safeTrim() = if (this.isNullOrBlank()) null else this.trim()
|
||||
|
||||
@ -99,6 +100,15 @@ fun String?.memorySize(): Int {
|
||||
return 40 + 2 * length
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否中文
|
||||
*/
|
||||
fun String.isChinese(): Boolean {
|
||||
val p = Pattern.compile("[\u4e00-\u9fa5]")
|
||||
val m = p.matcher(this)
|
||||
return m.find()
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串拆分为单个字符,包含emoji
|
||||
*/
|
||||
|
@ -52,7 +52,6 @@
|
||||
android:layout_height="22dp"
|
||||
android:layout_gravity="right"
|
||||
android:visibility="invisible"
|
||||
app:hide_mode="invisible"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:loading_width="2dp"
|
||||
|
@ -51,7 +51,6 @@
|
||||
android:layout_height="22dp"
|
||||
android:layout_gravity="right"
|
||||
android:visibility="invisible"
|
||||
app:hide_mode="invisible"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:loading_width="2dp"
|
||||
|
@ -36,7 +36,6 @@
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginRight="4dp"
|
||||
app:hide_mode="gone"
|
||||
app:loading_width="1dp"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
android:layout_margin="6dp"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="invisible"
|
||||
app:hide_mode="invisible"
|
||||
app:loading_width="2dp" />
|
||||
|
||||
<TextView
|
||||
|
@ -128,12 +128,6 @@
|
||||
<attr name="loading_color" format="color" />
|
||||
<attr name="shadow_position" format="integer" />
|
||||
<attr name="loading_speed" format="integer" />
|
||||
<attr name="hide_mode">
|
||||
<!-- Not displayed, but taken into account during layout (space is left for it). -->
|
||||
<enum name="invisible" value="1" />
|
||||
<!-- Completely hidden, as if the view had not been added. -->
|
||||
<enum name="gone" value="2" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="CircleImageView">
|
||||
|
Loading…
Reference in New Issue
Block a user