pull/306/head
gedoor 4 years ago
parent a60c9824ac
commit b7ac1f4be3
  1. 4
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt
  2. 14
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
  3. 6
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleViewModel.kt
  4. 4
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt
  5. 3
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
  6. 2
      app/src/main/res/values-zh-rHK/strings.xml
  7. 2
      app/src/main/res/values-zh-rTW/strings.xml
  8. 2
      app/src/main/res/values-zh/strings.xml
  9. 2
      app/src/main/res/values/strings.xml

@ -78,7 +78,7 @@ class ImportBookSourceActivity : VMBaseActivity<ImportBookSourceViewModel>(
}
else -> {
rotate_loading.hide()
toast("格式不对")
toast(R.string.wrong_format)
finish()
}
}
@ -86,7 +86,7 @@ class ImportBookSourceActivity : VMBaseActivity<ImportBookSourceViewModel>(
}
private fun errorDialog(msg: String) {
alert("导入出错", msg) {
alert(getString(R.string.error), msg) {
okButton { }
}.show().applyTint().setOnDismissListener {
finish()

@ -6,14 +6,13 @@ import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.MutableLiveData
import com.jayway.jsonpath.JsonPath
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.BookSource
import io.legado.app.help.http.HttpHelper
import io.legado.app.help.storage.OldRule
import io.legado.app.help.storage.Restore
import io.legado.app.utils.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.File
class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
@ -42,12 +41,11 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
if (content != null) {
importSource(content)
} else {
withContext(Dispatchers.Main) {
errorLiveData.postValue("打开文件出错")
}
errorLiveData.postValue(context.getString(R.string.error_read_file))
}
}.onError {
errorLiveData.postValue(it.localizedMessage ?: "打开文件出错")
it.printStackTrace()
errorLiveData.postValue(context.getString(R.string.error_read_file))
}
}
@ -80,7 +78,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
text1.isAbsUrl() -> {
importSourceUrl(text1)
}
else -> throw Exception("格式不对")
else -> throw Exception(context.getString(R.string.wrong_format))
}
}.onError {
it.printStackTrace()
@ -93,7 +91,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
private fun importSourceUrl(url: String) {
HttpHelper.simpleGet(url, "UTF-8").let { body ->
if (body == null) {
throw Exception("访问网站失败")
throw Exception(context.getString(R.string.error_get_data))
}
val items: List<Map<String, Any>> = Restore.jsonPath.parse(body).read("$")
for (item in items) {

@ -4,6 +4,7 @@ import android.app.Application
import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.MutableLiveData
import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.ReplaceRule
import io.legado.app.help.http.HttpHelper
@ -36,10 +37,11 @@ class ImportReplaceRuleViewModel(app: Application) : BaseViewModel(app) {
if (content != null) {
import(content)
} else {
errorLiveData.postValue("打开文件出错")
errorLiveData.postValue(context.getString(R.string.error_read_file))
}
}.onError {
errorLiveData.postValue(it.localizedMessage ?: "打开文件出错")
it.printStackTrace()
errorLiveData.postValue(context.getString(R.string.error_read_file))
}
}

@ -78,7 +78,7 @@ class ImportRssSourceActivity : VMBaseActivity<ImportRssSourceViewModel>(
}
else -> {
rotate_loading.hide()
toast("格式不对")
toast(R.string.wrong_format)
finish()
}
}
@ -86,7 +86,7 @@ class ImportRssSourceActivity : VMBaseActivity<ImportRssSourceViewModel>(
}
private fun errorDialog(msg: String) {
alert("导入出错", msg) {
alert(getString(R.string.error), msg) {
okButton { }
}.show().applyTint().setOnDismissListener {
finish()

@ -6,6 +6,7 @@ import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.MutableLiveData
import com.jayway.jsonpath.JsonPath
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.RssSource
import io.legado.app.help.http.HttpHelper
@ -76,7 +77,7 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
text1.isAbsUrl() -> {
importSourceUrl(text1)
}
else -> throw Exception("格式不对")
else -> throw Exception(context.getString(R.string.wrong_format))
}
}.onError {
errorLiveData.postValue("ImportError:${it.localizedMessage}")

@ -739,4 +739,6 @@
<string name="night_bottom_bar_too_light">夜间底栏不能太亮</string>
<string name="accent_background_diff">强调色不能和背景颜色相似</string>
<string name="accent_text_diff">强调色不能和文字颜色相似</string>
<string name="wrong_format">格式不对</string>
<string name="error">错误</string>
</resources>

@ -739,5 +739,7 @@
<string name="night_bottom_bar_too_light">夜间底栏不能太亮</string>
<string name="accent_background_diff">强调色不能和背景颜色相似</string>
<string name="accent_text_diff">强调色不能和文字颜色相似</string>
<string name="wrong_format">格式不对</string>
<string name="error">错误</string>
</resources>

@ -739,4 +739,6 @@
<string name="night_bottom_bar_too_light">夜间底栏不能太亮</string>
<string name="accent_background_diff">强调色不能和背景颜色相似</string>
<string name="accent_text_diff">强调色不能和文字颜色相似</string>
<string name="wrong_format">格式不对</string>
<string name="error">错误</string>
</resources>

@ -740,5 +740,7 @@
<string name="night_bottom_bar_too_light">夜间底栏不能太亮</string>
<string name="accent_background_diff">强调色不能和背景颜色相似</string>
<string name="accent_text_diff">强调色不能和文字颜色相似</string>
<string name="wrong_format">格式不对</string>
<string name="error">错误</string>
</resources>
Loading…
Cancel
Save