|
|
@ -8,6 +8,7 @@ import io.legado.app.base.BaseViewModel |
|
|
|
import io.legado.app.data.entities.ReplaceRule |
|
|
|
import io.legado.app.data.entities.ReplaceRule |
|
|
|
import io.legado.app.help.FileHelp |
|
|
|
import io.legado.app.help.FileHelp |
|
|
|
import io.legado.app.help.storage.Backup |
|
|
|
import io.legado.app.help.storage.Backup |
|
|
|
|
|
|
|
import io.legado.app.help.storage.Restore |
|
|
|
import io.legado.app.utils.GSON |
|
|
|
import io.legado.app.utils.GSON |
|
|
|
import io.legado.app.utils.splitNotBlank |
|
|
|
import io.legado.app.utils.splitNotBlank |
|
|
|
import org.jetbrains.anko.toast |
|
|
|
import org.jetbrains.anko.toast |
|
|
@ -17,7 +18,7 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application |
|
|
|
|
|
|
|
|
|
|
|
fun importSource(text: String, toast: (msg: String) -> Unit) { |
|
|
|
fun importSource(text: String, toast: (msg: String) -> Unit) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
|
|
|
|
Restore.importOldReplaceRule(text) |
|
|
|
}.onError { |
|
|
|
}.onError { |
|
|
|
toast(it.localizedMessage ?: "ERROR") |
|
|
|
toast(it.localizedMessage ?: "ERROR") |
|
|
|
}.onSuccess { |
|
|
|
}.onSuccess { |
|
|
|