feat: 优化代码

pull/103/head
kunfei 5 years ago
parent 6129c814ca
commit 84155570df
  1. 4
      app/src/main/java/io/legado/app/lib/theme/ATHUtils.kt
  2. 14
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt
  3. 1
      app/src/main/res/values/strings.xml
  4. 6
      app/src/main/res/xml/pref_config_read.xml

@ -8,10 +8,6 @@ import androidx.annotation.AttrRes
*/
object ATHUtils {
fun isWindowBackgroundDark(context: Context): Boolean {
return !ColorUtils.isColorLight(resolveColor(context, android.R.attr.windowBackground))
}
@JvmOverloads
fun resolveColor(context: Context, @AttrRes attr: Int, fallback: Int = 0): Int {
val a = context.theme.obtainStyledAttributes(intArrayOf(attr))

@ -45,7 +45,7 @@ abstract class PageDelegate(protected val pageView: PageView) {
protected var atTop: Boolean = false
protected var atBottom: Boolean = false
private var snackbar: Snackbar? = null
private var snackBar: Snackbar? = null
private val scroller: Scroller by lazy {
Scroller(
@ -291,10 +291,10 @@ abstract class PageDelegate(protected val pageView: PageView) {
direction = Direction.PREV
val hasPrev = pageView.pageFactory?.hasPrev() == true
if (!hasPrev) {
snackbar ?: let {
snackbar = pageView.snackbar("没有上一页")
snackBar ?: let {
snackBar = pageView.snackbar("没有上一页")
}
snackbar?.let {
snackBar?.let {
if (!it.isShown) {
it.setText("没有上一页")
it.show()
@ -309,10 +309,10 @@ abstract class PageDelegate(protected val pageView: PageView) {
direction = Direction.NEXT
val hasNext = pageView.pageFactory?.hasNext() == true
if (!hasNext) {
snackbar ?: let {
snackbar = pageView.snackbar("没有下一页")
snackBar ?: let {
snackBar = pageView.snackbar("没有下一页")
}
snackbar?.let {
snackBar?.let {
if (!it.isShown) {
it.setText("没有下一页")
it.show()

@ -609,4 +609,5 @@
<string name="chage_icon_error">图标为矢量图标,Android8.0以前不支持</string>
<string name="aloud_config">朗读设置</string>
<string name="main_activity">主界面</string>
<string name="selectText">选择文本</string>
</resources>

@ -40,6 +40,12 @@
android:key="volumeKeyPageOnPlay"
app:iconSpaceReserved="false" />
<io.legado.app.lib.theme.prefs.ATESwitchPreference
android:defaultValue="true"
android:title="@string/selectText"
android:key="selectText"
app:iconSpaceReserved="false" />
<Preference
android:key="customPageKey"
android:title="@string/custom_page_key"

Loading…
Cancel
Save