Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Nov 17, 2023
2 parents 7351429 + 698314a commit cff73c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 8 additions & 5 deletions app/src/main/java/io/legado/app/service/ExportBookService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import java.io.FileOutputStream
import java.nio.charset.Charset
import java.util.concurrent.ConcurrentHashMap
import kotlin.coroutines.coroutineContext
import kotlin.math.min

/**
* 导出书籍服务
Expand Down Expand Up @@ -363,7 +364,7 @@ class ExportBookService : BaseService() {
* @author Discut
*/
@SuppressLint("ObsoleteSdkInt")
private fun paresScope(scope: String): IntArray {
private fun paresScope(scope: String): Set<Int> {
val split = scope.split(",")

@Suppress("RemoveExplicitTypeArguments")
Expand All @@ -387,7 +388,7 @@ class ExportBookService : BaseService() {
for (i in left..right)
result.add(i - 1)
}
return result.toIntArray()
return result
}

/**
Expand Down Expand Up @@ -702,7 +703,7 @@ class ExportBookService : BaseService() {
* @param scope 导出范围
* @param size epub 文件包含最大章节数
*/
inner class CustomExporter(private val scope: IntArray, private val size: Int) {
inner class CustomExporter(private var scope: Set<Int>, private val size: Int) {

/**
* 导出Epub
Expand All @@ -717,6 +718,8 @@ class ExportBookService : BaseService() {
exportMsg.remove(book.bookUrl)
postEvent(EventBus.EXPORT_BOOK, book.bookUrl)
val currentTimeMillis = System.currentTimeMillis()
val count = appDb.bookChapterDao.getChapterCount(book.bookUrl)
scope = scope.filter { it < count }.toHashSet()
when (path.isContentScheme()) {
true -> {
val uri = Uri.parse(path)
Expand Down Expand Up @@ -812,7 +815,7 @@ class ExportBookService : BaseService() {
val contentProcessor = ContentProcessor.get(book.name, book.origin)
var chapterList: MutableList<BookChapter> = ArrayList()
appDb.bookChapterDao.getChapterList(book.bookUrl).forEachIndexed { index, chapter ->
if (scope.indexOf(index) >= 0) {
if (scope.contains(index)) {
chapterList.add(chapter)
}
if (scope.size == chapterList.size) {
Expand All @@ -825,7 +828,7 @@ class ExportBookService : BaseService() {
}
chapterList = chapterList.subList(
epubBookIndex * size,
if ((epubBookIndex + 1) * size > scope.size) scope.size else (epubBookIndex + 1) * size
min(scope.size, (epubBookIndex + 1) * size)
)
chapterList.forEachIndexed { index, chapter ->
coroutineContext.ensureActive()
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/io/legado/app/ui/font/FontAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Build
import android.view.ViewGroup
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.constant.AppLog
import io.legado.app.databinding.ItemFontBinding
import io.legado.app.utils.*
import java.io.File
Expand Down Expand Up @@ -45,7 +46,7 @@ class FontAdapter(context: Context, curFilePath: String, val callBack: CallBack)
tvFont.typeface = typeface
}.onFailure {
it.printOnDebug()
context.toastOnUi("Read ${item.name} Error: ${it.localizedMessage}")
AppLog.put("读取字体 ${item.name} 出错\n${it.localizedMessage}", it, true)
}
tvFont.text = item.name
root.setOnClickListener { callBack.onFontSelect(item) }
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/dialog_select_section_export.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
android:id="@+id/cb_all_export"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_marginStart="6dp"
android:layout_marginEnd="16dp" />

Expand All @@ -43,6 +44,7 @@
android:id="@+id/cb_select_export"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_marginStart="6dp"
android:layout_marginEnd="16dp" />

Expand Down Expand Up @@ -71,8 +73,8 @@
android:id="@+id/et_epub_filename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:enabled="false"
android:inputType="text"
tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" />

</io.legado.app.ui.widget.text.TextInputLayout>
Expand Down

0 comments on commit cff73c6

Please sign in to comment.