delete anko:anko-sdk27-coroutines

pull/840/head
gedoor 4 years ago
parent a03eba41d7
commit 4c0bc940fe
  1. 10
      app/src/main/java/io/legado/app/base/BaseViewModel.kt
  2. 6
      app/src/main/java/io/legado/app/help/ContentProcessor.kt
  3. 6
      app/src/main/java/io/legado/app/help/IntentHelp.kt
  4. 4
      app/src/main/java/io/legado/app/help/LauncherIconHelp.kt
  5. 6
      app/src/main/java/io/legado/app/help/SourceHelp.kt
  6. 4
      app/src/main/java/io/legado/app/help/permission/PermissionActivity.kt
  7. 6
      app/src/main/java/io/legado/app/help/storage/BookWebDav.kt
  8. 28
      app/src/main/java/io/legado/app/help/storage/ImportOldData.kt
  9. 2
      app/src/main/java/io/legado/app/help/storage/Restore.kt
  10. 10
      app/src/main/java/io/legado/app/service/AudioPlayService.kt
  11. 4
      app/src/main/java/io/legado/app/service/CacheBookService.kt
  12. 4
      app/src/main/java/io/legado/app/service/CheckSourceService.kt
  13. 4
      app/src/main/java/io/legado/app/service/DownloadService.kt
  14. 6
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  15. 4
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt
  16. 4
      app/src/main/java/io/legado/app/service/WebService.kt
  17. 4
      app/src/main/java/io/legado/app/service/help/CheckSource.kt
  18. 4
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  19. 4
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  20. 4
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  21. 4
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt
  22. 4
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleActivity.kt
  23. 4
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt
  24. 4
      app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt
  25. 8
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  26. 16
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt
  27. 2
      app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt
  28. 2
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  29. 4
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  30. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  31. 6
      app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt
  32. 8
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  33. 4
      app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt
  34. 4
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  35. 8
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt
  36. 4
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  37. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt
  38. 10
      app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt
  39. 4
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
  40. 14
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  41. 2
      app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt
  42. 4
      app/src/main/java/io/legado/app/ui/filepicker/FilePickerDialog.kt
  43. 4
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  44. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  45. 10
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt
  46. 2
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  47. 8
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt
  48. 4
      app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt
  49. 2
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt
  50. 6
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt
  51. 4
      app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt
  52. 2
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt
  53. 8
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt
  54. 2
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  55. 10
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt
  56. 2
      app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt
  57. 4
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt
  58. 18
      app/src/main/java/io/legado/app/utils/ContextExtensions.kt
  59. 4
      app/src/main/java/io/legado/app/utils/Toasts.kt

@ -6,7 +6,7 @@ import androidx.annotation.CallSuper
import androidx.lifecycle.AndroidViewModel
import io.legado.app.App
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
@ -38,12 +38,12 @@ open class BaseViewModel(application: Application) : AndroidViewModel(applicatio
cancel()
}
open fun toastOnUI(message: Int) {
context.toastOnUI(message)
open fun toastOnUi(message: Int) {
context.toastOnUi(message)
}
open fun toastOnUI(message: CharSequence?) {
context.toastOnUI(message ?: toString())
open fun toastOnUi(message: CharSequence?) {
context.toastOnUi(message ?: toString())
}
}

@ -4,7 +4,7 @@ import com.hankcs.hanlp.HanLP
import io.legado.app.App
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.ReplaceRule
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@ -40,7 +40,7 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
App.INSTANCE.toastOnUI("${item.name}替换出错")
App.INSTANCE.toastOnUi("${item.name}替换出错")
}
}
}
@ -57,7 +57,7 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
App.INSTANCE.toastOnUI("简繁转换出错")
App.INSTANCE.toastOnUi("简繁转换出错")
}
}
}

@ -5,7 +5,7 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import io.legado.app.R
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
@Suppress("unused")
object IntentHelp {
@ -19,7 +19,7 @@ object IntentHelp {
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent)
}.onFailure {
context.toastOnUI(R.string.tip_cannot_jump_setting_page)
context.toastOnUi(R.string.tip_cannot_jump_setting_page)
}
}
@ -30,7 +30,7 @@ object IntentHelp {
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent)
}.onFailure {
context.toastOnUI("无法打开设置")
context.toastOnUi("无法打开设置")
}
}

