pull/32/head
kunfei 5 years ago
parent b736fd7ded
commit 70f1082bba
  1. 4
      app/src/main/java/io/legado/app/ui/readbook/config/PaddingConfigDialog.java
  2. 8
      app/src/main/java/io/legado/app/ui/widget/page/ContentTextView.kt

@ -0,0 +1,4 @@
package io.legado.app.ui.readbook.config;
public class PaddingConfigDialog {
}

@ -10,21 +10,21 @@ class ContentTextView : AppCompatTextView {
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
: super(context, attrs, defStyleAttr)
/**
* 获取当前页总字数
*/
fun getCharNum(): Int {
return layout.getLineEnd(getLineNum())
return layout?.getLineEnd(getLineNum()) ?: 0
}
/**
* 获取当前页总行数
*/
fun getLineNum(): Int {
val layout = layout
val topOfLastLine = height - paddingTop - paddingBottom - lineHeight
return layout.getLineForVertical(topOfLastLine)
return layout?.getLineForVertical(topOfLastLine) ?: 0
}
}

Loading…
Cancel
Save