mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a2a76da248
@ -348,7 +348,10 @@ class EpubFile(var book: Book) {
|
|||||||
durIndex = 0
|
durIndex = 0
|
||||||
while (i < contents.size) {
|
while (i < contents.size) {
|
||||||
val content = contents[i]
|
val content = contents[i]
|
||||||
if (!content.mediaType.toString().contains("htm")) continue
|
if (!content.mediaType.toString().contains("htm")) {
|
||||||
|
i++
|
||||||
|
continue
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 检索到第一章href停止
|
* 检索到第一章href停止
|
||||||
* completeHref可能有fragment(#id) 必须去除
|
* completeHref可能有fragment(#id) 必须去除
|
||||||
|
@ -9,7 +9,6 @@ import androidx.lifecycle.LiveData
|
|||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.VMBaseFragment
|
import io.legado.app.base.VMBaseFragment
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.constant.PreferKey
|
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookGroup
|
import io.legado.app.data.entities.BookGroup
|
||||||
@ -137,7 +136,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
|
|||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
fun configBookshelf() {
|
fun configBookshelf() {
|
||||||
alert(titleResource = R.string.bookshelf_layout) {
|
alert(titleResource = R.string.bookshelf_layout) {
|
||||||
val bookshelfLayout = getPrefInt(PreferKey.bookshelfLayout)
|
val bookshelfLayout = AppConfig.bookshelfLayout
|
||||||
val bookshelfSort = AppConfig.bookshelfSort
|
val bookshelfSort = AppConfig.bookshelfSort
|
||||||
val alertBinding =
|
val alertBinding =
|
||||||
DialogBookshelfConfigBinding.inflate(layoutInflater)
|
DialogBookshelfConfigBinding.inflate(layoutInflater)
|
||||||
|
@ -11,7 +11,6 @@ import androidx.fragment.app.FragmentManager
|
|||||||
import androidx.fragment.app.FragmentStatePagerAdapter
|
import androidx.fragment.app.FragmentStatePagerAdapter
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.PreferKey
|
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookGroup
|
import io.legado.app.data.entities.BookGroup
|
||||||
@ -126,7 +125,7 @@ class BookshelfFragment1() : BaseBookshelfFragment(R.layout.fragment_bookshelf1)
|
|||||||
override fun onTabUnselected(tab: TabLayout.Tab) = Unit
|
override fun onTabUnselected(tab: TabLayout.Tab) = Unit
|
||||||
|
|
||||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||||
putPrefInt(PreferKey.saveTabPosition, tab.position)
|
AppConfig.saveTabPosition = tab.position
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun gotoTop() {
|
override fun gotoTop() {
|
||||||
|
@ -13,7 +13,6 @@ import io.legado.app.R
|
|||||||
import io.legado.app.base.BaseFragment
|
import io.legado.app.base.BaseFragment
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.constant.PreferKey
|
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookGroup
|
import io.legado.app.data.entities.BookGroup
|
||||||
@ -52,9 +51,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
|||||||
|
|
||||||
private val binding by viewBinding(FragmentBooksBinding::bind)
|
private val binding by viewBinding(FragmentBooksBinding::bind)
|
||||||
private val activityViewModel by activityViewModels<MainViewModel>()
|
private val activityViewModel by activityViewModels<MainViewModel>()
|
||||||
private val bookshelfLayout by lazy {
|
private val bookshelfLayout by lazy { AppConfig.bookshelfLayout }
|
||||||
getPrefInt(PreferKey.bookshelfLayout)
|
|
||||||
}
|
|
||||||
private val booksAdapter: BaseBooksAdapter<*> by lazy {
|
private val booksAdapter: BaseBooksAdapter<*> by lazy {
|
||||||
if (bookshelfLayout == 0) {
|
if (bookshelfLayout == 0) {
|
||||||
BooksAdapterList(requireContext(), this)
|
BooksAdapterList(requireContext(), this)
|
||||||
|
@ -12,7 +12,6 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.constant.PreferKey
|
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookGroup
|
import io.legado.app.data.entities.BookGroup
|
||||||
@ -53,9 +52,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val binding by viewBinding(FragmentBookshelf2Binding::bind)
|
private val binding by viewBinding(FragmentBookshelf2Binding::bind)
|
||||||
private val bookshelfLayout by lazy {
|
private val bookshelfLayout by lazy { AppConfig.bookshelfLayout }
|
||||||
getPrefInt(PreferKey.bookshelfLayout)
|
|
||||||
}
|
|
||||||
private val booksAdapter: BaseBooksAdapter<*> by lazy {
|
private val booksAdapter: BaseBooksAdapter<*> by lazy {
|
||||||
if (bookshelfLayout == 0) {
|
if (bookshelfLayout == 0) {
|
||||||
BooksAdapterList(requireContext(), this)
|
BooksAdapterList(requireContext(), this)
|
||||||
@ -123,8 +120,10 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
private fun initBooksData() {
|
private fun initBooksData() {
|
||||||
if (groupId == -100L) {
|
if (groupId == -100L) {
|
||||||
|
if (isAdded) {
|
||||||
binding.titleBar.title = getString(R.string.bookshelf)
|
binding.titleBar.title = getString(R.string.bookshelf)
|
||||||
binding.refreshLayout.isEnabled = true
|
binding.refreshLayout.isEnabled = true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
bookGroups.firstOrNull {
|
bookGroups.firstOrNull {
|
||||||
groupId == it.groupId
|
groupId == it.groupId
|
||||||
@ -156,6 +155,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
}.flowOn(Dispatchers.Default).catch {
|
}.flowOn(Dispatchers.Default).catch {
|
||||||
AppLog.put("书架更新出错", it)
|
AppLog.put("书架更新出错", it)
|
||||||
}.conflate().collect { list ->
|
}.conflate().collect { list ->
|
||||||
|
if (isAdded) {
|
||||||
books = list
|
books = list
|
||||||
booksAdapter.notifyDataSetChanged()
|
booksAdapter.notifyDataSetChanged()
|
||||||
binding.tvEmptyMsg.isGone = getItemCount() > 0
|
binding.tvEmptyMsg.isGone = getItemCount() > 0
|
||||||
@ -163,6 +163,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun back(): Boolean {
|
fun back(): Boolean {
|
||||||
if (groupId != -100L) {
|
if (groupId != -100L) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.ag2s.epublib.domain;
|
package me.ag2s.epublib.domain;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import me.ag2s.epublib.util.StringUtil;
|
import me.ag2s.epublib.util.StringUtil;
|
||||||
@ -60,7 +60,7 @@ public class MediaTypes {
|
|||||||
SMIL, PLS, JAVASCRIPT, MP3, MP4, OGG, UNKNOWN
|
SMIL, PLS, JAVASCRIPT, MP3, MP4, OGG, UNKNOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Map<String, MediaType> mediaTypesByName = new HashMap<>();
|
public static final Map<String, MediaType> mediaTypesByName = new LinkedHashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (MediaType mediaType : mediaTypes) {
|
for (MediaType mediaType : mediaTypes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user