delete anko:anko-sdk27-coroutines

pull/840/head
gedoor 4 years ago
parent ca6b4ced1d
commit a03eba41d7
  1. 13
      app/build.gradle
  2. 2
      app/src/main/java/io/legado/app/App.kt
  3. 29
      app/src/main/java/io/legado/app/base/BaseViewModel.kt
  4. 6
      app/src/main/java/io/legado/app/help/ContentProcessor.kt
  5. 6
      app/src/main/java/io/legado/app/help/IntentHelp.kt
  6. 4
      app/src/main/java/io/legado/app/help/LauncherIconHelp.kt
  7. 6
      app/src/main/java/io/legado/app/help/SourceHelp.kt
  8. 4
      app/src/main/java/io/legado/app/help/permission/PermissionActivity.kt
  9. 7
      app/src/main/java/io/legado/app/help/storage/BookWebDav.kt
  10. 28
      app/src/main/java/io/legado/app/help/storage/ImportOldData.kt
  11. 3
      app/src/main/java/io/legado/app/help/storage/Restore.kt
  12. 4
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  13. 10
      app/src/main/java/io/legado/app/service/AudioPlayService.kt
  14. 4
      app/src/main/java/io/legado/app/service/CacheBookService.kt
  15. 4
      app/src/main/java/io/legado/app/service/CheckSourceService.kt
  16. 6
      app/src/main/java/io/legado/app/service/DownloadService.kt
  17. 12
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  18. 4
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt
  19. 7
      app/src/main/java/io/legado/app/service/WebService.kt
  20. 4
      app/src/main/java/io/legado/app/service/help/CheckSource.kt
  21. 4
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  22. 4
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  23. 5
      app/src/main/java/io/legado/app/ui/about/ReadRecordActivity.kt
  24. 4
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  25. 4
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt
  26. 6
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  27. 4
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleActivity.kt
  28. 4
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt
  29. 5
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  30. 19
      app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt
  31. 4
      app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt
  32. 10
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt
  33. 6
      app/src/main/java/io/legado/app/ui/book/cache/CacheAdapter.kt
  34. 4
      app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt
  35. 7
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt
  36. 6
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt
  37. 4
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowAdapter.kt
  38. 6
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  39. 8
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  40. 28
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  41. 16
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt
  42. 8
      app/src/main/java/io/legado/app/ui/book/info/ChapterListAdapter.kt
  43. 10
      app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt
  44. 6
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  45. 4
      app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt
  46. 5
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  47. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  48. 39
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  49. 17
      app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt
  50. 10
      app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt
  51. 4
      app/src/main/java/io/legado/app/ui/book/read/config/BgAdapter.kt
  52. 26
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  53. 4
      app/src/main/java/io/legado/app/ui/book/read/config/ChineseConverter.kt
  54. 20
      app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt
  55. 4
      app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt
  56. 22
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt
  57. 21
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  58. 14
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt
  59. 4
      app/src/main/java/io/legado/app/ui/book/read/config/TextFontWeightConverter.kt
  60. 23
      app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt
  61. 12
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  62. 7
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  63. 4
      app/src/main/java/io/legado/app/ui/book/search/BookAdapter.kt
  64. 8
      app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt
  65. 6
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  66. 4
      app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt
  67. 11
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt
  68. 4
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentAdapter.kt
  69. 4
      app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt
  70. 4
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  71. 8
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt
  72. 5
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  73. 6
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt
  74. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt
  75. 6
      app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt
  76. 7
      app/src/main/java/io/legado/app/ui/book/toc/BookmarkAdapter.kt
  77. 4
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt
  78. 8
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt
  79. 11
      app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt
  80. 4
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
  81. 14
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  82. 10
      app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt
  83. 4
      app/src/main/java/io/legado/app/ui/filepicker/FilePickerDialog.kt
  84. 4
      app/src/main/java/io/legado/app/ui/filepicker/adapter/FileAdapter.kt
  85. 4
      app/src/main/java/io/legado/app/ui/filepicker/adapter/PathAdapter.kt
  86. 4
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  87. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  88. 10
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt
  89. 7
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt
  90. 7
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt
  91. 9
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  92. 7
      app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt
  93. 4
      app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt
  94. 6
      app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt
  95. 3
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  96. 8
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt
  97. 14
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt
  98. 7
      app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt
  99. 10
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt
  100. 10
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter1.kt
  101. Some files were not shown because too many files have changed in this diff Show More

