Horis 1 سال پیش
والد
کامیت
118840d99d
1فایلهای تغییر یافته به همراه7 افزوده شده و 7 حذف شده
  1. 7 7
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt

+ 7 - 7
app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt

@@ -61,6 +61,7 @@ import kotlinx.coroutines.flow.flowOn
 import kotlinx.coroutines.flow.map
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext
+import splitties.init.appCtx
 import kotlin.math.max
 
 /**
@@ -440,22 +441,21 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
                     alertDialog.hide()
                     return@apply
                 }
-                val text = etInputScope.text
-                if (!verificationField(text.toString())) {
-                    etInputScope.error =
-                        applicationContext.getString(R.string.error_scope_input)//"请输入正确的范围"
+                val epubScope = etInputScope.text.toString()
+                if (!verificationField(epubScope)) {
+                    etInputScope.error = appCtx.getString(R.string.error_scope_input)//"请输入正确的范围"
                     return@apply
                 }
                 etInputScope.error = null
-                val toInt = etEpubSize.text.toString().toInt()
+                val epubSize = etEpubSize.text.toString().toIntOrNull() ?: 1
                 adapter.getItem(position)?.let { book ->
                     startService<ExportBookService> {
                         action = IntentAction.start
                         putExtra("bookUrl", book.bookUrl)
                         putExtra("exportType", "epub")
                         putExtra("exportPath", path)
-                        putExtra("epubSize", toInt)
-                        putExtra("epubScope", text.toString())
+                        putExtra("epubSize", epubSize)
+                        putExtra("epubScope", epubScope)
                     }
                 }
                 alertDialog.hide()