@ -6,7 +6,7 @@ import android.os.Build
import io.legado.app.App
import io.legado.app.R
import io.legado.app.ui.welcome.*
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
/**
* Created by GKF on 2018/2/27.
@ -26,7 +26,7 @@ object LauncherIconHelp {
fun changeIcon(icon: String?) {
if (icon.isNullOrEmpty()) return
if (Build.VERSION.SDK_INT < 26) {
App.INSTANCE.toastOnUI(R.string.change_icon_error)
App.INSTANCE.toastOnUi(R.string.change_icon_error)
return
}
var hasEnabled = false

@ -8,7 +8,7 @@ import io.legado.app.data.entities.RssSource
import io.legado.app.utils.EncoderUtils
import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
object SourceHelp {
@ -26,7 +26,7 @@ object SourceHelp {
rssSources.forEach { rssSource ->
if (is18Plus(rssSource.sourceUrl)) {
handler.post {
App.INSTANCE.toastOnUI("${rssSource.sourceName}是18+网址,禁止导入.")
App.INSTANCE.toastOnUi("${rssSource.sourceName}是18+网址,禁止导入.")
}
} else {
App.db.rssSourceDao.insert(rssSource)
@ -38,7 +38,7 @@ object SourceHelp {
bookSources.forEach { bookSource ->
if (is18Plus(bookSource.bookSourceUrl)) {
handler.post {
App.INSTANCE.toastOnUI("${bookSource.bookSourceName}是18+网址,禁止导入.")
App.INSTANCE.toastOnUi("${bookSource.bookSourceName}是18+网址,禁止导入.")
}
} else {
App.db.bookSourceDao.insert(bookSource)

@ -8,7 +8,7 @@ import android.view.KeyEvent
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import io.legado.app.R
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
class PermissionActivity : AppCompatActivity() {
@ -32,7 +32,7 @@ class PermissionActivity : AppCompatActivity() {
settingIntent.data = Uri.fromParts("package", packageName, null)
startActivityForResult(settingIntent, Request.TYPE_REQUEST_SETTING)
} catch (e: Exception) {
toastOnUI(R.string.tip_cannot_jump_setting_page)
toastOnUi(R.string.tip_cannot_jump_setting_page)
finish()
}

@ -79,7 +79,7 @@ object BookWebDav {
Coroutine.async {
restoreWebDav(names[index])
}.onError {
App.INSTANCE.toastOnUI("WebDavError:${it.localizedMessage}")
App.INSTANCE.toastOnUi("WebDavError:${it.localizedMessage}")
}
}
}
@ -117,7 +117,7 @@ object BookWebDav {
}
} catch (e: Exception) {
Handler(Looper.getMainLooper()).post {
App.INSTANCE.toastOnUI("WebDav\n${e.localizedMessage}")
App.INSTANCE.toastOnUi("WebDav\n${e.localizedMessage}")
}
}
}
@ -138,7 +138,7 @@ object BookWebDav {
}
} catch (e: Exception) {
Handler(Looper.getMainLooper()).post {
App.INSTANCE.toastOnUI("WebDav导出\n${e.localizedMessage}")
App.INSTANCE.toastOnUi("WebDav导出\n${e.localizedMessage}")
}
}
}

@ -8,7 +8,7 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.utils.DocumentUtils
import io.legado.app.utils.FileUtils
import io.legado.app.utils.isContentScheme
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import java.io.File
object ImportOldData {
@ -21,28 +21,28 @@ object ImportOldData {
kotlin.runCatching {
DocumentUtils.readText(context, doc.uri)?.let { json ->
val importCount = importOldBookshelf(json)
context.toastOnUI("成功导入书籍${importCount}")
context.toastOnUi("成功导入书籍${importCount}")
}
}.onFailure {
context.toastOnUI("导入书籍失败\n${it.localizedMessage}")
context.toastOnUi("导入书籍失败\n${it.localizedMessage}")
}
"myBookSource.json" ->
kotlin.runCatching {
DocumentUtils.readText(context, doc.uri)?.let { json ->
val importCount = importOldSource(json)
context.toastOnUI("成功导入书源${importCount}")
context.toastOnUi("成功导入书源${importCount}")
}
}.onFailure {
context.toastOnUI("导入源失败\n${it.localizedMessage}")
context.toastOnUi("导入源失败\n${it.localizedMessage}")
}
"myBookReplaceRule.json" ->
kotlin.runCatching {
DocumentUtils.readText(context, doc.uri)?.let { json ->
val importCount = importOldReplaceRule(json)
context.toastOnUI("成功导入替换规则${importCount}")
context.toastOnUi("成功导入替换规则${importCount}")
}
}.onFailure {
context.toastOnUI("导入替换规则失败\n${it.localizedMessage}")
context.toastOnUi("导入替换规则失败\n${it.localizedMessage}")
}
}
}
@ -54,9 +54,9 @@ object ImportOldData {
FileUtils.createFileIfNotExist(file, "myBookShelf.json")
val json = shelfFile.readText()
val importCount = importOldBookshelf(json)
context.toastOnUI("成功导入书籍${importCount}")
context.toastOnUi("成功导入书籍${importCount}")
}.onFailure {
context.toastOnUI("导入书籍失败\n${it.localizedMessage}")
context.toastOnUi("导入书籍失败\n${it.localizedMessage}")
}
kotlin.runCatching {// Book source
@ -64,9 +64,9 @@ object ImportOldData {
FileUtils.getFile(file, "myBookSource.json")
val json = sourceFile.readText()
val importCount = importOldSource(json)
context.toastOnUI("成功导入书源${importCount}")
context.toastOnUi("成功导入书源${importCount}")
}.onFailure {
context.toastOnUI("导入源失败\n${it.localizedMessage}")
context.toastOnUi("导入源失败\n${it.localizedMessage}")
}
kotlin.runCatching {// Replace rules
@ -74,12 +74,12 @@ object ImportOldData {
if (ruleFile.exists()) {
val json = ruleFile.readText()
val importCount = importOldReplaceRule(json)
context.toastOnUI("成功导入替换规则${importCount}")
context.toastOnUi("成功导入替换规则${importCount}")
} else {
context.toastOnUI("未找到替换规则")
context.toastOnUi("未找到替换规则")
}
}.onFailure {
context.toastOnUI("导入替换规则失败\n${it.localizedMessage}")
context.toastOnUi("导入替换规则失败\n${it.localizedMessage}")
}
}
}

@ -223,7 +223,7 @@ object Restore {
ReadBook.loadContent(resetPageOffset = false)
}
withContext(Main) {
App.INSTANCE.toastOnUI(R.string.restore_success)
App.INSTANCE.toastOnUi(R.string.restore_success)
if (!BuildConfig.DEBUG) {
LauncherIconHelp.changeIcon(App.INSTANCE.getPrefString(PreferKey.launcherIcon))
}

@ -31,7 +31,7 @@ import io.legado.app.receiver.MediaButtonReceiver
import io.legado.app.service.help.AudioPlay
import io.legado.app.ui.audio.AudioPlayActivity
import io.legado.app.utils.postEvent
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@ -133,7 +133,7 @@ class AudioPlayService : BaseService(),
}.onFailure {
it.printStackTrace()
launch {
toastOnUI("$url ${it.localizedMessage}")
toastOnUi("$url ${it.localizedMessage}")
stopSelf()
}
}
@ -219,7 +219,7 @@ class AudioPlayService : BaseService(),
if (!mediaPlayer.isPlaying) {
AudioPlay.status = Status.STOP
postEvent(EventBus.AUDIO_STATE, Status.STOP)
launch { toastOnUI("error: $what $extra $url") }
launch { toastOnUi("error: $what $extra $url") }
}
return true
}
@ -274,7 +274,7 @@ class AudioPlayService : BaseService(),
.onSuccess { content ->
if (content.isEmpty()) {
withContext(Main) {
toastOnUI("未获取到资源链接")
toastOnUi("未获取到资源链接")
}
} else {
contentLoadFinish(chapter, content)
@ -286,7 +286,7 @@ class AudioPlayService : BaseService(),
}
} else {
removeLoading(chapter.index)
toastOnUI("book or source is null")
toastOnUi("book or source is null")
}
}
}

@ -20,7 +20,7 @@ import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.webBook.WebBook
import io.legado.app.service.help.CacheBook
import io.legado.app.utils.postEvent
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.isActive
import java.util.concurrent.ConcurrentHashMap
@ -128,7 +128,7 @@ class CacheBookService : BaseService() {
if (downloadMap.containsKey(bookUrl)) {
notificationContent = getString(R.string.already_in_download)
upNotification()
toastOnUI(notificationContent)
toastOnUi(notificationContent)
return
}
downloadCount[bookUrl] = DownloadCount()

@ -16,7 +16,7 @@ import io.legado.app.model.webBook.WebBook
import io.legado.app.service.help.CheckSource
import io.legado.app.ui.book.source.manage.BookSourceActivity
import io.legado.app.utils.postEvent
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.asCoroutineDispatcher
import java.util.concurrent.Executors
import kotlin.math.min
@ -70,7 +70,7 @@ class CheckSourceService : BaseService() {
private fun check(ids: List<String>) {
if (allIds.isNotEmpty()) {
toastOnUI("已有书源在校验,等完成后再试")
toastOnUi("已有书源在校验,等完成后再试")
return
}
tasks.clear()

@ -21,7 +21,7 @@ import io.legado.app.help.IntentHelp
import io.legado.app.utils.RealPathUtil
import io.legado.app.utils.downloadManager
import io.legado.app.utils.msg
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import java.io.File
@ -149,7 +149,7 @@ class DownloadService : BaseService() {
try {
startActivity(intent)
} catch (e: Exception) {
toastOnUI(e.msg)
toastOnUi(e.msg)
}
}
}

@ -119,17 +119,17 @@ class HttpReadAloudService : BaseReadAloudService(),
}
} catch (e: SocketTimeoutException) {
removeSpeakCacheFile(fileName)
runOnUiThread { toastOnUI("tts接口超时,尝试重新获取") }
runOnUiThread { toastOnUi("tts接口超时,尝试重新获取") }
downloadAudio()
} catch (e: ConnectException) {
removeSpeakCacheFile(fileName)
runOnUiThread { toastOnUI("网络错误") }
runOnUiThread { toastOnUi("网络错误") }
} catch (e: IOException) {
val file = getSpeakFileAsMd5(fileName)
if (file.exists()) {
FileUtils.deleteFile(file.absolutePath)
}
runOnUiThread { toastOnUI("tts文件解析错误") }
runOnUiThread { toastOnUi("tts文件解析错误") }
} catch (e: Exception) {
removeSpeakCacheFile(fileName)
}

@ -13,7 +13,7 @@ import io.legado.app.help.MediaHelp
import io.legado.app.service.help.ReadBook
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.postEvent
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.launch
import java.util.*
@ -64,7 +64,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
}
} else {
launch {
toastOnUI(R.string.tts_init_failed)
toastOnUi(R.string.tts_init_failed)
}
}
}

@ -13,7 +13,7 @@ import io.legado.app.help.IntentHelp
import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.getPrefInt
import io.legado.app.utils.postEvent
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import io.legado.app.web.HttpServer
import io.legado.app.web.WebSocketServer
import org.jetbrains.anko.startService
@ -91,7 +91,7 @@ class WebService : BaseService() {
notificationContent = hostAddress
upNotification()
} catch (e: IOException) {
toastOnUI(e.localizedMessage ?: "")
toastOnUi(e.localizedMessage ?: "")
stopSelf()
}
} else {

@ -6,14 +6,14 @@ import io.legado.app.R
import io.legado.app.constant.IntentAction
import io.legado.app.data.entities.BookSource
import io.legado.app.service.CheckSourceService
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
object CheckSource {
var keyword = "我的"
fun start(context: Context, sources: List<BookSource>) {
if (sources.isEmpty()) {
context.toastOnUI(R.string.non_select)
context.toastOnUi(R.string.non_select)
return
}
val selectedIds: ArrayList<String> = arrayListOf()

@ -14,7 +14,7 @@ import io.legado.app.ui.book.read.page.entities.TextChapter
import io.legado.app.ui.book.read.page.entities.TextPage
import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.ui.book.read.page.provider.ImageProvider
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
@ -437,7 +437,7 @@ object ReadBook {
}
}.onError {
it.printStackTrace()
App.INSTANCE.toastOnUI("ChapterProvider ERROR:\n${it.getStackTraceString()}")
App.INSTANCE.toastOnUi("ChapterProvider ERROR:\n${it.getStackTraceString()}")
}.onSuccess {
success?.invoke()
}

@ -15,7 +15,7 @@ import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.openUrl
import io.legado.app.utils.sendMail
import io.legado.app.utils.sendToClip
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
class AboutFragment : PreferenceFragmentCompat() {
@ -105,7 +105,7 @@ class AboutFragment : PreferenceFragmentCompat() {
startActivity(intent)
return true
}.onFailure {
toastOnUI("添加失败,请手动添加")
toastOnUi("添加失败,请手动添加")
}
return false
}

@ -7,7 +7,7 @@ import io.legado.app.constant.Theme
import io.legado.app.databinding.ActivityTranslucenceBinding
import io.legado.app.ui.main.MainActivity
import io.legado.app.utils.getViewModel
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import org.jetbrains.anko.startActivity
@ -27,7 +27,7 @@ class FileAssociationActivity :
binding.rotateLoading.show()
viewModel.errorLiveData.observe(this, {
binding.rotateLoading.hide()
toastOnUI(it)
toastOnUi(it)
finish()
})
viewModel.successLiveData.observe(this, {

@ -8,7 +8,7 @@ import io.legado.app.databinding.ActivityTranslucenceBinding
import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.dialogs.alert
import io.legado.app.utils.getViewModel
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
class ImportBookSourceActivity :
@ -66,7 +66,7 @@ class ImportBookSourceActivity :
}
else -> {
binding.rotateLoading.hide()
toastOnUI(R.string.wrong_format)
toastOnUi(R.string.wrong_format)
finish()
}
}

@ -9,7 +9,7 @@ import io.legado.app.databinding.ActivityTranslucenceBinding
import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.dialogs.alert
import io.legado.app.utils.getViewModel
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
class ImportReplaceRuleActivity :
VMBaseActivity<ActivityTranslucenceBinding, ImportReplaceRuleViewModel>(
@ -66,7 +66,7 @@ class ImportReplaceRuleActivity :
}
else -> {
binding.rotateLoading.hide()
toastOnUI("格式不对")
toastOnUi("格式不对")
finish()
}
}

@ -8,7 +8,7 @@ import io.legado.app.databinding.ActivityTranslucenceBinding
import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.dialogs.alert
import io.legado.app.utils.getViewModel
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
class ImportRssSourceActivity :
VMBaseActivity<ActivityTranslucenceBinding, ImportRssSourceViewModel>(
@ -65,7 +65,7 @@ class ImportRssSourceActivity :
}
else -> {
binding.rotateLoading.hide()
toastOnUI(R.string.wrong_format)
toastOnUi(R.string.wrong_format)
finish()
}
}

@ -75,10 +75,10 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application)
}
AudioPlay.upDurChapter(book)
} else {
toastOnUI(R.string.error_load_toc)
toastOnUi(R.string.error_load_toc)
}
}?.onError {
toastOnUI(R.string.error_load_toc)
toastOnUi(R.string.error_load_toc)
}
}
}

@ -90,7 +90,7 @@ class BookInfoActivity :
)
}
} else {
toastOnUI(R.string.after_add_bookshelf)
toastOnUi(R.string.after_add_bookshelf)
}
}
R.id.menu_share_it -> {
@ -111,7 +111,7 @@ class BookInfoActivity :
}
R.id.menu_copy_url -> viewModel.bookData.value?.bookUrl?.let {
sendToClip(it)
} ?: toastOnUI(R.string.no_book)
} ?: toastOnUi(R.string.no_book)
R.id.menu_can_update -> {
if (viewModel.inBookshelf) {
viewModel.bookData.value?.let {
@ -119,7 +119,7 @@ class BookInfoActivity :
viewModel.saveBook()
}
} else {
toastOnUI(R.string.after_add_bookshelf)
toastOnUi(R.string.after_add_bookshelf)
}
}
R.id.menu_clear_cache -> viewModel.clearCache()
@ -291,7 +291,7 @@ class BookInfoActivity :
private fun openChapterList() {
if (viewModel.chapterListData.value.isNullOrEmpty()) {
toastOnUI(R.string.chapter_list_empty)
toastOnUi(R.string.chapter_list_empty)
return
}
viewModel.bookData.value?.let {

@ -65,11 +65,11 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
}
loadChapter(it, changeDruChapterIndex)
}.onError {
toastOnUI(R.string.error_get_book_info)
toastOnUi(R.string.error_get_book_info)
}
} ?: let {
chapterListData.postValue(null)
toastOnUI(R.string.error_no_source)
toastOnUi(R.string.error_no_source)
}
}
}
@ -101,19 +101,19 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
changeDruChapterIndex(it)
}
} else {
toastOnUI(R.string.chapter_list_empty)
toastOnUi(R.string.chapter_list_empty)
}
}.onError {
chapterListData.postValue(null)
toastOnUI(R.string.error_get_chapter_list)
toastOnUi(R.string.error_get_chapter_list)
}
} ?: let {
chapterListData.postValue(null)
toastOnUI(R.string.error_no_source)
toastOnUi(R.string.error_no_source)
}
}
}.onError {
toastOnUI("LoadTocError:${it.localizedMessage}")
toastOnUi("LoadTocError:${it.localizedMessage}")
}
}
@ -238,9 +238,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
execute {
BookHelp.clearCache(bookData.value!!)
}.onSuccess {
toastOnUI(R.string.clear_cache_success)
toastOnUi(R.string.clear_cache_success)
}.onError {
toastOnUI(it.stackTraceToString())
toastOnUi(it.stackTraceToString())
}
}

@ -119,7 +119,7 @@ class BookInfoEditActivity :
}.getOrNull()?.let { byteArray ->
file.writeBytes(byteArray)
coverChangeTo(file.absolutePath)
} ?: toastOnUI("获取文件出错")
} ?: toastOnUi("获取文件出错")
}
} else {
PermissionsCompat.Builder(this)

@ -251,7 +251,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
} ?: let {
val lastPath = AppConfig.importBookPath
if (lastPath.isNullOrEmpty()) {
toastOnUI(R.string.empty_msg_import_book)
toastOnUi(R.string.empty_msg_import_book)
} else {
adapter.clearItems()
val file = File(path)

@ -346,7 +346,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
) {
if (BaseReadAloudService.isPlay()) {
ReadAloud.pause(this)
toastOnUI(R.string.read_aloud_pause)
toastOnUi(R.string.read_aloud_pause)
return true
}
if (isAutoPage) {
@ -452,7 +452,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
R.id.menu_bookmark -> binding.readView.curPage.let {
val bookmark = it.createBookmark()
if (bookmark == null) {
toastOnUI(R.string.create_bookmark_error)
toastOnUi(R.string.create_bookmark_error)
} else {
showBookMark(bookmark)
}

@ -226,7 +226,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}.onStart {
ReadBook.upMsg(context.getString(R.string.source_auto_changing))
}.onError {
toastOnUI(it.msg)
toastOnUi(it.msg)
}.onFinally {
ReadBook.upMsg(null)
}

@ -119,7 +119,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
R.id.menu_share_str -> context.share(callBack.selectedText)
R.id.menu_aloud -> {
if (BaseReadAloudService.isRun) {
context.toastOnUI(R.string.alouding_disable)
context.toastOnUi(R.string.alouding_disable)
return
}
readAloud(callBack.selectedText)
@ -138,7 +138,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
context.startActivity(intent)
}.onFailure {
it.printStackTrace()
context.toastOnUI(it.localizedMessage ?: "ERROR")
context.toastOnUi(it.localizedMessage ?: "ERROR")
}
}
else -> item.intent?.let {
@ -214,7 +214,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
).intent = createProcessTextIntentForResolveInfo(resolveInfo)
}
}.onFailure {
context.toastOnUI("获取文字操作菜单出错:${it.localizedMessage}")
context.toastOnUi("获取文字操作菜单出错:${it.localizedMessage}")
}
}

@ -185,7 +185,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
postEvent(EventBus.UP_CONFIG, true)
dismiss()
} else {
toastOnUI("数量已是最少,不能删除.")
toastOnUi("数量已是最少,不能删除.")
}
}
}
@ -267,7 +267,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
}
}
}.onSuccess {
toastOnUI("导出成功, 文件名为 $exportFileName")
toastOnUi("导出成功, 文件名为 $exportFileName")
}.onError {
it.printStackTrace()
longToast("导出失败:${it.localizedMessage}")
@ -363,7 +363,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
ReadBookConfig.durConfig = config
postEvent(EventBus.UP_CONFIG, true)
}.onSuccess {
toastOnUI("导入成功")
toastOnUi("导入成功")
}.onError {
it.printStackTrace()
longToast("导入失败:${it.localizedMessage}")
@ -404,7 +404,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
ReadBookConfig.durConfig.setCurBg(2, file.absolutePath)
ReadBookConfig.upBg()
postEvent(EventBus.UP_CONFIG, false)
} ?: toastOnUI("获取文件出错")
} ?: toastOnUi("获取文件出错")
}
} else {
PermissionsCompat.Builder(this)

@ -14,7 +14,7 @@ import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.qrcode.QrCodeActivity
import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.getViewModel
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.launch
import org.jetbrains.anko.startActivityForResult
@ -83,7 +83,7 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
viewModel.startDebug(key, {
binding.rotateLoading.show()
}, {
toastOnUI("未获取到书源")
toastOnUi("未获取到书源")
})
}

@ -105,7 +105,7 @@ class BookSourceEditActivity :
R.id.menu_login -> getSource().let {
if (checkSource(it)) {
if (it.loginUrl.isNullOrEmpty()) {
toastOnUI(R.string.source_no_login)
toastOnUi(R.string.source_no_login)
} else {
startActivity<SourceLogin>(
Pair("sourceUrl", it.bookSourceUrl),
@ -357,7 +357,7 @@ class BookSourceEditActivity :
private fun checkSource(source: BookSource): Boolean {
if (source.bookSourceUrl.isBlank() || source.bookSourceName.isBlank()) {
toastOnUI(R.string.non_null_name_url)
toastOnUi(R.string.non_null_name_url)
return false
}
return true

@ -45,7 +45,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
}.onSuccess {
success?.invoke()
}.onError {
toastOnUI(it.localizedMessage)
toastOnUi(it.localizedMessage)
it.printStackTrace()
}
}
@ -58,13 +58,13 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
}
source
}.onError {
toastOnUI(it.localizedMessage)
toastOnUi(it.localizedMessage)
it.printStackTrace()
}.onSuccess {
if (it != null) {
onSuccess(it)
} else {
toastOnUI("格式不对")
toastOnUi("格式不对")
}
}
}
@ -76,7 +76,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
finally.invoke(it)
}
}.onError {
toastOnUI(it.localizedMessage ?: "Error")
toastOnUi(it.localizedMessage ?: "Error")
}
}
}

@ -411,7 +411,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
groups.map { group ->
if (group.contains("失效")) {
searchView.setQuery("失效", true)
toastOnUI("发现有失效书源,已为您自动筛选!")
toastOnUi("发现有失效书源,已为您自动筛选!")
}
}
}
@ -473,7 +473,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
startActivity<ImportBookSourceActivity>("dataKey" to dataKey)
}
} catch (e: Exception) {
toastOnUI("readTextError:${e.localizedMessage}")
toastOnUi("readTextError:${e.localizedMessage}")
}
}
}

@ -181,7 +181,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
}.onSuccess {
success.invoke(it)
}.onError {
toastOnUI(it.msg)
toastOnUi(it.msg)
}
}

@ -20,7 +20,7 @@ import io.legado.app.ui.filepicker.FilePicker
import io.legado.app.utils.getPrefString
import io.legado.app.utils.isContentScheme
import io.legado.app.utils.longToast
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers.Main
object BackupRestoreUi {
@ -41,7 +41,7 @@ object BackupRestoreUi {
Coroutine.async {
Backup.backup(fragment.requireContext(), backupPath)
}.onSuccess {
fragment.toastOnUI(R.string.backup_success)
fragment.toastOnUi(R.string.backup_success)
}
} else {
selectBackupFolder(fragment, backupSelectRequestCode)
@ -64,7 +64,7 @@ object BackupRestoreUi {
AppConfig.backupPath = path
Backup.backup(fragment.requireContext(), path)
}.onSuccess {
fragment.toastOnUI(R.string.backup_success)
fragment.toastOnUi(R.string.backup_success)
}
}
.request()
@ -134,7 +134,7 @@ object BackupRestoreUi {
Coroutine.async {
Backup.backup(App.INSTANCE, uri.toString())
}.onSuccess {
App.INSTANCE.toastOnUI(R.string.backup_success)
App.INSTANCE.toastOnUi(R.string.backup_success)
}
} else {
uri.path?.let { path ->
@ -142,7 +142,7 @@ object BackupRestoreUi {
Coroutine.async {
Backup.backup(App.INSTANCE, path)
}.onSuccess {
App.INSTANCE.toastOnUI(R.string.backup_success)
App.INSTANCE.toastOnUi(R.string.backup_success)
}
}
}

@ -177,7 +177,7 @@ class OtherConfigFragment : BasePreferenceFragment(),
okButton {
BookHelp.clearCache()
FileUtils.deleteFile(requireActivity().cacheDir.absolutePath)
toastOnUI(R.string.clear_cache_success)
toastOnUi(R.string.clear_cache_success)
}
noButton()
}.show()
@ -221,7 +221,7 @@ class OtherConfigFragment : BasePreferenceFragment(),
file.writeBytes(byteArray)
putPrefString(PreferKey.defaultCover, file.absolutePath)
CoverImageView.upDefaultCover()
} ?: toastOnUI("获取文件出错")
} ?: toastOnUi("获取文件出错")
}
} else {
PermissionsCompat.Builder(this)

@ -60,7 +60,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
findPreference<ColorPreference>(PreferKey.cBackground)?.let {
it.onSaveColor = { color ->
if (!ColorUtils.isColorLight(color)) {
toastOnUI(R.string.day_background_too_dark)
toastOnUi(R.string.day_background_too_dark)
true
} else {
false
@ -70,7 +70,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
findPreference<ColorPreference>(PreferKey.cNBackground)?.let {
it.onSaveColor = { color ->
if (ColorUtils.isColorLight(color)) {
toastOnUI(R.string.night_background_too_light)
toastOnUi(R.string.night_background_too_light)
true
} else {
false
@ -84,11 +84,11 @@ class ThemeConfigFragment : BasePreferenceFragment(),
val textColor = getCompatColor(R.color.primaryText)
when {
ColorUtils.getColorDifference(color, background) <= 60 -> {
toastOnUI(R.string.accent_background_diff)
toastOnUi(R.string.accent_background_diff)
true
}
ColorUtils.getColorDifference(color, textColor) <= 60 -> {
toastOnUI(R.string.accent_text_diff)
toastOnUi(R.string.accent_text_diff)
true
}
else -> false
@ -102,11 +102,11 @@ class ThemeConfigFragment : BasePreferenceFragment(),
val textColor = getCompatColor(R.color.primaryText)
when {
ColorUtils.getColorDifference(color, background) <= 60 -> {
toastOnUI(R.string.accent_background_diff)
toastOnUi(R.string.accent_background_diff)
true
}
ColorUtils.getColorDifference(color, textColor) <= 60 -> {
toastOnUI(R.string.accent_text_diff)
toastOnUi(R.string.accent_text_diff)
true
}
else -> false
@ -277,7 +277,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
putPrefString(preferenceKey, file.absolutePath)
upPreferenceSummary(preferenceKey, file.absolutePath)
success()
} ?: toastOnUI("获取文件出错")
} ?: toastOnUi("获取文件出错")
}
} else {
PermissionsCompat.Builder(this)

@ -72,7 +72,7 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
if (ThemeConfig.addConfig(it)) {
initData()
} else {
toastOnUI("格式不对,添加失败")
toastOnUi("格式不对,添加失败")
}
}
}

@ -170,14 +170,14 @@ class FilePickerDialog : DialogFragment(),
} else {
fileItem?.path?.let { path ->
if (mode == DIRECTORY) {
toastOnUI("这是文件夹选择,不能选择文件,点击右上角的确定选择文件夹")
toastOnUi("这是文件夹选择,不能选择文件,点击右上角的确定选择文件夹")
} else if (allowExtensions.isNullOrEmpty() ||
allowExtensions?.contains(FileUtils.getExtension(path)) == true
) {
setData(path)
dismiss()
} else {
toastOnUI("不能打开此文件")
toastOnUi("不能打开此文件")
}
}
}

@ -32,7 +32,7 @@ import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.getViewModel
import io.legado.app.utils.hideSoftInput
import io.legado.app.utils.observeEvent
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
@ -144,7 +144,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
return true
}
if (System.currentTimeMillis() - exitTime > 2000) {
toastOnUI(R.string.double_click_exit)
toastOnUi(R.string.double_click_exit)
exitTime = System.currentTimeMillis()
} else {
if (BaseReadAloudService.pause) {

@ -205,7 +205,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
override fun onTabReselected(tab: TabLayout.Tab) {
fragmentMap[selectedGroup.groupId]?.let {
toastOnUI("${selectedGroup.groupName}(${it.getBooksCount()})")
toastOnUi("${selectedGroup.groupName}(${it.getBooksCount()})")
}
}

@ -57,12 +57,12 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
}
}.onSuccess {
if (successCount > 0) {
toastOnUI(R.string.success)
toastOnUi(R.string.success)
} else {
toastOnUI("ERROR")
toastOnUi("ERROR")
}
}.onError {
toastOnUI(it.localizedMessage ?: "ERROR")
toastOnUi(it.localizedMessage ?: "ERROR")
}
}
@ -98,7 +98,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
}
}
}.onError {
toastOnUI(it.localizedMessage ?: "ERROR")
toastOnUi(it.localizedMessage ?: "ERROR")
}
}
@ -121,7 +121,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
}
}
}.onFinally {
toastOnUI(R.string.success)
toastOnUi(R.string.success)
}
}

@ -269,7 +269,7 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
startActivity<ImportReplaceRuleActivity>("dataKey" to dataKey)
}
}.onFailure {
toastOnUI("readTextError:${it.localizedMessage}")
toastOnUi("readTextError:${it.localizedMessage}")
}
}
}

@ -79,9 +79,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application
FileUtils.createFileIfNotExist(file, "exportReplaceRule.json")
.writeText(json)
}.onSuccess {
context.toastOnUI("成功导出至\n${file.absolutePath}")
context.toastOnUi("成功导出至\n${file.absolutePath}")
}.onError {
context.toastOnUI("导出失败\n${it.localizedMessage}")
context.toastOnUi("导出失败\n${it.localizedMessage}")
}
}
@ -92,9 +92,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application
doc.createFile("", "exportReplaceRule.json")
?.writeText(context, json)
}.onSuccess {
context.toastOnUI("成功导出至\n${doc.uri.path}")
context.toastOnUi("成功导出至\n${doc.uri.path}")
}.onError {
context.toastOnUI("导出失败\n${it.localizedMessage}")
context.toastOnUi("导出失败\n${it.localizedMessage}")
}
}

@ -20,7 +20,7 @@ import io.legado.app.ui.widget.KeyboardToolPop
import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.getViewModel
import io.legado.app.utils.postEvent
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import org.jetbrains.anko.displayMetrics
import org.jetbrains.anko.selector
import kotlin.math.abs
@ -82,7 +82,7 @@ class ReplaceEditActivity :
R.id.menu_save -> {
val rule = getReplaceRule()
if (!rule.isValid()) {
toastOnUI(R.string.replace_rule_invalid)
toastOnUi(R.string.replace_rule_invalid)
} else {
viewModel.save(rule) {
postEvent(EventBus.REPLACE_RULE_SAVE, "")

@ -51,7 +51,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
}.onError {
loadFinally.postValue(false)
it.printStackTrace()
toastOnUI(it.localizedMessage)
toastOnUi(it.localizedMessage)
}
}

@ -137,9 +137,9 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
}
} ?: throw Throwable("NULL")
}.onError {
toastOnUI("保存图片失败:${it.localizedMessage}")
toastOnUi("保存图片失败:${it.localizedMessage}")
}.onSuccess {
toastOnUI("保存成功")
toastOnUi("保存成功")
}
}
@ -186,7 +186,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
play()
} else {
launch {
toastOnUI(R.string.tts_init_failed)
toastOnUi(R.string.tts_init_failed)
}
}
}

@ -9,7 +9,7 @@ import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.getViewModel
import io.legado.app.utils.gone
import io.legado.app.utils.toastOnUI
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.launch
@ -56,7 +56,7 @@ class RssSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, RssSou
viewModel.startDebug({
binding.rotateLoading.show()
}, {
toastOnUI("未获取到源")
toastOnUi("未获取到源")
})
}
}

@ -181,7 +181,7 @@ class RssSourceEditActivity :
private fun checkSource(source: RssSource): Boolean {
if (source.sourceName.isBlank() || source.sourceName.isBlank()) {
toastOnUI("名称或url不能为空")
toastOnUi("名称或url不能为空")
return false
}
return true

@ -40,7 +40,7 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
}.onSuccess {
success()
}.onError {
toastOnUI(it.localizedMessage)
toastOnUi(it.localizedMessage)
it.printStackTrace()
}
}
@ -53,12 +53,12 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
}
source
}.onError {
toastOnUI(it.localizedMessage)
toastOnUi(it.localizedMessage)
}.onSuccess {
if (it != null) {
onSuccess(it)
} else {
toastOnUI("格式不对")
toastOnUi("格式不对")
}
}
}
@ -70,7 +70,7 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
finally.invoke(it)
}
}.onError {
toastOnUI(it.msg)
toastOnUi(it.msg)
}
}

@ -270,7 +270,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
startActivity<ImportRssSourceActivity>("dataKey" to dataKey)
}
}.onFailure {
toastOnUI("readTextError:${it.localizedMessage}")
toastOnUi("readTextError:${it.localizedMessage}")
}
}
}

@ -85,9 +85,9 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
FileUtils.createFileIfNotExist(file, "exportRssSource.json")
.writeText(json)
}.onSuccess {
context.toastOnUI("成功导出至\n${file.absolutePath}")
context.toastOnUi("成功导出至\n${file.absolutePath}")
}.onError {
context.toastOnUI("导出失败\n${it.localizedMessage}")
context.toastOnUi("导出失败\n${it.localizedMessage}")
}
}
@ -98,9 +98,9 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
doc.createFile("", "exportRssSource.json")
?.writeText(context, json)
}.onSuccess {
context.toastOnUI("成功导出至\n${doc.uri.path}")
context.toastOnUi("成功导出至\n${doc.uri.path}")
}.onError {
context.toastOnUI("导出失败\n${it.localizedMessage}")
context.toastOnUi("导出失败\n${it.localizedMessage}")
}
}
@ -122,7 +122,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
}.onSuccess {
success.invoke(it)
}.onError {
toastOnUI(it.msg)
toastOnUi(it.msg)
}
}

@ -42,7 +42,7 @@ class FontAdapter(context: Context, val callBack: CallBack) :
tvFont.typeface = typeface
}.onFailure {
it.printStackTrace()
context.toastOnUI("Read ${item.name} Error: ${it.localizedMessage}")
context.toastOnUi("Read ${item.name} Error: ${it.localizedMessage}")
}
tvFont.text = item.name
root.setOnClickListener { callBack.onClick(item) }

@ -157,7 +157,7 @@ class FontSelectDialog : BaseDialogFragment(),
}.onSuccess {
adapter?.setItems(it)
}.onError {
toastOnUI("getFontFiles:${it.localizedMessage}")
toastOnUi("getFontFiles:${it.localizedMessage}")
}
}
@ -192,7 +192,7 @@ class FontSelectDialog : BaseDialogFragment(),
}.onSuccess {
adapter?.setItems(it)
}.onError {
toastOnUI("getFontFiles:${it.localizedMessage}")
toastOnUi("getFontFiles:${it.localizedMessage}")
}
}

@ -35,25 +35,25 @@ val Context.downloadManager
val Context.connectivityManager
get() = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
fun Context.toastOnUI(message: Int) {
fun Context.toastOnUi(message: Int) {
runOnUiThread {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
}
fun Context.toastOnUI(message: CharSequence?) {
fun Context.toastOnUi(message: CharSequence?) {
runOnUiThread {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
}
fun Context.longToastOnUI(message: Int) {
fun Context.longToastOnUi(message: Int) {
runOnUiThread {
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
}
}
fun Context.longToastOnUI(message: CharSequence?) {
fun Context.longToastOnUi(message: CharSequence?) {
runOnUiThread {
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
}
@ -139,7 +139,7 @@ val Context.navigationBarHeight: Int
fun Context.shareWithQr(title: String, text: String) {
val bitmap = QRCodeUtils.createQRCode(text)
if (bitmap == null) {
toastOnUI(R.string.text_too_long_qr_error)
toastOnUi(R.string.text_too_long_qr_error)
} else {
try {
val file = File(externalCacheDir, "qr.png")
@ -159,7 +159,7 @@ fun Context.shareWithQr(title: String, text: String) {
intent.type = "image/png"
startActivity(Intent.createChooser(intent, title))
} catch (e: Exception) {
toastOnUI(e.localizedMessage ?: "ERROR")
toastOnUi(e.localizedMessage ?: "ERROR")
}
}
}
@ -191,7 +191,7 @@ fun Context.sendMail(mail: String) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
} catch (e: Exception) {
toastOnUI(e.localizedMessage ?: "Error")
toastOnUi(e.localizedMessage ?: "Error")
}
}
@ -231,13 +231,13 @@ fun Context.openUrl(uri: Uri) {
try {
startActivity(intent)
} catch (e: Exception) {
toastOnUI(e.localizedMessage ?: "open url error")
toastOnUi(e.localizedMessage ?: "open url error")
}
} else {
try {
startActivity(Intent.createChooser(intent, "请选择浏览器"))
} catch (e: Exception) {
toastOnUI(e.localizedMessage ?: "open url error")
toastOnUi(e.localizedMessage ?: "open url error")
}
}
}

@ -12,14 +12,14 @@ import org.jetbrains.anko.longToast
*
* @param message the message text resource.
*/
fun Fragment.toastOnUI(message: Int) = requireActivity().toastOnUI(message)
fun Fragment.toastOnUi(message: Int) = requireActivity().toastOnUi(message)
/**
* Display the simple Toast message with the [Toast.LENGTH_SHORT] duration.
*
* @param message the message text.
*/
fun Fragment.toastOnUI(message: CharSequence) = requireActivity().toastOnUI(message)
fun Fragment.toastOnUi(message: CharSequence) = requireActivity().toastOnUi(message)
/**
* Display the simple Toast message with the [Toast.LENGTH_LONG] duration.

Loading…
Cancel
Save