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. 14
      app/src/main/res/layout/dialog_chapter_change_source.xml

@ -1,13 +1,13 @@
package io.legado.app.ui.book.changesource package io.legado.app.ui.book.changesource
import android.content.DialogInterface
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.*
import android.view.MenuItem import android.view.KeyEvent.ACTION_UP
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R import io.legado.app.R
@ -35,6 +35,7 @@ import kotlinx.coroutines.launch
class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_change_source), class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_change_source),
Toolbar.OnMenuItemClickListener, Toolbar.OnMenuItemClickListener,
DialogInterface.OnKeyListener,
ChangeChapterSourceAdapter.CallBack, ChangeChapterSourceAdapter.CallBack,
ChangeChapterTocAdapter.Callback { ChangeChapterTocAdapter.Callback {
@ -78,6 +79,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
dialog?.setOnKeyListener(this)
} }
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { 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 { interface CallBack {
val oldBook: Book? val oldBook: Book?
fun changeTo(source: BookSource, book: Book) fun changeTo(source: BookSource, book: Book)

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

Loading…
Cancel
Save