feat: 优化代码

pull/105/head
kunfei 5 years ago
parent 57db88335a
commit 38911b6d93
  1. 2
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  2. 2
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt
  4. 1
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/read/page/DataSource.kt
  6. 1
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  7. 1
      app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt
  8. 2
      app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChapter.kt
  9. 11
      app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChar.kt
  10. 6
      app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt
  11. 3
      app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt

@ -23,7 +23,7 @@ import io.legado.app.help.MediaHelp
import io.legado.app.receiver.MediaButtonReceiver
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.read.page.TextChapter
import io.legado.app.ui.book.read.page.entities.TextChapter
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.postEvent

@ -12,7 +12,7 @@ import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.WebBook
import io.legado.app.service.BaseReadAloudService
import io.legado.app.ui.book.read.page.ChapterProvider
import io.legado.app.ui.book.read.page.TextChapter
import io.legado.app.ui.book.read.page.entities.TextChapter
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.Main

@ -9,6 +9,8 @@ import androidx.core.text.HtmlCompat.FROM_HTML_MODE_COMPACT
import io.legado.app.App
import io.legado.app.data.entities.BookChapter
import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.book.read.page.entities.TextChapter
import io.legado.app.ui.book.read.page.entities.TextPage
object ChapterProvider {

@ -11,6 +11,7 @@ import io.legado.app.R
import io.legado.app.constant.AppConst.TIME_FORMAT
import io.legado.app.constant.PreferKey
import io.legado.app.help.ReadBookConfig
import io.legado.app.ui.book.read.page.entities.TextPage
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.view_book_page.view.*
import org.jetbrains.anko.sdk27.listeners.onScrollChange

@ -1,5 +1,7 @@
package io.legado.app.ui.book.read.page
import io.legado.app.ui.book.read.page.entities.TextChapter
interface DataSource {
val isScrollDelegate: Boolean

@ -10,6 +10,7 @@ import io.legado.app.constant.PreferKey
import io.legado.app.help.ReadBookConfig
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.page.delegate.*
import io.legado.app.ui.book.read.page.entities.TextChapter
import io.legado.app.utils.activity
import io.legado.app.utils.getPrefInt

@ -1,6 +1,7 @@
package io.legado.app.ui.book.read.page
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.page.entities.TextPage
class TextPageFactory(dataSource: DataSource) : PageFactory<TextPage>(dataSource) {

@ -1,4 +1,4 @@
package io.legado.app.ui.book.read.page
package io.legado.app.ui.book.read.page.entities
import android.text.SpannableStringBuilder
import kotlin.math.min

@ -0,0 +1,11 @@
package io.legado.app.ui.book.read.page.entities
import android.graphics.Point
data class TextChar(
val charData: Char,
var selected: Boolean = false,
var isReadAloud: Boolean = false,
val leftBottomPosition: Point,
val rightTopPosition: Point
)

@ -0,0 +1,6 @@
package io.legado.app.ui.book.read.page.entities
data class TextLine(
val textChars: List<TextChar>,
val lineBottom: Int
)

@ -1,9 +1,10 @@
package io.legado.app.ui.book.read.page
package io.legado.app.ui.book.read.page.entities
import android.text.Spannable
import android.text.SpannableStringBuilder
import io.legado.app.App
import io.legado.app.R
import io.legado.app.ui.book.read.page.ChapterProvider
data class TextPage(
val index: Int,
Loading…
Cancel
Save