From 34a75339ea87dabe1bf416e4cc620359824cb409 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 25 Apr 2020 16:11:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/config/PageKeyDialog.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt index 28a46b7f2..d85aae294 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt @@ -8,6 +8,7 @@ import io.legado.app.constant.PreferKey import io.legado.app.utils.getPrefInt import io.legado.app.utils.hideSoftInput import io.legado.app.utils.putPrefInt +import io.legado.app.utils.removePref import kotlinx.android.synthetic.main.dialog_page_key.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -19,11 +20,17 @@ class PageKeyDialog(context: Context) : Dialog(context, R.style.AppTheme_AlertDi et_prev.setText(context.getPrefInt(PreferKey.prevKey).toString()) et_next.setText(context.getPrefInt(PreferKey.nextKey).toString()) tv_ok.onClick { - et_prev.text?.let { - context.putPrefInt(PreferKey.prevKey, it.toString().toInt()) + val prevKey = et_prev.text?.toString() + if (prevKey.isNullOrEmpty()) { + context.removePref(PreferKey.prevKey) + } else { + context.putPrefInt(PreferKey.prevKey, prevKey.toInt()) } - et_next.text?.let { - context.putPrefInt(PreferKey.nextKey, it.toString().toInt()) + val nextKey = et_next.text?.toString() + if (nextKey.isNullOrEmpty()) { + context.removePref(PreferKey.nextKey) + } else { + context.putPrefInt(PreferKey.nextKey, nextKey.toInt()) } dismiss() }