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() }