feat: 优化代码

pull/105/head
kunfei 5 years ago
parent 817de1ce89
commit c8179fa59a
  1. 15
      app/src/main/java/io/legado/app/ui/download/DownloadViewModel.kt

@ -3,8 +3,11 @@ package io.legado.app.ui.download
import android.app.Application import android.app.Application
import android.net.Uri import android.net.Uri
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.help.BookHelp
import io.legado.app.utils.FileUtils import io.legado.app.utils.FileUtils
import io.legado.app.utils.isContentPath import io.legado.app.utils.isContentPath
import java.io.File import java.io.File
@ -41,4 +44,16 @@ class DownloadViewModel(application: Application) : BaseViewModel(application) {
} }
private fun getAllContents(book: Book): String {
val stringBuilder = StringBuilder()
stringBuilder.append(book.name)
.append("\n")
.append(context.getString(R.string.author_show, book.author))
App.db.bookChapterDao().getChapterList(book.bookUrl).forEach { chapter ->
BookHelp.getContent(book, chapter)?.let {
stringBuilder.append("\n").append(it)
}
}
return stringBuilder.toString()
}
} }
Loading…
Cancel
Save