pull/1738/head
kunfei 3 years ago
parent b62839512e
commit c1daabd898
  1. 12
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt
  2. 22
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt
  3. 13
      app/src/main/res/layout/dialog_book_change_source.xml
  4. 5
      app/src/main/res/menu/change_source.xml
  5. 1
      app/src/main/res/values-es-rES/strings.xml
  6. 1
      app/src/main/res/values-ja-rJP/strings.xml
  7. 1
      app/src/main/res/values-pt-rBR/strings.xml
  8. 1
      app/src/main/res/values-zh-rHK/strings.xml
  9. 1
      app/src/main/res/values-zh-rTW/strings.xml
  10. 1
      app/src/main/res/values-zh/strings.xml
  11. 1
      app/src/main/res/values/strings.xml

@ -10,7 +10,6 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -88,7 +87,6 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
}
private fun initRecyclerView() {
binding.recyclerView.layoutManager = LinearLayoutManager(context)
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
binding.recyclerView.adapter = adapter
adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
@ -167,6 +165,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.menu_scroll_to_dur -> scrollToDurSource()
R.id.menu_check_author -> {
AppConfig.changeSourceCheckAuthor = !item.isChecked
item.isChecked = !item.isChecked
@ -198,6 +197,15 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
return false
}
private fun scrollToDurSource() {
adapter.getItems().forEachIndexed { index, searchBook ->
if (searchBook.bookUrl == bookUrl) {
binding.recyclerView.scrollToPosition(index)
return
}
}
}
override fun changeTo(searchBook: SearchBook) {
changeSource(searchBook)
dismissAllowingStateLoss()

@ -59,6 +59,12 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
registerForActivityResult(StartActivityContract(BookSourceEditActivity::class.java)) {
viewModel.startSearch()
}
private val searchBookAdapter by lazy {
ChangeChapterSourceAdapter(requireContext(), viewModel, this)
}
private val tocAdapter by lazy {
ChangeChapterTocAdapter(requireContext(), this)
}
private val tocSuccess: (toc: List<BookChapter>) -> Unit = {
tocAdapter.durChapterIndex =
BookHelp.getDurChapter(viewModel.chapterIndex, viewModel.chapterTitle, it)
@ -71,12 +77,6 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
callBack?.replaceContent(it)
dismissAllowingStateLoss()
}
private val searchBookAdapter by lazy {
ChangeChapterSourceAdapter(requireContext(), viewModel, this)
}
private val tocAdapter by lazy {
ChangeChapterTocAdapter(requireContext(), this)
}
private var searchBook: SearchBook? = null
override fun onStart() {
@ -199,6 +199,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.menu_scroll_to_dur -> scrollToDurSource()
R.id.menu_check_author -> {
AppConfig.changeSourceCheckAuthor = !item.isChecked
item.isChecked = !item.isChecked
@ -230,6 +231,15 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
return false
}
private fun scrollToDurSource() {
searchBookAdapter.getItems().forEachIndexed { index, searchBook ->
if (searchBook.bookUrl == bookUrl) {
binding.recyclerView.scrollToPosition(index)
return
}
}
}
override fun openToc(searchBook: SearchBook) {
this.searchBook = searchBook
tocAdapter.setItems(null)

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background">
android:background="@color/background"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/tool_bar"
@ -13,10 +13,10 @@
android:background="@color/background_menu"
android:elevation="5dp"
android:theme="?attr/actionBarStyle"
app:titleTextAppearance="@style/ToolbarTitle"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:displayHomeAsUp="false"
app:fitStatusBar="false" />
app:fitStatusBar="false"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:titleTextAppearance="@style/ToolbarTitle" />
<io.legado.app.ui.widget.anima.RefreshProgressBar
android:id="@+id/refresh_progress_bar"
@ -26,6 +26,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>

@ -18,6 +18,11 @@
app:showAsAction="always"
tools:ignore="AlwaysShowAction" />
<item
android:id="@+id/menu_scroll_to_dur"
android:title="@string/scroll_to_dur_source"
app:showAsAction="never" />
<item
android:id="@+id/menu_source_manage"
android:title="@string/book_source_manage"

@ -961,5 +961,6 @@
<string name="only_wifi_summary">仅在wifi下加载网络封面</string>
<string name="cover_rule">封面规则</string>
<string name="cover_rule_summary">进入详情页时使用封面规则重新获取封面</string>
<string name="scroll_to_dur_source">定位到当前书源</string>
<!-- string end -->
</resources>

@ -964,5 +964,6 @@
<string name="only_wifi_summary">仅在wifi下加载网络封面</string>
<string name="cover_rule">封面规则</string>
<string name="cover_rule_summary">进入详情页时使用封面规则重新获取封面</string>
<string name="scroll_to_dur_source">定位到当前书源</string>
<!-- string end -->
</resources>

@ -964,5 +964,6 @@
<string name="only_wifi_summary">仅在wifi下加载网络封面</string>
<string name="cover_rule">封面规则</string>
<string name="cover_rule_summary">进入详情页时使用封面规则重新获取封面</string>
<string name="scroll_to_dur_source">定位到当前书源</string>
<!-- string end -->
</resources>

@ -961,5 +961,6 @@
<string name="only_wifi_summary">仅在wifi下加载网络封面</string>
<string name="cover_rule">封面规则</string>
<string name="cover_rule_summary">进入详情页时使用封面规则重新获取封面</string>
<string name="scroll_to_dur_source">定位到当前书源</string>
<!-- string end -->
</resources>

@ -963,5 +963,6 @@
<string name="only_wifi_summary">仅在wifi下加载网络封面</string>
<string name="cover_rule">封面规则</string>
<string name="cover_rule_summary">进入详情页时使用封面规则重新获取封面</string>
<string name="scroll_to_dur_source">定位到当前书源</string>
<!-- string end -->
</resources>

@ -963,5 +963,6 @@
<string name="only_wifi_summary">仅在wifi下加载网络封面</string>
<string name="cover_rule">封面规则</string>
<string name="cover_rule_summary">进入详情页时使用封面规则重新获取封面</string>
<string name="scroll_to_dur_source">定位到当前书源</string>
<!-- string end -->
</resources>

@ -964,5 +964,6 @@
<string name="only_wifi_summary">仅在wifi下加载网络封面</string>
<string name="cover_rule">封面规则</string>
<string name="cover_rule_summary">进入详情页时使用封面规则重新获取封面</string>
<string name="scroll_to_dur_source">定位到当前书源</string>
<!-- string end -->
</resources>

Loading…
Cancel
Save