@ -125,17 +125,21 @@ dependencies {
implementation 'com.google.firebase:firebase-crashlytics-ktx:17.3.0'
//androidX
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.media:media:1.2.1'
implementation 'androidx.core:core-ktx:1.3.2'
implementation "androidx.activity:activity-ktx:1.1.0"
implementation "androidx.fragment:fragment-ktx:1.2.5"
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'androidx.media:media:1.2.1'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.google.android:flexbox:1.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation "org.jetbrains.anko:anko-sdk27:0.10.8"
//lifecycle
def lifecycle_version = '2.2.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
@ -150,11 +154,6 @@ dependencies {
//paging
implementation 'androidx.paging:paging-runtime-ktx:2.1.2'
//anko
def anko_version = '0.10.8'
implementation "org.jetbrains.anko:anko-sdk27:$anko_version"
implementation "org.jetbrains.anko:anko-sdk27-coroutines:$anko_version"
//liveEventBus
implementation 'com.jeremyliao:live-event-bus-x:1.5.7'

@ -18,8 +18,8 @@ import io.legado.app.data.AppDatabase
import io.legado.app.help.*
import io.legado.app.help.http.HttpHelper
import io.legado.app.utils.LanguageUtils
import io.legado.app.utils.defaultSharedPreferences
import io.legado.app.utils.postEvent
import org.jetbrains.anko.defaultSharedPreferences
import rxhttp.wrapper.param.RxHttp
@Suppress("DEPRECATION")

@ -6,15 +6,13 @@ 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 kotlinx.coroutines.*
import org.jetbrains.anko.AnkoLogger
import org.jetbrains.anko.toast
import kotlin.coroutines.CoroutineContext
@Suppress("unused")
open class BaseViewModel(application: Application) : AndroidViewModel(application),
CoroutineScope by MainScope(),
AnkoLogger {
CoroutineScope by MainScope() {
val context: Context by lazy { this.getApplication<App>() }
@ -40,27 +38,12 @@ open class BaseViewModel(application: Application) : AndroidViewModel(applicatio
cancel()
}
open fun toast(message: Int) {
launch {
context.toast(message)
}
open fun toastOnUI(message: Int) {
context.toastOnUI(message)
}
open fun toast(message: CharSequence?) {
launch {
context.toast(message ?: toString())
}
open fun toastOnUI(message: CharSequence?) {
context.toastOnUI(message ?: toString())
}
open fun longToast(message: Int) {
launch {
context.toast(message)
}
}
open fun longToast(message: CharSequence?) {
launch {
context.toast(message ?: toString())
}
}
}

@ -4,9 +4,9 @@ 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 kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.jetbrains.anko.toast
class ContentProcessor(private val bookName: String, private val bookOrigin: String) {
@ -40,7 +40,7 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
App.INSTANCE.toast("${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.toast("简繁转换出错")
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 org.jetbrains.anko.toast
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.toast(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.toast("无法打开设置")
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 org.jetbrains.anko.toast
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.toast(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 org.jetbrains.anko.toast
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.toast("${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.toast("${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 org.jetbrains.anko.toast
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) {
toast(R.string.tip_cannot_jump_setting_page)
toastOnUI(R.string.tip_cannot_jump_setting_page)
finish()
}

@ -16,7 +16,6 @@ import io.legado.app.utils.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.withContext
import org.jetbrains.anko.toast
import java.io.File
import java.text.SimpleDateFormat
import java.util.*
@ -80,7 +79,7 @@ object BookWebDav {
Coroutine.async {
restoreWebDav(names[index])
}.onError {
App.INSTANCE.toast("WebDavError:${it.localizedMessage}")
App.INSTANCE.toastOnUI("WebDavError:${it.localizedMessage}")
}
}
}
@ -118,7 +117,7 @@ object BookWebDav {
}
} catch (e: Exception) {
Handler(Looper.getMainLooper()).post {
App.INSTANCE.toast("WebDav\n${e.localizedMessage}")
App.INSTANCE.toastOnUI("WebDav\n${e.localizedMessage}")
}
}
}
@ -139,7 +138,7 @@ object BookWebDav {
}
} catch (e: Exception) {
Handler(Looper.getMainLooper()).post {
App.INSTANCE.toast("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 org.jetbrains.anko.toast
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.toast("成功导入书籍${importCount}")
context.toastOnUI("成功导入书籍${importCount}")
}
}.onFailure {
context.toast("导入书籍失败\n${it.localizedMessage}")
context.toastOnUI("导入书籍失败\n${it.localizedMessage}")
}
"myBookSource.json" ->
kotlin.runCatching {
DocumentUtils.readText(context, doc.uri)?.let { json ->
val importCount = importOldSource(json)
context.toast("成功导入书源${importCount}")
context.toastOnUI("成功导入书源${importCount}")
}
}.onFailure {
context.toast("导入源失败\n${it.localizedMessage}")
context.toastOnUI("导入源失败\n${it.localizedMessage}")
}
"myBookReplaceRule.json" ->
kotlin.runCatching {
DocumentUtils.readText(context, doc.uri)?.let { json ->
val importCount = importOldReplaceRule(json)
context.toast("成功导入替换规则${importCount}")
context.toastOnUI("成功导入替换规则${importCount}")
}
}.onFailure {
context.toast("导入替换规则失败\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.toast("成功导入书籍${importCount}")
context.toastOnUI("成功导入书籍${importCount}")
}.onFailure {
context.toast("导入书籍失败\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.toast("成功导入书源${importCount}")
context.toastOnUI("成功导入书源${importCount}")
}.onFailure {
context.toast("导入源失败\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.toast("成功导入替换规则${importCount}")
context.toastOnUI("成功导入替换规则${importCount}")
} else {
context.toast("未找到替换规则")
context.toastOnUI("未找到替换规则")
}
}.onFailure {
context.toast("导入替换规则失败\n${it.localizedMessage}")
context.toastOnUI("导入替换规则失败\n${it.localizedMessage}")
}
}
}

@ -24,7 +24,6 @@ import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.withContext
import org.jetbrains.anko.defaultSharedPreferences
import org.jetbrains.anko.toast
import java.io.File
object Restore {
@ -224,7 +223,7 @@ object Restore {
ReadBook.loadContent(resetPageOffset = false)
}
withContext(Main) {
App.INSTANCE.toast(R.string.restore_success)
App.INSTANCE.toastOnUI(R.string.restore_success)
if (!BuildConfig.DEBUG) {
LauncherIconHelp.changeIcon(App.INSTANCE.getPrefString(PreferKey.launcherIcon))
}

@ -24,8 +24,6 @@ import io.legado.app.help.AppConfig
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
import io.legado.app.utils.getCompatColor
import org.jetbrains.anko.backgroundColor
/**
* @author Karim Abou Zeid (kabouzeid)
@ -272,7 +270,7 @@ object ATH {
fun applyBackgroundTint(view: View?) {
view?.apply {
if (background == null) {
backgroundColor = context.backgroundColor
setBackgroundColor(context.backgroundColor)
} else {
setBackgroundTint(this, context.backgroundColor)
}

@ -31,10 +31,10 @@ 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 kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.toast
class AudioPlayService : BaseService(),
@ -133,7 +133,7 @@ class AudioPlayService : BaseService(),
}.onFailure {
it.printStackTrace()
launch {
toast("$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 { toast("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) {
toast("未获取到资源链接")
toastOnUI("未获取到资源链接")
}
} else {
contentLoadFinish(chapter, content)
@ -286,7 +286,7 @@ class AudioPlayService : BaseService(),
}
} else {
removeLoading(chapter.index)
toast("book or source is null")
toastOnUI("book or source is null")
}
}
}

@ -20,9 +20,9 @@ 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 kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.isActive
import org.jetbrains.anko.toast
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArraySet
import java.util.concurrent.Executors
@ -128,7 +128,7 @@ class CacheBookService : BaseService() {
if (downloadMap.containsKey(bookUrl)) {
notificationContent = getString(R.string.already_in_download)
upNotification()
toast(notificationContent)
toastOnUI(notificationContent)
return
}
downloadCount[bookUrl] = DownloadCount()

@ -16,8 +16,8 @@ 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 kotlinx.coroutines.asCoroutineDispatcher
import org.jetbrains.anko.toast
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()) {
toast("已有书源在校验,等完成后再试")
toastOnUI("已有书源在校验,等完成后再试")
return
}
tasks.clear()

@ -19,9 +19,9 @@ import io.legado.app.constant.AppConst
import io.legado.app.constant.IntentAction
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 org.jetbrains.anko.downloadManager
import org.jetbrains.anko.toast
import io.legado.app.utils.toastOnUI
import java.io.File
@ -149,7 +149,7 @@ class DownloadService : BaseService() {
try {
startActivity(intent)
} catch (e: Exception) {
toast(e.msg)
toastOnUI(e.msg)
}
}
}

@ -10,15 +10,11 @@ import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.service.help.ReadAloud
import io.legado.app.service.help.ReadBook
import io.legado.app.utils.FileUtils
import io.legado.app.utils.LogUtils
import io.legado.app.utils.MD5Utils
import io.legado.app.utils.postEvent
import io.legado.app.utils.*
import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.isActive
import org.jetbrains.anko.collections.forEachWithIndex
import org.jetbrains.anko.runOnUiThread
import org.jetbrains.anko.toast
import java.io.File
import java.io.FileDescriptor
import java.io.FileInputStream
@ -123,17 +119,17 @@ class HttpReadAloudService : BaseReadAloudService(),
}
} catch (e: SocketTimeoutException) {
removeSpeakCacheFile(fileName)
runOnUiThread { toast("tts接口超时,尝试重新获取") }
runOnUiThread { toastOnUI("tts接口超时,尝试重新获取") }
downloadAudio()
} catch (e: ConnectException) {
removeSpeakCacheFile(fileName)
runOnUiThread { toast("网络错误") }
runOnUiThread { toastOnUI("网络错误") }
} catch (e: IOException) {
val file = getSpeakFileAsMd5(fileName)
if (file.exists()) {
FileUtils.deleteFile(file.absolutePath)
}
runOnUiThread { toast("tts文件解析错误") }
runOnUiThread { toastOnUI("tts文件解析错误") }
} catch (e: Exception) {
removeSpeakCacheFile(fileName)
}

@ -13,8 +13,8 @@ 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 kotlinx.coroutines.launch
import org.jetbrains.anko.toast
import java.util.*
class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener {
@ -64,7 +64,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
}
} else {
launch {
toast(R.string.tts_init_failed)
toastOnUI(R.string.tts_init_failed)
}
}
}

@ -13,11 +13,10 @@ 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.web.HttpServer
import io.legado.app.web.WebSocketServer
import kotlinx.coroutines.launch
import org.jetbrains.anko.startService
import org.jetbrains.anko.toast
import java.io.IOException
class WebService : BaseService() {
@ -92,11 +91,9 @@ class WebService : BaseService() {
notificationContent = hostAddress
upNotification()
} catch (e: IOException) {
launch {
toast(e.localizedMessage ?: "")
toastOnUI(e.localizedMessage ?: "")
stopSelf()
}
}
} else {
stopSelf()
}

@ -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 org.jetbrains.anko.toast
import io.legado.app.utils.toastOnUI
object CheckSource {
var keyword = "我的"
fun start(context: Context, sources: List<BookSource>) {
if (sources.isEmpty()) {
context.toast(R.string.non_select)
context.toastOnUI(R.string.non_select)
return
}
val selectedIds: ArrayList<String> = arrayListOf()

@ -14,12 +14,12 @@ 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 kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.jetbrains.anko.getStackTraceString
import org.jetbrains.anko.toast
@Suppress("MemberVisibilityCanBePrivate")
@ -437,7 +437,7 @@ object ReadBook {
}
}.onError {
it.printStackTrace()
App.INSTANCE.toast("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.toast
import io.legado.app.utils.toastOnUI
class AboutFragment : PreferenceFragmentCompat() {
@ -105,7 +105,7 @@ class AboutFragment : PreferenceFragmentCompat() {
startActivity(intent)
return true
}.onFailure {
toast("添加失败,请手动添加")
toastOnUI("添加失败,请手动添加")
}
return false
}

@ -19,7 +19,6 @@ import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.coroutines.onClick
import java.util.*
class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
@ -59,7 +58,7 @@ class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
readRecord.tvBookName.setText(R.string.all_read_time)
adapter = RecordAdapter(this@ReadRecordActivity)
recyclerView.adapter = adapter
readRecord.tvRemove.onClick {
readRecord.tvRemove.setOnClickListener {
alert(R.string.delete, R.string.sure_del) {
okButton {
App.db.readRecordDao.clear()
@ -112,7 +111,7 @@ class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
override fun registerListener(holder: ItemViewHolder, binding: ItemReadRecordBinding) {
binding.apply {
tvRemove.onClick {
tvRemove.setOnClickListener {
getItem(holder.layoutPosition)?.let { item ->
sureDelAlert(item)
}

@ -7,8 +7,8 @@ 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 org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
class FileAssociationActivity :
@ -27,7 +27,7 @@ class FileAssociationActivity :
binding.rotateLoading.show()
viewModel.errorLiveData.observe(this, {
binding.rotateLoading.hide()
toast(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 org.jetbrains.anko.toast
import io.legado.app.utils.toastOnUI
class ImportBookSourceActivity :
@ -66,7 +66,7 @@ class ImportBookSourceActivity :
}
else -> {
binding.rotateLoading.hide()
toast(R.string.wrong_format)
toastOnUI(R.string.wrong_format)
finish()
}
}

@ -25,7 +25,7 @@ import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
/**
* 导入书源弹出窗口
@ -62,11 +62,11 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
binding.recyclerView.adapter = adapter
adapter.setItems(viewModel.allSources)
binding.tvCancel.visible()
binding.tvCancel.onClick {
binding.tvCancel.setOnClickListener {
dismiss()
}
binding.tvOk.visible()
binding.tvOk.onClick {
binding.tvOk.setOnClickListener {
viewModel.importSelect {
dismiss()
}

@ -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 org.jetbrains.anko.toast
import io.legado.app.utils.toastOnUI
class ImportReplaceRuleActivity :
VMBaseActivity<ActivityTranslucenceBinding, ImportReplaceRuleViewModel>(
@ -66,7 +66,7 @@ class ImportReplaceRuleActivity :
}
else -> {
binding.rotateLoading.hide()
toast("格式不对")
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 org.jetbrains.anko.toast
import io.legado.app.utils.toastOnUI
class ImportRssSourceActivity :
VMBaseActivity<ActivityTranslucenceBinding, ImportRssSourceViewModel>(
@ -65,7 +65,7 @@ class ImportRssSourceActivity :
}
else -> {
binding.rotateLoading.hide()
toast(R.string.wrong_format)
toastOnUI(R.string.wrong_format)
finish()
}
}

@ -25,7 +25,6 @@ import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
/**
* 导入rss源弹出窗口
@ -62,11 +61,11 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
binding.recyclerView.adapter = adapter
adapter.setItems(viewModel.allSources)
binding.tvCancel.visible()
binding.tvCancel.onClick {
binding.tvCancel.setOnClickListener {
dismiss()
}
binding.tvOk.visible()
binding.tvOk.onClick {
binding.tvOk.setOnClickListener {
viewModel.importSelect {
dismiss()
}

@ -28,8 +28,6 @@ import io.legado.app.ui.book.toc.ChapterListActivity
import io.legado.app.ui.widget.image.CoverImageView
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
import io.legado.app.utils.*
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
import org.jetbrains.anko.startActivityForResult
import java.util.*
@ -80,16 +78,17 @@ class AudioPlayActivity :
}
private fun initView() {
binding.fabPlayStop.onClick {
binding.fabPlayStop.setOnClickListener {
playButton()
}
binding.fabPlayStop.onLongClick(returnValue = true) {
binding.fabPlayStop.setOnLongClickListener {
AudioPlay.stop(this@AudioPlayActivity)
true
}
binding.ivSkipNext.onClick {
binding.ivSkipNext.setOnClickListener {
AudioPlay.next(this@AudioPlayActivity)
}
binding.ivSkipPrevious.onClick {
binding.ivSkipPrevious.setOnClickListener {
AudioPlay.prev(this@AudioPlayActivity)
}
binding.playerProgress.setOnSeekBarChangeListener(object : SeekBarChangeListener {
@ -106,7 +105,7 @@ class AudioPlayActivity :
AudioPlay.adjustProgress(this@AudioPlayActivity, seekBar.progress)
}
})
binding.ivChapter.onClick {
binding.ivChapter.setOnClickListener {
AudioPlay.book?.let {
startActivityForResult<ChapterListActivity>(
requestCodeChapter,
@ -118,13 +117,13 @@ class AudioPlayActivity :
binding.ivFastRewind.invisible()
binding.ivFastForward.invisible()
}
binding.ivFastForward.onClick {
binding.ivFastForward.setOnClickListener {
AudioPlay.adjustSpeed(this@AudioPlayActivity, 0.1f)
}
binding.ivFastRewind.onClick {
binding.ivFastRewind.setOnClickListener {
AudioPlay.adjustSpeed(this@AudioPlayActivity, -0.1f)
}
binding.ivTimer.onClick {
binding.ivTimer.setOnClickListener {
AudioPlay.addTimer(this@AudioPlayActivity)
}
}

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

@ -13,8 +13,6 @@ import io.legado.app.databinding.ItemArrangeBookBinding
import io.legado.app.lib.theme.backgroundColor
import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
import io.legado.app.ui.widget.recycler.ItemTouchCallback
import org.jetbrains.anko.backgroundColor
import org.jetbrains.anko.sdk27.coroutines.onClick
import java.util.*
class ArrangeBookAdapter(context: Context, val callBack: CallBack) :
@ -40,7 +38,7 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) :
payloads: MutableList<Any>
) {
binding.apply {
root.backgroundColor = context.backgroundColor
root.setBackgroundColor(context.backgroundColor)
tvName.text = item.name
tvAuthor.text = item.author
tvAuthor.visibility = if (item.author.isEmpty()) View.GONE else View.VISIBLE
@ -65,7 +63,7 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) :
}
}
}
root.onClick {
root.setOnClickListener {
getItem(holder.layoutPosition)?.let {
checkbox.isChecked = !checkbox.isChecked
if (checkbox.isChecked) {
@ -76,12 +74,12 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) :
callBack.upSelectCount()
}
}
tvDelete.onClick {
tvDelete.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.deleteBook(it)
}
}
tvGroup.onClick {
tvGroup.setOnClickListener {
getItem(holder.layoutPosition)?.let {
actionItem = it
callBack.selectGroup(groupRequestCode, it.group)

@ -10,7 +10,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.databinding.ItemDownloadBinding
import io.legado.app.service.help.CacheBook
import org.jetbrains.anko.sdk27.coroutines.onClick
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArraySet
@ -54,7 +54,7 @@ class CacheAdapter(context: Context, private val callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemDownloadBinding) {
with(binding) {
ivDownload.onClick {
ivDownload.setOnClickListener {
getItem(holder.layoutPosition)?.let {
if (downloadMap?.containsKey(it.bookUrl) == true) {
CacheBook.remove(context, it.bookUrl)
@ -63,7 +63,7 @@ class CacheAdapter(context: Context, private val callBack: CallBack) :
}
}
}
tvExport.onClick {
tvExport.setOnClickListener {
callBack.export(holder.layoutPosition)
}
}

@ -7,7 +7,7 @@ import io.legado.app.base.adapter.DiffRecyclerAdapter
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.ItemCoverBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class CoverAdapter(context: Context, val callBack: CallBack) :
DiffRecyclerAdapter<SearchBook, ItemCoverBinding>(context) {
@ -41,7 +41,7 @@ class CoverAdapter(context: Context, val callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemCoverBinding) {
holder.itemView.apply {
onClick {
setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.changeTo(it.coverUrl ?: "")
}

@ -13,8 +13,6 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.ItemChangeSourceBinding
import io.legado.app.utils.invisible
import io.legado.app.utils.visible
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
class ChangeSourceAdapter(context: Context, val callBack: CallBack) :
@ -65,13 +63,14 @@ class ChangeSourceAdapter(context: Context, val callBack: CallBack) :
}
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.changeTo(it)
}
}
holder.itemView.onLongClick(returnValue = true) {
holder.itemView.setOnLongClickListener {
showMenu(holder.itemView, getItem(holder.layoutPosition))
true
}
}

@ -6,7 +6,6 @@ import android.os.Handler
import android.os.Looper
import androidx.lifecycle.MutableLiveData
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppPattern
import io.legado.app.constant.PreferKey
@ -21,7 +20,6 @@ import io.legado.app.utils.getPrefString
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.ExecutorCoroutineDispatcher
import kotlinx.coroutines.asCoroutineDispatcher
import org.jetbrains.anko.debug
import java.util.concurrent.CopyOnWriteArraySet
import java.util.concurrent.Executors
@ -173,7 +171,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
searchFinish(searchBook)
}
}.onError {
debug { context.getString(R.string.error_get_book_info) }
it.printStackTrace()
}
}
@ -186,7 +184,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
searchFinish(searchBook)
}
}.onError {
debug { context.getString(R.string.error_get_chapter_list) }
it.printStackTrace()
}
}

@ -10,7 +10,7 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.ItemSearchBinding
import io.legado.app.utils.gone
import io.legado.app.utils.visible
import org.jetbrains.anko.sdk27.coroutines.onClick
class ExploreShowAdapter(context: Context, val callBack: CallBack) :
RecyclerAdapter<SearchBook, ItemSearchBinding>(context) {
@ -51,7 +51,7 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
}
override fun registerListener(holder: ItemViewHolder, binding: ItemSearchBinding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.showBookInfo(it.toBook())
}

@ -28,7 +28,7 @@ import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private lateinit var viewModel: GroupViewModel
@ -68,7 +68,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
ItemTouchHelper(itemTouchCallback).attachToRecyclerView(binding.recyclerView)
binding.tvOk.setTextColor(requireContext().accentColor)
binding.tvOk.visible()
binding.tvOk.onClick { dismiss() }
binding.tvOk.setOnClickListener { dismiss() }
}
private fun initData() {
@ -164,7 +164,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
override fun registerListener(holder: ItemViewHolder, binding: ItemBookGroupManageBinding) {
with(binding) {
tvEdit.onClick { getItem(holder.layoutPosition)?.let { editGroup(it) } }
tvEdit.setOnClickListener { getItem(holder.layoutPosition)?.let { editGroup(it) } }
swShow.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) {
getItem(holder.layoutPosition)?.let {

@ -32,7 +32,7 @@ import io.legado.app.utils.getSize
import io.legado.app.utils.getViewModel
import io.legado.app.utils.requestInputMethod
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
@ -95,9 +95,9 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
val itemTouchCallback = ItemTouchCallback(adapter)
itemTouchCallback.isCanDrag = true
ItemTouchHelper(itemTouchCallback).attachToRecyclerView(binding.recyclerView)
binding.tvCancel.onClick { dismiss() }
binding.tvCancel.setOnClickListener { dismiss() }
binding.tvOk.setTextColor(requireContext().accentColor)
binding.tvOk.onClick {
binding.tvOk.setOnClickListener {
callBack?.upGroup(requestCode, groupId)
dismiss()
}
@ -187,7 +187,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
}
}
}
tvEdit.onClick { getItem(holder.layoutPosition)?.let { editGroup(it) } }
tvEdit.setOnClickListener { getItem(holder.layoutPosition)?.let { editGroup(it) } }
}
}

@ -37,10 +37,8 @@ import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.book.toc.ChapterListActivity
import io.legado.app.ui.widget.image.CoverImageView
import io.legado.app.utils.*
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast
class BookInfoActivity :
@ -92,7 +90,7 @@ class BookInfoActivity :
)
}
} else {
toast(R.string.after_add_bookshelf)
toastOnUI(R.string.after_add_bookshelf)
}
}
R.id.menu_share_it -> {
@ -113,7 +111,7 @@ class BookInfoActivity :
}
R.id.menu_copy_url -> viewModel.bookData.value?.bookUrl?.let {
sendToClip(it)
} ?: toast(R.string.no_book)
} ?: toastOnUI(R.string.no_book)
R.id.menu_can_update -> {
if (viewModel.inBookshelf) {
viewModel.bookData.value?.let {
@ -121,7 +119,7 @@ class BookInfoActivity :
viewModel.saveBook()
}
} else {
toast(R.string.after_add_bookshelf)
toastOnUI(R.string.after_add_bookshelf)
}
}
R.id.menu_clear_cache -> viewModel.clearCache()
@ -207,17 +205,17 @@ class BookInfoActivity :
}
private fun initOnClick() = with(binding) {
ivCover.onClick {
ivCover.setOnClickListener {
viewModel.bookData.value?.let {
ChangeCoverDialog.show(supportFragmentManager, it.name, it.author)
}
}
tvRead.onClick {
tvRead.setOnClickListener {
viewModel.bookData.value?.let {
readBook(it)
}
}
tvShelf.onClick {
tvShelf.setOnClickListener {
if (viewModel.inBookshelf) {
deleteBook()
} else {
@ -226,17 +224,17 @@ class BookInfoActivity :
}
}
}
tvOrigin.onClick {
tvOrigin.setOnClickListener {
viewModel.bookData.value?.let {
startActivity<BookSourceEditActivity>(Pair("data", it.origin))
}
}
tvChangeSource.onClick {
tvChangeSource.setOnClickListener {
viewModel.bookData.value?.let {
ChangeSourceDialog.show(supportFragmentManager, it.name, it.author)
}
}
tvTocView.onClick {
tvTocView.setOnClickListener {
if (!viewModel.inBookshelf) {
viewModel.saveBook {
viewModel.saveChapterList {
@ -247,15 +245,15 @@ class BookInfoActivity :
openChapterList()
}
}
tvChangeGroup.onClick {
tvChangeGroup.setOnClickListener {
viewModel.bookData.value?.let {
GroupSelectDialog.show(supportFragmentManager, it.group)
}
}
tvAuthor.onClick {
tvAuthor.setOnClickListener {
startActivity<SearchActivity>(Pair("key", viewModel.bookData.value?.author))
}
tvName.onClick {
tvName.setOnClickListener {
startActivity<SearchActivity>(Pair("key", viewModel.bookData.value?.name))
}
}
@ -293,7 +291,7 @@ class BookInfoActivity :
private fun openChapterList() {
if (viewModel.chapterListData.value.isNullOrEmpty()) {
toast(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 {
toast(R.string.error_get_book_info)
toastOnUI(R.string.error_get_book_info)
}
} ?: let {
chapterListData.postValue(null)
toast(R.string.error_no_source)
toastOnUI(R.string.error_no_source)
}
}
}
@ -101,19 +101,19 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
changeDruChapterIndex(it)
}
} else {
toast(R.string.chapter_list_empty)
toastOnUI(R.string.chapter_list_empty)
}
}.onError {
chapterListData.postValue(null)
toast(R.string.error_get_chapter_list)
toastOnUI(R.string.error_get_chapter_list)
}
} ?: let {
chapterListData.postValue(null)
toast(R.string.error_no_source)
toastOnUI(R.string.error_no_source)
}
}
}.onError {
toast("LoadTocError:${it.localizedMessage}")
toastOnUI("LoadTocError:${it.localizedMessage}")
}
}
@ -238,9 +238,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
execute {
BookHelp.clearCache(bookData.value!!)
}.onSuccess {
toast(R.string.clear_cache_success)
toastOnUI(R.string.clear_cache_success)
}.onError {
toast(it.stackTraceToString())
toastOnUI(it.stackTraceToString())
}
}

@ -8,8 +8,8 @@ import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.data.entities.BookChapter
import io.legado.app.databinding.ItemChapterListBinding
import io.legado.app.lib.theme.accentColor
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.textColorResource
import io.legado.app.utils.getCompatColor
class ChapterListAdapter(context: Context, var callBack: CallBack) :
RecyclerAdapter<BookChapter, ItemChapterListBinding>(context) {
@ -29,7 +29,7 @@ class ChapterListAdapter(context: Context, var callBack: CallBack) :
if (item.index == callBack.durChapterIndex()) {
tvChapterName.setTextColor(context.accentColor)
} else {
tvChapterName.textColorResource = R.color.secondaryText
tvChapterName.setTextColor(context.getCompatColor(R.color.secondaryText))
}
}
@ -37,7 +37,7 @@ class ChapterListAdapter(context: Context, var callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemChapterListBinding) {
holder.itemView.apply {
this.onClick {
this.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.openChapter(it)
}

@ -15,8 +15,6 @@ import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.ui.book.changecover.ChangeCoverDialog
import io.legado.app.utils.*
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.toast
import java.io.File
class BookInfoEditActivity :
@ -55,15 +53,15 @@ class BookInfoEditActivity :
}
private fun initEvent() = with(binding) {
tvChangeCover.onClick {
tvChangeCover.setOnClickListener {
viewModel.bookData.value?.let {
ChangeCoverDialog.show(supportFragmentManager, it.name, it.author)
}
}
tvSelectCover.onClick {
tvSelectCover.setOnClickListener {
selectImage()
}
tvRefreshCover.onClick {
tvRefreshCover.setOnClickListener {
viewModel.book?.customCoverUrl = tieCoverUrl.text?.toString()
upCover()
}
@ -121,7 +119,7 @@ class BookInfoEditActivity :
}.getOrNull()?.let { byteArray ->
file.writeBytes(byteArray)
coverChangeTo(file.absolutePath)
} ?: toast("获取文件出错")
} ?: toastOnUI("获取文件出错")
}
} else {
PermissionsCompat.Builder(this)

@ -28,8 +28,6 @@ import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.toast
import java.io.File
import java.util.*
@ -112,7 +110,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
}
private fun initEvent() {
binding.tvGoBack.onClick {
binding.tvGoBack.setOnClickListener {
goBackDir()
}
}
@ -253,7 +251,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
} ?: let {
val lastPath = AppConfig.importBookPath
if (lastPath.isNullOrEmpty()) {
toast(R.string.empty_msg_import_book)
toastOnUI(R.string.empty_msg_import_book)
} else {
adapter.clearItems()
val file = File(path)

@ -9,7 +9,7 @@ import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.constant.AppConst
import io.legado.app.databinding.ItemImportBookBinding
import io.legado.app.utils.*
import org.jetbrains.anko.sdk27.coroutines.onClick
class ImportBookAdapter(context: Context, val callBack: CallBack) :
RecyclerAdapter<DocItem, ItemImportBookBinding>(context) {
@ -62,7 +62,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) :
}
override fun registerListener(holder: ItemViewHolder, binding: ItemImportBookBinding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
if (it.isDir) {
callBack.nextDoc(it.uri)

@ -55,7 +55,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast
class ReadBookActivity : ReadBookBaseActivity(),
View.OnTouchListener,
@ -347,7 +346,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
) {
if (BaseReadAloudService.isPlay()) {
ReadAloud.pause(this)
toast(R.string.read_aloud_pause)
toastOnUI(R.string.read_aloud_pause)
return true
}
if (isAutoPage) {
@ -453,7 +452,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
R.id.menu_bookmark -> binding.readView.curPage.let {
val bookmark = it.createBookmark()
if (bookmark == null) {
toast(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 {
toast(it.msg)
toastOnUI(it.msg)
}.onFinally {
ReadBook.upMsg(null)
}

@ -21,8 +21,6 @@ import io.legado.app.lib.theme.*
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
import io.legado.app.utils.*
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
/**
* 阅读界面菜单
@ -83,8 +81,8 @@ class ReadMenu @JvmOverloads constructor(
tvFont.setTextColor(textColor)
ivSetting.setColorFilter(textColor)
tvSetting.setTextColor(textColor)
vwBg.onClick { }
vwNavigationBar.onClick { }
vwBg.setOnClickListener { }
vwNavigationBar.setOnClickListener { }
seekBrightness.progress = context.getPrefInt("brightness", 100)
}
@ -135,16 +133,16 @@ class ReadMenu @JvmOverloads constructor(
}
private fun bindEvent() = with(binding) {
tvChapterName.onClick {
tvChapterName.setOnClickListener {
callBack.openSourceEditActivity()
}
tvChapterUrl.onClick {
tvChapterUrl.setOnClickListener {
context.openUrl(binding.tvChapterUrl.text.toString())
}
tvLogin.onClick {
tvLogin.setOnClickListener {
callBack.showLogin()
}
ivBrightnessAuto.onClick {
ivBrightnessAuto.setOnClickListener {
context.putPrefBoolean("brightnessAuto", !brightnessAuto())
upBrightnessState()
}
@ -171,59 +169,60 @@ class ReadMenu @JvmOverloads constructor(
})
//搜索
fabSearch.onClick {
fabSearch.setOnClickListener {
runMenuOut {
callBack.openSearchActivity(null)
}
}
//自动翻页
fabAutoPage.onClick {
fabAutoPage.setOnClickListener {
runMenuOut {
callBack.autoPage()
}
}
//替换
fabReplaceRule.onClick { callBack.openReplaceRule() }
fabReplaceRule.setOnClickListener { callBack.openReplaceRule() }
//夜间模式
fabNightTheme.onClick {
fabNightTheme.setOnClickListener {
AppConfig.isNightTheme = !AppConfig.isNightTheme
App.INSTANCE.applyDayNight()
}
//上一章
tvPre.onClick { ReadBook.moveToPrevChapter(upContent = true, toLast = false) }
tvPre.setOnClickListener { ReadBook.moveToPrevChapter(upContent = true, toLast = false) }
//下一章
tvNext.onClick { ReadBook.moveToNextChapter(true) }
tvNext.setOnClickListener { ReadBook.moveToNextChapter(true) }
//目录
llCatalog.onClick {
llCatalog.setOnClickListener {
runMenuOut {
callBack.openChapterList()
}
}
//朗读
llReadAloud.onClick {
llReadAloud.setOnClickListener {
runMenuOut {
callBack.onClickReadAloud()
}
}
llReadAloud.onLongClick(returnValue = true) {
llReadAloud.setOnLongClickListener {
runMenuOut { callBack.showReadAloudDialog() }
true
}
//界面
llFont.onClick {
llFont.setOnClickListener {
runMenuOut {
callBack.showReadStyle()
}
}
//设置
llSetting.onClick {
llSetting.setOnClickListener {
runMenuOut {
callBack.showMoreSetting()
}
@ -241,7 +240,7 @@ class ReadMenu @JvmOverloads constructor(
}
override fun onAnimationEnd(animation: Animation) {
binding.vwMenuBg.onClick { runMenuOut() }
binding.vwMenuBg.setOnClickListener { runMenuOut() }
binding.vwNavigationBar.layoutParams = binding.vwNavigationBar.layoutParams.apply {
height = activity!!.navigationBarHeight
}

@ -24,13 +24,8 @@ import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.databinding.ItemTextBinding
import io.legado.app.databinding.PopupActionMenuBinding
import io.legado.app.service.BaseReadAloudService
import io.legado.app.utils.gone
import io.legado.app.utils.isAbsUrl
import io.legado.app.utils.sendToClip
import io.legado.app.utils.visible
import org.jetbrains.anko.sdk27.coroutines.onClick
import io.legado.app.utils.*
import org.jetbrains.anko.share
import org.jetbrains.anko.toast
import java.util.*
@SuppressLint("RestrictedApi")
@ -73,7 +68,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
if (moreMenu.size() > 0) {
ivMenuMore.visible()
}
ivMenuMore.onClick {
ivMenuMore.setOnClickListener {
if (recyclerView.isVisible) {
ivMenuMore.setImageResource(R.drawable.ic_arrow_back)
adapter.setItems(moreMenu.visibleItems)
@ -107,7 +102,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
}
override fun registerListener(holder: ItemViewHolder, binding: ItemTextBinding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
if (!callBack.onMenuItemSelected(it.itemId)) {
onMenuItemSelected(it)
@ -124,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.toast(R.string.alouding_disable)
context.toastOnUI(R.string.alouding_disable)
return
}
readAloud(callBack.selectedText)
@ -143,7 +138,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
context.startActivity(intent)
}.onFailure {
it.printStackTrace()
context.toast(it.localizedMessage ?: "ERROR")
context.toastOnUI(it.localizedMessage ?: "ERROR")
}
}
else -> item.intent?.let {
@ -219,7 +214,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
).intent = createProcessTextIntentForResolveInfo(resolveInfo)
}
}.onFailure {
context.toast("获取文字操作菜单出错:${it.localizedMessage}")
context.toastOnUI("获取文字操作菜单出错:${it.localizedMessage}")
}
}

@ -16,7 +16,7 @@ import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class AutoReadDialog : BaseDialogFragment() {
var callBack: CallBack? = null
@ -94,12 +94,12 @@ class AutoReadDialog : BaseDialogFragment() {
}
private fun initEvent() {
binding.llMainMenu.onClick { callBack?.showMenuBar(); dismiss() }
binding.llSetting.onClick {
binding.llMainMenu.setOnClickListener { callBack?.showMenuBar(); dismiss() }
binding.llSetting.setOnClickListener {
ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog")
}
binding.llCatalog.onClick { callBack?.openChapterList() }
binding.llAutoPageStop.onClick {
binding.llCatalog.setOnClickListener { callBack?.openChapterList() }
binding.llAutoPageStop.setOnClickListener {
callBack?.autoPageStop()
dismiss()
}

@ -9,7 +9,7 @@ import io.legado.app.databinding.ItemBgImageBinding
import io.legado.app.help.ImageLoader
import io.legado.app.help.ReadBookConfig
import io.legado.app.utils.postEvent
import org.jetbrains.anko.sdk27.coroutines.onClick
import java.io.File
class BgAdapter(context: Context, val textColor: Int) :
@ -39,7 +39,7 @@ class BgAdapter(context: Context, val textColor: Int) :
override fun registerListener(holder: ItemViewHolder, binding: ItemBgImageBinding) {
holder.itemView.apply {
this.onClick {
this.setOnClickListener {
getItemByLayoutPosition(holder.layoutPosition)?.let {
ReadBookConfig.durConfig.setCurBg(1, it)
ReadBookConfig.upBg()

@ -28,8 +28,6 @@ import io.legado.app.ui.filepicker.FilePicker
import io.legado.app.ui.filepicker.FilePickerDialog
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onCheckedChange
import org.jetbrains.anko.sdk27.coroutines.onClick
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toByteArray
import java.io.File
@ -110,7 +108,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
tvName.text = getString(R.string.select_image)
ivBg.setImageResource(R.drawable.ic_image)
ivBg.setColorFilter(primaryTextColor)
root.onClick { selectImage() }
root.setOnClickListener { selectImage() }
}
}
requireContext().assets.list("bg")?.let {
@ -120,7 +118,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
@SuppressLint("InflateParams")
private fun initEvent() = with(ReadBookConfig.durConfig) {
binding.ivEdit.onClick {
binding.ivEdit.setOnClickListener {
alert(R.string.style_name) {
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.setText(ReadBookConfig.durConfig.name)
@ -135,13 +133,13 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
cancelButton()
}.show()
}
binding.swDarkStatusIcon.onCheckedChange { buttonView, isChecked ->
binding.swDarkStatusIcon.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView?.isPressed == true) {
setCurStatusIconDark(isChecked)
(activity as? ReadBookActivity)?.upSystemUiVisibility()
}
}
binding.tvTextColor.onClick {
binding.tvTextColor.setOnClickListener {
ColorPickerDialog.newBuilder()
.setColor(curTextColor())
.setShowAlphaSlider(false)
@ -149,7 +147,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
.setDialogId(TEXT_COLOR)
.show(requireActivity())
}
binding.tvBgColor.onClick {
binding.tvBgColor.setOnClickListener {
val bgColor =
if (curBgType() == 0) Color.parseColor(curBgStr())
else Color.parseColor("#015A86")
@ -160,7 +158,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
.setDialogId(BG_COLOR)
.show(requireActivity())
}
binding.ivImport.onClick {
binding.ivImport.setOnClickListener {
val importFormNet = "网络导入"
val otherActions = arrayListOf(importFormNet)
FilePicker.selectFile(
@ -175,19 +173,19 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
}
}
}
binding.ivExport.onClick {
binding.ivExport.setOnClickListener {
FilePicker.selectFolder(
this@BgTextConfigDialog,
requestCodeExport,
title = getString(R.string.export_str)
)
}
binding.ivDelete.onClick {
binding.ivDelete.setOnClickListener {
if (ReadBookConfig.deleteDur()) {
postEvent(EventBus.UP_CONFIG, true)
dismiss()
} else {
toast("数量已是最少,不能删除.")
toastOnUI("数量已是最少,不能删除.")
}
}
}
@ -269,7 +267,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
}
}
}.onSuccess {
toast("导出成功, 文件名为 $exportFileName")
toastOnUI("导出成功, 文件名为 $exportFileName")
}.onError {
it.printStackTrace()
longToast("导出失败:${it.localizedMessage}")
@ -365,7 +363,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
ReadBookConfig.durConfig = config
postEvent(EventBus.UP_CONFIG, true)
}.onSuccess {
toast("导入成功")
toastOnUI("导入成功")
}.onError {
it.printStackTrace()
longToast("导入失败:${it.localizedMessage}")
@ -406,7 +404,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
ReadBookConfig.durConfig.setCurBg(2, file.absolutePath)
ReadBookConfig.upBg()
postEvent(EventBus.UP_CONFIG, false)
} ?: toast("获取文件出错")
} ?: toastOnUI("获取文件出错")
}
} else {
PermissionsCompat.Builder(this)

@ -10,7 +10,7 @@ import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.widget.text.StrokeTextView
import org.jetbrains.anko.sdk27.coroutines.onClick
class ChineseConverter(context: Context, attrs: AttributeSet?) : StrokeTextView(context, attrs) {
@ -23,7 +23,7 @@ class ChineseConverter(context: Context, attrs: AttributeSet?) : StrokeTextView(
if (!isInEditMode) {
upUi(AppConfig.chineseConverterType)
}
onClick {
setOnClickListener {
selectType()
}
}

@ -16,7 +16,7 @@ import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.putPrefInt
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class ClickActionConfigDialog : BaseDialogFragment() {
private val binding by viewBinding(DialogClickActionConfigBinding::bind)
@ -68,52 +68,52 @@ class ClickActionConfigDialog : BaseDialogFragment() {
}
private fun initViewEvent() {
binding.ivClose.onClick {
binding.ivClose.setOnClickListener {
dismiss()
}
binding.tvTopLeft.onClick {
binding.tvTopLeft.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionTL, action)
(it as? TextView)?.text = actions[action]
}
}
binding.tvTopCenter.onClick {
binding.tvTopCenter.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionTC, action)
(it as? TextView)?.text = actions[action]
}
}
binding.tvTopRight.onClick {
binding.tvTopRight.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionTR, action)
(it as? TextView)?.text = actions[action]
}
}
binding.tvMiddleLeft.onClick {
binding.tvMiddleLeft.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionML, action)
(it as? TextView)?.text = actions[action]
}
}
binding.tvMiddleRight.onClick {
binding.tvMiddleRight.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionMR, action)
(it as? TextView)?.text = actions[action]
}
}
binding.tvBottomLeft.onClick {
binding.tvBottomLeft.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionBL, action)
(it as? TextView)?.text = actions[action]
}
}
binding.tvBottomCenter.onClick {
binding.tvBottomCenter.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionBC, action)
(it as? TextView)?.text = actions[action]
}
}
binding.tvBottomRight.onClick {
binding.tvBottomRight.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionBR, action)
(it as? TextView)?.text = actions[action]

@ -10,7 +10,7 @@ import io.legado.app.lib.theme.backgroundColor
import io.legado.app.utils.getPrefString
import io.legado.app.utils.hideSoftInput
import io.legado.app.utils.putPrefString
import org.jetbrains.anko.sdk27.coroutines.onClick
class PageKeyDialog(context: Context) : Dialog(context, R.style.AppTheme_AlertDialog) {
@ -21,7 +21,7 @@ class PageKeyDialog(context: Context) : Dialog(context, R.style.AppTheme_AlertDi
binding.contentView.setBackgroundColor(context.backgroundColor)
binding.etPrev.setText(context.getPrefString(PreferKey.prevKeys))
binding.etNext.setText(context.getPrefString(PreferKey.nextKeys))
binding.tvOk.onClick {
binding.tvOk.setOnClickListener {
context.putPrefString(PreferKey.prevKeys, binding.etPrev.text?.toString())
context.putPrefString(PreferKey.nextKeys, binding.etNext.text?.toString())
dismiss()

@ -21,7 +21,7 @@ import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.observeEvent
import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class ReadAloudDialog : BaseDialogFragment() {
private var callBack: CallBack? = null
@ -122,18 +122,18 @@ class ReadAloudDialog : BaseDialogFragment() {
}
private fun initEvent() = with(binding) {
llMainMenu.onClick { callBack?.showMenuBar(); dismiss() }
llSetting.onClick {
llMainMenu.setOnClickListener { callBack?.showMenuBar(); dismiss() }
llSetting.setOnClickListener {
ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog")
}
tvPre.onClick { ReadBook.moveToPrevChapter(upContent = true, toLast = false) }
tvNext.onClick { ReadBook.moveToNextChapter(true) }
ivStop.onClick { ReadAloud.stop(requireContext()); dismiss() }
ivPlayPause.onClick { callBack?.onClickReadAloud() }
ivPlayPrev.onClick { ReadAloud.prevParagraph(requireContext()) }
ivPlayNext.onClick { ReadAloud.nextParagraph(requireContext()) }
llCatalog.onClick { callBack?.openChapterList() }
llToBackstage.onClick { callBack?.finish() }
tvPre.setOnClickListener { ReadBook.moveToPrevChapter(upContent = true, toLast = false) }
tvNext.setOnClickListener { ReadBook.moveToNextChapter(true) }
ivStop.setOnClickListener { ReadAloud.stop(requireContext()); dismiss() }
ivPlayPause.setOnClickListener { callBack?.onClickReadAloud() }
ivPlayPrev.setOnClickListener { ReadAloud.prevParagraph(requireContext()) }
ivPlayNext.setOnClickListener { ReadAloud.nextParagraph(requireContext()) }
llCatalog.setOnClickListener { callBack?.openChapterList() }
llToBackstage.setOnClickListener { callBack?.finish() }
}
private fun upPlayState() {

@ -24,9 +24,6 @@ import io.legado.app.utils.dp
import io.legado.app.utils.getIndexById
import io.legado.app.utils.postEvent
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onCheckedChange
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
private val binding by viewBinding(DialogReadBookStyleBinding::bind)
@ -93,7 +90,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
ivStyle.setColorFilter(textColor)
ivStyle.borderColor = textColor
ivStyle.setImageResource(R.drawable.ic_add)
root.onClick {
root.setOnClickListener {
ReadBookConfig.configList.add(ReadBookConfig.Config())
showBgTextConfig(ReadBookConfig.configList.lastIndex)
}
@ -114,10 +111,10 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
textFontWeightConverter.onChanged {
postEvent(EventBus.UP_CONFIG, true)
}
tvTextFont.onClick {
tvTextFont.setOnClickListener {
FontSelectDialog().show(childFragmentManager, "fontSelectDialog")
}
tvTextIndent.onClick {
tvTextIndent.setOnClickListener {
selector(
title = getString(R.string.text_indent),
items = resources.getStringArray(R.array.indent).toList()
@ -126,14 +123,14 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
postEvent(EventBus.UP_CONFIG, true)
}
}
tvPadding.onClick {
tvPadding.setOnClickListener {
dismiss()
callBack?.showPaddingConfig()
}
tvTip.onClick {
tvTip.setOnClickListener {
TipConfigDialog().show(childFragmentManager, "tipConfigDialog")
}
rgPageAnim.onCheckedChange { _, checkedId ->
rgPageAnim.setOnCheckedChangeListener { _, checkedId ->
ReadBook.book?.setPageAnim(-1)
ReadBookConfig.pageAnim = binding.rgPageAnim.getIndexById(checkedId)
callBack?.upPageAnim()
@ -235,14 +232,16 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
override fun registerListener(holder: ItemViewHolder, binding: ItemReadStyleBinding) {
binding.apply {
ivStyle.onClick {
ivStyle.setOnClickListener {
if (ivStyle.isInView) {
changeBg(holder.layoutPosition)
}
}
ivStyle.onLongClick(returnValue = ivStyle.isInView) {
ivStyle.setOnLongClickListener {
if (ivStyle.isInView) {
showBgTextConfig(holder.layoutPosition)
} else {
false
}
}
}

@ -27,7 +27,7 @@ import io.legado.app.service.help.ReadAloud
import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private val binding by viewBinding(DialogRecyclerViewBinding::bind)
@ -66,17 +66,17 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
recyclerView.adapter = adapter
tvFooterLeft.setText(R.string.local_tts)
tvFooterLeft.visible()
tvFooterLeft.onClick {
tvFooterLeft.setOnClickListener {
removePref(PreferKey.speakEngine)
dismiss()
}
tvOk.visible()
tvOk.onClick {
tvOk.setOnClickListener {
putPrefLong(PreferKey.speakEngine, engineId)
dismiss()
}
tvCancel.visible()
tvCancel.onClick {
tvCancel.setOnClickListener {
dismiss()
}
}
@ -150,16 +150,16 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
override fun registerListener(holder: ItemViewHolder, binding: ItemHttpTtsBinding) {
binding.apply {
cbName.onClick {
cbName.setOnClickListener {
getItem(holder.layoutPosition)?.let { httpTTS ->
engineId = httpTTS.id
notifyItemRangeChanged(0, itemCount)
}
}
ivEdit.onClick {
ivEdit.setOnClickListener {
editHttpTTS(getItem(holder.layoutPosition))
}
ivMenuDelete.onClick {
ivMenuDelete.setOnClickListener {
getItem(holder.layoutPosition)?.let { httpTTS ->
App.db.httpTTSDao.delete(httpTTS)
}

@ -10,7 +10,7 @@ import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.widget.text.StrokeTextView
import org.jetbrains.anko.sdk27.coroutines.onClick
class TextFontWeightConverter(context: Context, attrs: AttributeSet?) : StrokeTextView(context, attrs) {
@ -23,7 +23,7 @@ class TextFontWeightConverter(context: Context, attrs: AttributeSet?) : StrokeTe
if (!isInEditMode) {
upUi(ReadBookConfig.textBold)
}
onClick {
setOnClickListener {
selectType()
}
}

@ -14,8 +14,7 @@ import io.legado.app.help.ReadTipConfig
import io.legado.app.lib.dialogs.selector
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onCheckedChange
import org.jetbrains.anko.sdk27.coroutines.onClick
class TipConfigDialog : BaseDialogFragment() {
@ -76,7 +75,7 @@ class TipConfigDialog : BaseDialogFragment() {
}
private fun initEvent() = with(binding) {
rgTitleMode.onCheckedChange { _, checkedId ->
rgTitleMode.setOnCheckedChangeListener { _, checkedId ->
ReadBookConfig.titleMode = rgTitleMode.getIndexById(checkedId)
postEvent(EventBus.UP_CONFIG, true)
}
@ -92,21 +91,21 @@ class TipConfigDialog : BaseDialogFragment() {
ReadBookConfig.titleBottomSpacing = it
postEvent(EventBus.UP_CONFIG, true)
}
llHeaderShow.onClick {
llHeaderShow.setOnClickListener {
selector(items = ReadTipConfig.headerModes.values.toList()) { _, i ->
ReadTipConfig.headerMode = ReadTipConfig.headerModes.keys.toList()[i]
tvHeaderShow.text = ReadTipConfig.headerModes[ReadTipConfig.headerMode]
postEvent(EventBus.UP_CONFIG, true)
}
}
llFooterShow.onClick {
llFooterShow.setOnClickListener {
selector(items = ReadTipConfig.footerModes.values.toList()) { _, i ->
ReadTipConfig.footerMode = ReadTipConfig.footerModes.keys.toList()[i]
tvFooterShow.text = ReadTipConfig.footerModes[ReadTipConfig.footerMode]
postEvent(EventBus.UP_CONFIG, true)
}
}
llHeaderLeft.onClick {
llHeaderLeft.setOnClickListener {
selector(items = ReadTipConfig.tips) { _, i ->
clearRepeat(i)
ReadTipConfig.tipHeaderLeft = i
@ -114,7 +113,7 @@ class TipConfigDialog : BaseDialogFragment() {
postEvent(EventBus.UP_CONFIG, true)
}
}
llHeaderMiddle.onClick {
llHeaderMiddle.setOnClickListener {
selector(items = ReadTipConfig.tips) { _, i ->
clearRepeat(i)
ReadTipConfig.tipHeaderMiddle = i
@ -122,7 +121,7 @@ class TipConfigDialog : BaseDialogFragment() {
postEvent(EventBus.UP_CONFIG, true)
}
}
llHeaderRight.onClick {
llHeaderRight.setOnClickListener {
selector(items = ReadTipConfig.tips) { _, i ->
clearRepeat(i)
ReadTipConfig.tipHeaderRight = i
@ -130,7 +129,7 @@ class TipConfigDialog : BaseDialogFragment() {
postEvent(EventBus.UP_CONFIG, true)
}
}
llFooterLeft.onClick {
llFooterLeft.setOnClickListener {
selector(items = ReadTipConfig.tips) { _, i ->
clearRepeat(i)
ReadTipConfig.tipFooterLeft = i
@ -138,7 +137,7 @@ class TipConfigDialog : BaseDialogFragment() {
postEvent(EventBus.UP_CONFIG, true)
}
}
llFooterMiddle.onClick {
llFooterMiddle.setOnClickListener {
selector(items = ReadTipConfig.tips) { _, i ->
clearRepeat(i)
ReadTipConfig.tipFooterMiddle = i
@ -146,7 +145,7 @@ class TipConfigDialog : BaseDialogFragment() {
postEvent(EventBus.UP_CONFIG, true)
}
}
llFooterRight.onClick {
llFooterRight.setOnClickListener {
selector(items = ReadTipConfig.tips) { _, i ->
clearRepeat(i)
ReadTipConfig.tipFooterRight = i
@ -154,7 +153,7 @@ class TipConfigDialog : BaseDialogFragment() {
postEvent(EventBus.UP_CONFIG, true)
}
}
llTipColor.onClick {
llTipColor.setOnClickListener {
selector(items = arrayListOf("跟随正文", "自定义")) { _, i ->
when (i) {
0 -> {

@ -33,7 +33,7 @@ import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch
import org.jetbrains.anko.sdk27.coroutines.onClick
import java.util.*
class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
@ -79,16 +79,16 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
val itemTouchCallback = ItemTouchCallback(adapter)
itemTouchCallback.isCanDrag = true
ItemTouchHelper(itemTouchCallback).attachToRecyclerView(recyclerView)
tvCancel.onClick {
tvCancel.setOnClickListener {
dismiss()
}
tvOk.onClick {
tvOk.setOnClickListener {
adapter.getItems().forEach { tocRule ->
if (selectedName == tocRule.name) {
val callBack = activity as? CallBack
callBack?.onTocRegexDialogResult(tocRule.rule)
dismiss()
return@onClick
return@setOnClickListener
}
}
}
@ -231,10 +231,10 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
}
}
}
ivEdit.onClick {
ivEdit.setOnClickListener {
editRule(getItem(holder.layoutPosition))
}
ivDelete.onClick {
ivDelete.setOnClickListener {
getItem(holder.layoutPosition)?.let { item ->
launch(IO) {
App.db.txtTocRule.delete(item)

@ -20,7 +20,6 @@ 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.widget.BatteryView
import io.legado.app.utils.*
import org.jetbrains.anko.topPadding
import java.util.*
/**
@ -97,9 +96,9 @@ class PageView(context: Context) : FrameLayout(context) {
/**
* 显示状态栏时隐藏header
*/
fun upStatusBar() {
binding.vwStatusBar.topPadding = context.statusBarHeight
binding.vwStatusBar.isGone =
fun upStatusBar() = with(binding.vwStatusBar) {
setPadding(paddingLeft, context.statusBarHeight, paddingRight, paddingBottom)
isGone =
ReadBookConfig.hideStatusBar || (activity as? BaseActivity<*>)?.isInMultiWindow == true
}

@ -6,7 +6,7 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.data.entities.Book
import io.legado.app.databinding.ItemFilletTextBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class BookAdapter(context: Context, val callBack: CallBack) :
RecyclerAdapter<Book, ItemFilletTextBinding>(context) {
@ -28,7 +28,7 @@ class BookAdapter(context: Context, val callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemFilletTextBinding) {
holder.itemView.apply {
onClick {
setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.showBookInfo(it)
}

@ -10,9 +10,6 @@ import io.legado.app.ui.widget.anima.explosion_field.ExplosionField
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
class HistoryKeyAdapter(activity: SearchActivity, val callBack: CallBack) :
RecyclerAdapter<SearchKeyword, ItemFilletTextBinding>(activity) {
@ -36,12 +33,12 @@ class HistoryKeyAdapter(activity: SearchActivity, val callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemFilletTextBinding) {
holder.itemView.apply {
onClick {
setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.searchHistory(it.word)
}
}
onLongClick(returnValue = true) {
setOnLongClickListener {
it?.let {
explosionField.explode(it, true)
}
@ -50,6 +47,7 @@ class HistoryKeyAdapter(activity: SearchActivity, val callBack: CallBack) :
App.db.searchKeywordDao.delete(it)
}
}
true
}
}
}

@ -28,7 +28,7 @@ import io.legado.app.utils.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.startActivity
class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel>(),
@ -184,11 +184,11 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
.setDefaultColor(accentColor)
.setPressedColor(ColorUtils.darkenColor(accentColor))
.create()
binding.fbStop.onClick {
binding.fbStop.setOnClickListener {
viewModel.stop()
binding.refreshProgressBar.isAutoLoading = false
}
binding.tvClearHistory.onClick { viewModel.clearHistory() }
binding.tvClearHistory.setOnClickListener { viewModel.clearHistory() }
}
private fun initLiveData() {

@ -11,7 +11,7 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.ItemSearchBinding
import io.legado.app.utils.gone
import io.legado.app.utils.visible
import org.jetbrains.anko.sdk27.coroutines.onClick
class SearchAdapter(context: Context, val callBack: CallBack) :
DiffRecyclerAdapter<SearchBook, ItemSearchBinding>(context) {
@ -66,7 +66,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
}
override fun registerListener(holder: ItemViewHolder, binding: ItemSearchBinding) {
binding.root.onClick {
binding.root.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.showBookInfo(it.name, it.author)
}

@ -26,7 +26,7 @@ import io.legado.app.utils.observeEvent
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.coroutines.onClick
class SearchContentActivity :
VMBaseActivity<ActivitySearchContentBinding, SearchContentViewModel>(),
@ -92,8 +92,13 @@ class SearchContentActivity :
}
private fun initView() {
binding.ivSearchContentTop.onClick { mLayoutManager.scrollToPositionWithOffset(0, 0) }
binding.ivSearchContentBottom.onClick {
binding.ivSearchContentTop.setOnClickListener {
mLayoutManager.scrollToPositionWithOffset(
0,
0
)
}
binding.ivSearchContentBottom.setOnClickListener {
if (adapter.itemCount > 0) {
mLayoutManager.scrollToPositionWithOffset(adapter.itemCount - 1, 0)
}

@ -9,7 +9,7 @@ import io.legado.app.databinding.ItemSearchListBinding
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.hexString
import org.jetbrains.anko.sdk27.coroutines.onClick
class SearchContentAdapter(context: Context, val callback: Callback) :
RecyclerAdapter<SearchResult, ItemSearchListBinding>(context) {
@ -38,7 +38,7 @@ class SearchContentAdapter(context: Context, val callback: Callback) :
}
override fun registerListener(holder: ItemViewHolder, binding: ItemSearchListBinding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callback.openSearchResult(it)
}

@ -14,9 +14,9 @@ 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 kotlinx.coroutines.launch
import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast
class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookSourceDebugModel>() {
@ -83,7 +83,7 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
viewModel.startDebug(key, {
binding.rotateLoading.show()
}, {
toast("未获取到书源")
toastOnUI("未获取到书源")
})
}

@ -105,7 +105,7 @@ class BookSourceEditActivity :
R.id.menu_login -> getSource().let {
if (checkSource(it)) {
if (it.loginUrl.isNullOrEmpty()) {
toast(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()) {
toast(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 {
toast(it.localizedMessage)
toastOnUI(it.localizedMessage)
it.printStackTrace()
}
}
@ -58,13 +58,13 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
}
source
}.onError {
toast(it.localizedMessage)
toastOnUI(it.localizedMessage)
it.printStackTrace()
}.onSuccess {
if (it != null) {
onSuccess(it)
} else {
toast("格式不对")
toastOnUI("格式不对")
}
}
}
@ -76,7 +76,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
finally.invoke(it)
}
}.onError {
toast(it.localizedMessage ?: "Error")
toastOnUI(it.localizedMessage ?: "Error")
}
}
}

@ -40,7 +40,6 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast
import java.io.File
class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceViewModel>(),
@ -412,7 +411,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
groups.map { group ->
if (group.contains("失效")) {
searchView.setQuery("失效", true)
toast("发现有失效书源,已为您自动筛选!")
toastOnUI("发现有失效书源,已为您自动筛选!")
}
}
}
@ -474,7 +473,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
startActivity<ImportBookSourceActivity>("dataKey" to dataKey)
}
} catch (e: Exception) {
toast("readTextError:${e.localizedMessage}")
toastOnUI("readTextError:${e.localizedMessage}")
}
}
}

@ -20,7 +20,7 @@ import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
import io.legado.app.ui.widget.recycler.ItemTouchCallback.Callback
import io.legado.app.utils.invisible
import io.legado.app.utils.visible
import org.jetbrains.anko.sdk27.coroutines.onClick
class BookSourceAdapter(context: Context, val callBack: CallBack) :
RecyclerAdapter<BookSource, ItemBookSourceBinding>(context),
@ -132,12 +132,12 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
}
}
}
ivEdit.onClick {
ivEdit.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.edit(it)
}
}
ivMenuMore.onClick {
ivMenuMore.setOnClickListener {
showMenu(ivMenuMore, holder.layoutPosition)
}
}

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

@ -24,7 +24,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
private lateinit var viewModel: BookSourceViewModel
@ -129,12 +129,12 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
override fun registerListener(holder: ItemViewHolder, binding: ItemGroupManageBinding) {
binding.apply {
tvEdit.onClick {
tvEdit.setOnClickListener {
getItem(holder.layoutPosition)?.let {
editGroup(it)
}
}
tvDel.onClick {
tvDel.setOnClickListener {
getItem(holder.layoutPosition)?.let { viewModel.delGroup(it) }
}
}

@ -7,8 +7,6 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.data.entities.Bookmark
import io.legado.app.databinding.ItemBookmarkBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
class BookmarkAdapter(val callback: Callback) : PagedListAdapter<Bookmark, BookmarkAdapter.MyViewHolder>(DIFF_CALLBACK) {
@ -45,11 +43,12 @@ class BookmarkAdapter(val callback: Callback) : PagedListAdapter<Bookmark, Bookm
tvChapterName.text = bookmark.chapterName
tvBookText.text = bookmark.bookText
tvContent.text = bookmark.content
itemView.onClick {
itemView.setOnClickListener {
callback?.onClick(bookmark)
}
itemView.onLongClick(returnValue = true) {
itemView.setOnLongClickListener {
callback?.onLongClick(bookmark)
true
}
}
}

@ -10,7 +10,7 @@ import io.legado.app.databinding.ItemChapterListBinding
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.visible
import org.jetbrains.anko.sdk27.coroutines.onClick
class ChapterListAdapter(context: Context, val callback: Callback) :
RecyclerAdapter<BookChapter, ItemChapterListBinding>(context) {
@ -49,7 +49,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
}
override fun registerListener(holder: ItemViewHolder, binding: ItemChapterListBinding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callback.openChapter(it)
}

@ -26,7 +26,7 @@ import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.coroutines.onClick
import kotlin.math.min
class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_chapter_list),
@ -63,13 +63,13 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
}
private fun initView() = with(binding) {
ivChapterTop.onClick { mLayoutManager.scrollToPositionWithOffset(0, 0) }
ivChapterBottom.onClick {
ivChapterTop.setOnClickListener { mLayoutManager.scrollToPositionWithOffset(0, 0) }
ivChapterBottom.setOnClickListener {
if (adapter.itemCount > 0) {
mLayoutManager.scrollToPositionWithOffset(adapter.itemCount - 1, 0)
}
}
tvCurrentChapterInfo.onClick {
tvCurrentChapterInfo.setOnClickListener {
mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0)
}
}

@ -20,9 +20,8 @@ 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.toast
import io.legado.app.utils.toastOnUI
import kotlinx.coroutines.Dispatchers.Main
import org.jetbrains.anko.toast
object BackupRestoreUi {
private const val selectFolderRequestCode = 21
@ -42,7 +41,7 @@ object BackupRestoreUi {
Coroutine.async {
Backup.backup(fragment.requireContext(), backupPath)
}.onSuccess {
fragment.toast(R.string.backup_success)
fragment.toastOnUI(R.string.backup_success)
}
} else {
selectBackupFolder(fragment, backupSelectRequestCode)
@ -65,7 +64,7 @@ object BackupRestoreUi {
AppConfig.backupPath = path
Backup.backup(fragment.requireContext(), path)
}.onSuccess {
fragment.toast(R.string.backup_success)
fragment.toastOnUI(R.string.backup_success)
}
}
.request()
@ -135,7 +134,7 @@ object BackupRestoreUi {
Coroutine.async {
Backup.backup(App.INSTANCE, uri.toString())
}.onSuccess {
App.INSTANCE.toast(R.string.backup_success)
App.INSTANCE.toastOnUI(R.string.backup_success)
}
} else {
uri.path?.let { path ->
@ -143,7 +142,7 @@ object BackupRestoreUi {
Coroutine.async {
Backup.backup(App.INSTANCE, path)
}.onSuccess {
App.INSTANCE.toast(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)
toast(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()
} ?: toast("获取文件出错")
} ?: toastOnUI("获取文件出错")
}
} else {
PermissionsCompat.Builder(this)

@ -60,7 +60,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
findPreference<ColorPreference>(PreferKey.cBackground)?.let {
it.onSaveColor = { color ->
if (!ColorUtils.isColorLight(color)) {
toast(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)) {
toast(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 -> {
toast(R.string.accent_background_diff)
toastOnUI(R.string.accent_background_diff)
true
}
ColorUtils.getColorDifference(color, textColor) <= 60 -> {
toast(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 -> {
toast(R.string.accent_background_diff)
toastOnUI(R.string.accent_background_diff)
true
}
ColorUtils.getColorDifference(color, textColor) <= 60 -> {
toast(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()
} ?: toast("获取文件出错")
} ?: toastOnUI("获取文件出错")
}
} else {
PermissionsCompat.Builder(this)

@ -19,7 +19,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.share
class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
@ -72,7 +72,7 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
if (ThemeConfig.addConfig(it)) {
initData()
} else {
toast("格式不对,添加失败")
toastOnUI("格式不对,添加失败")
}
}
}
@ -115,13 +115,13 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
override fun registerListener(holder: ItemViewHolder, binding: ItemThemeConfigBinding) {
binding.apply {
root.onClick {
root.setOnClickListener {
ThemeConfig.applyConfig(context, ThemeConfig.configList[holder.layoutPosition])
}
ivShare.onClick {
ivShare.setOnClickListener {
share(holder.layoutPosition)
}
ivDelete.onClick {
ivDelete.setOnClickListener {
delete(holder.layoutPosition)
}
}

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

@ -13,7 +13,7 @@ import io.legado.app.ui.filepicker.entity.FileItem
import io.legado.app.ui.filepicker.utils.ConvertUtils
import io.legado.app.ui.filepicker.utils.FilePickerIcon
import io.legado.app.utils.FileUtils
import org.jetbrains.anko.sdk27.coroutines.onClick
import java.io.File
import java.util.*
@ -118,7 +118,7 @@ class FileAdapter(context: Context, val callBack: CallBack) :
}
override fun registerListener(holder: ItemViewHolder, binding: ItemFileFilepickerBinding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
callBack.onFileClick(holder.layoutPosition)
}
}

@ -8,7 +8,7 @@ import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.databinding.ItemPathFilepickerBinding
import io.legado.app.ui.filepicker.utils.ConvertUtils
import io.legado.app.ui.filepicker.utils.FilePickerIcon
import org.jetbrains.anko.sdk27.coroutines.onClick
import java.util.*
@ -61,7 +61,7 @@ class PathAdapter(context: Context, val callBack: CallBack) :
}
override fun registerListener(holder: ItemViewHolder, binding: ItemPathFilepickerBinding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
callBack.onPathClick(holder.layoutPosition)
}
}

@ -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 org.jetbrains.anko.toast
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) {
toast(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 {
toast("${selectedGroup.groupName}(${it.getBooksCount()})")
toastOnUI("${selectedGroup.groupName}(${it.getBooksCount()})")
}
}

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

@ -9,8 +9,6 @@ import io.legado.app.data.entities.Book
import io.legado.app.databinding.ItemBookshelfGridBinding
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.invisible
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
BaseBooksAdapter<ItemBookshelfGridBinding>(context) {
@ -55,16 +53,17 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemBookshelfGridBinding) {
holder.itemView.apply {
onClick {
setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.open(it)
}
}
onLongClick(returnValue = true) {
setOnLongClickListener {
getItem(holder.layoutPosition)?.let {
callBack.openBookInfo(it)
}
true
}
}
}

@ -9,8 +9,6 @@ import io.legado.app.data.entities.Book
import io.legado.app.databinding.ItemBookshelfListBinding
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.invisible
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
class BooksAdapterList(context: Context, private val callBack: CallBack) :
BaseBooksAdapter<ItemBookshelfListBinding>(context) {
@ -61,16 +59,17 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemBookshelfListBinding) {
holder.itemView.apply {
onClick {
setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.open(it)
}
}
onLongClick(returnValue = true) {
setOnLongClickListener {
getItem(holder.layoutPosition)?.let {
callBack.openBookInfo(it)
}
true
}
}
}

@ -19,8 +19,6 @@ import io.legado.app.utils.dp
import io.legado.app.utils.gone
import io.legado.app.utils.visible
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
class ExploreAdapter(context: Context, private val scope: CoroutineScope, val callBack: CallBack) :
RecyclerAdapter<BookSource, ItemFindBookBinding>(context) {
@ -68,7 +66,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
glChild.addView(tv.root)
tv.textView.text = kind.title
if (!kind.url.isNullOrEmpty()) {
tv.textView.onClick {
tv.textView.setOnClickListener {
callBack.openExplore(
item.bookSourceUrl,
kind.title,
@ -95,7 +93,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
override fun registerListener(holder: ItemViewHolder, binding: ItemFindBookBinding) {
binding.apply {
llTitle.onClick {
llTitle.setOnClickListener {
val position = holder.layoutPosition
val oldEx = exIndex
exIndex = if (exIndex == position) -1 else position
@ -106,8 +104,9 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
notifyItemChanged(position, false)
}
}
llTitle.onLongClick {
llTitle.setOnLongClickListener {
showMenu(llTitle, holder.layoutPosition)
true
}
}
}

@ -10,8 +10,6 @@ import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.data.entities.RssSource
import io.legado.app.databinding.ItemRssBinding
import io.legado.app.help.ImageLoader
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.sdk27.coroutines.onLongClick
class RssAdapter(context: Context, val callBack: CallBack) :
RecyclerAdapter<RssSource, ItemRssBinding>(context) {
@ -38,15 +36,16 @@ class RssAdapter(context: Context, val callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemRssBinding) {
binding.apply {
root.onClick {
root.setOnClickListener {
getItemByLayoutPosition(holder.layoutPosition)?.let {
callBack.openRss(it)
}
}
root.onLongClick(returnValue = true) {
root.setOnLongClickListener {
getItemByLayoutPosition(holder.layoutPosition)?.let {
showMenu(ivIcon, it)
}
true
}
}
}

@ -28,7 +28,7 @@ import io.legado.app.utils.getViewModel
import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.startActivity
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
/**
* 订阅界面
@ -106,7 +106,7 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
ItemRssBinding.inflate(layoutInflater, it, false).apply {
tvName.setText(R.string.rule_subscription)
ivIcon.setImageResource(R.drawable.image_legado)
root.onClick {
root.setOnClickListener {
startActivity<RuleSubActivity>()
}
}

@ -24,7 +24,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
private lateinit var viewModel: ReplaceRuleViewModel
@ -134,13 +134,13 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
override fun registerListener(holder: ItemViewHolder, binding: ItemGroupManageBinding) {
binding.apply {
tvEdit.onClick {
tvEdit.setOnClickListener {
getItem(holder.layoutPosition)?.let {
editGroup(it)
}
}
tvDel.onClick {
tvDel.setOnClickListener {
getItem(holder.layoutPosition)?.let { viewModel.delGroup(it) }
}
}

@ -39,7 +39,6 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast
import java.io.File
/**
@ -270,7 +269,7 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
startActivity<ImportReplaceRuleActivity>("dataKey" to dataKey)
}
}.onFailure {
toast("readTextError:${it.localizedMessage}")
toastOnUI("readTextError:${it.localizedMessage}")
}
}
}

@ -16,7 +16,7 @@ import io.legado.app.databinding.ItemReplaceRuleBinding
import io.legado.app.lib.theme.backgroundColor
import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
import io.legado.app.ui.widget.recycler.ItemTouchCallback
import org.jetbrains.anko.sdk27.coroutines.onClick
import java.util.*
@ -147,12 +147,12 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
}
}
}
ivEdit.onClick {
ivEdit.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.edit(it)
}
}
cbName.onClick {
cbName.setOnClickListener {
getItem(holder.layoutPosition)?.let {
if (cbName.isChecked) {
selected.add(it)
@ -162,7 +162,7 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
}
callBack.upCountView()
}
ivMenuMore.onClick {
ivMenuMore.setOnClickListener {
showMenu(ivMenuMore, holder.layoutPosition)
}
}

@ -6,11 +6,7 @@ import androidx.documentfile.provider.DocumentFile
import io.legado.app.App
import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.ReplaceRule
import io.legado.app.utils.FileUtils
import io.legado.app.utils.GSON
import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.writeText
import org.jetbrains.anko.toast
import io.legado.app.utils.*
import java.io.File
class ReplaceRuleViewModel(application: Application) : BaseViewModel(application) {
@ -83,9 +79,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application
FileUtils.createFileIfNotExist(file, "exportReplaceRule.json")
.writeText(json)
}.onSuccess {
context.toast("成功导出至\n${file.absolutePath}")
context.toastOnUI("成功导出至\n${file.absolutePath}")
}.onError {
context.toast("导出失败\n${it.localizedMessage}")
context.toastOnUI("导出失败\n${it.localizedMessage}")
}
}
@ -96,9 +92,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application
doc.createFile("", "exportReplaceRule.json")
?.writeText(context, json)
}.onSuccess {
context.toast("成功导出至\n${doc.uri.path}")
context.toastOnUI("成功导出至\n${doc.uri.path}")
}.onError {
context.toast("导出失败\n${it.localizedMessage}")
context.toastOnUI("导出失败\n${it.localizedMessage}")
}
}

@ -20,10 +20,9 @@ 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 org.jetbrains.anko.displayMetrics
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.selector
import org.jetbrains.anko.toast
import kotlin.math.abs
/**
@ -68,7 +67,7 @@ class ReplaceEditActivity :
viewModel.initData(intent) {
upReplaceView(it)
}
binding.ivHelp.onClick {
binding.ivHelp.setOnClickListener {
showRegexHelp()
}
}
@ -83,7 +82,7 @@ class ReplaceEditActivity :
R.id.menu_save -> {
val rule = getReplaceRule()
if (!rule.isValid()) {
toast(R.string.replace_rule_invalid)
toastOnUI(R.string.replace_rule_invalid)
} else {
viewModel.save(rule) {
postEvent(EventBus.REPLACE_RULE_SAVE, "")

@ -12,10 +12,10 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.data.entities.RssArticle
import io.legado.app.databinding.ItemRssArticleBinding
import io.legado.app.help.ImageLoader
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.gone
import io.legado.app.utils.visible
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.textColorResource
class RssArticlesAdapter(context: Context, callBack: CallBack) :
BaseRssArticlesAdapter<ItemRssArticleBinding>(context, callBack) {
@ -67,15 +67,15 @@ class RssArticlesAdapter(context: Context, callBack: CallBack) :
}.into(imageView)
}
if (item.read) {
tvTitle.textColorResource = R.color.tv_text_summary
tvTitle.setTextColor(context.getCompatColor(R.color.tv_text_summary))
} else {
tvTitle.textColorResource = R.color.primaryText
tvTitle.setTextColor(context.getCompatColor(R.color.primaryText))
}
}
}
override fun registerListener(holder: ItemViewHolder, binding: ItemRssArticleBinding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.readRss(it)
}

@ -12,10 +12,10 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.data.entities.RssArticle
import io.legado.app.databinding.ItemRssArticle1Binding
import io.legado.app.help.ImageLoader
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.gone
import io.legado.app.utils.visible
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.textColorResource
class RssArticlesAdapter1(context: Context, callBack: CallBack) :
BaseRssArticlesAdapter<ItemRssArticle1Binding>(context, callBack) {
@ -67,15 +67,15 @@ class RssArticlesAdapter1(context: Context, callBack: CallBack) :
}.into(imageView)
}
if (item.read) {
tvTitle.textColorResource = R.color.tv_text_summary
tvTitle.setTextColor(context.getCompatColor(R.color.tv_text_summary))
} else {
tvTitle.textColorResource = R.color.primaryText
tvTitle.setTextColor(context.getCompatColor(R.color.primaryText))
}
}
}
override fun registerListener(holder: ItemViewHolder, binding: ItemRssArticle1Binding) {
holder.itemView.onClick {
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.readRss(it)
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save