pull/1649/head
kunfei 3 years ago
parent 428b05c739
commit 9946a7f105
  1. 22
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt
  2. 24
      app/src/main/res/layout/dialog_chapter_change_source.xml

@ -1,13 +1,13 @@
package io.legado.app.ui.book.changesource
import android.content.DialogInterface
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.*
import android.view.KeyEvent.ACTION_UP
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
@ -35,6 +35,7 @@ import kotlinx.coroutines.launch
class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_change_source),
Toolbar.OnMenuItemClickListener,
DialogInterface.OnKeyListener,
ChangeChapterSourceAdapter.CallBack,
ChangeChapterTocAdapter.Callback {
@ -78,6 +79,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
override fun onStart() {
super.onStart()
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
dialog?.setOnKeyListener(this)
}
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
@ -325,6 +327,18 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
}
}
override fun onKey(dialog: DialogInterface?, keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> event?.let {
if (it.action == ACTION_UP && binding.clToc.isVisible) {
binding.clToc.gone()
return true
}
}
}
return false
}
interface CallBack {
val oldBook: Book?
fun changeTo(source: BookSource, book: Book)

@ -42,13 +42,23 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tool_bar">
<androidx.constraintlayout.utils.widget.ImageFilterView
android:id="@+id/iv_hide_toc"
<FrameLayout
android:id="@+id/fl_hide_toc"
android:layout_width="match_parent"
android:layout_height="36dp"
android:src="@drawable/ic_arrow_down"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/primaryText" />
android:layout_height="wrap_content"
android:background="@color/background"
android:elevation="4dp"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.utils.widget.ImageFilterView
android:id="@+id/iv_hide_toc"
android:layout_width="match_parent"
android:layout_height="36dp"
android:src="@drawable/ic_arrow_down"
android:background="?android:attr/selectableItemBackground"
app:tint="@color/primaryText" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_toc"
@ -56,7 +66,7 @@
android:layout_height="0dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iv_hide_toc" />
app:layout_constraintTop_toBottomOf="@+id/fl_hide_toc" />
<io.legado.app.ui.widget.anima.RotateLoading
android:id="@+id/loading_toc"

Loading…
Cancel
Save