添加批量换源
This commit is contained in:
@@ -169,6 +169,7 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
|
|||||||
R.id.menu_update_disable ->
|
R.id.menu_update_disable ->
|
||||||
viewModel.upCanUpdate(adapter.selectedBooks(), false)
|
viewModel.upCanUpdate(adapter.selectedBooks(), false)
|
||||||
R.id.menu_add_to_group -> selectGroup(addToGroupRequestCode, 0)
|
R.id.menu_add_to_group -> selectGroup(addToGroupRequestCode, 0)
|
||||||
|
R.id.menu_change_source -> showDialogFragment<SourcePickerDialog>()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package io.legado.app.ui.book.arrange
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.widget.SearchView
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import io.legado.app.R
|
||||||
|
import io.legado.app.base.BaseDialogFragment
|
||||||
|
import io.legado.app.base.adapter.ItemViewHolder
|
||||||
|
import io.legado.app.base.adapter.RecyclerAdapter
|
||||||
|
import io.legado.app.data.entities.BookSource
|
||||||
|
import io.legado.app.databinding.DialogSourcePickerBinding
|
||||||
|
import io.legado.app.databinding.ItemTextBinding
|
||||||
|
import io.legado.app.lib.theme.primaryColor
|
||||||
|
import io.legado.app.lib.theme.primaryTextColor
|
||||||
|
import io.legado.app.utils.applyTint
|
||||||
|
import io.legado.app.utils.dpToPx
|
||||||
|
import io.legado.app.utils.setLayout
|
||||||
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
|
import splitties.views.rightPadding
|
||||||
|
|
||||||
|
class SourcePickerDialog : BaseDialogFragment(R.layout.dialog_source_picker) {
|
||||||
|
|
||||||
|
private val binding by viewBinding(DialogSourcePickerBinding::bind)
|
||||||
|
private val searchView: SearchView by lazy {
|
||||||
|
binding.toolBar.findViewById(R.id.search_view)
|
||||||
|
}
|
||||||
|
private val adapter by lazy {
|
||||||
|
SourceAdapter(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
setLayout(1f, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
initView()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initView() {
|
||||||
|
binding.toolBar.setBackgroundColor(primaryColor)
|
||||||
|
binding.toolBar.title = "选择书源"
|
||||||
|
binding.toolBar.rightPadding = 16.dpToPx()
|
||||||
|
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
binding.recyclerView.adapter = adapter
|
||||||
|
searchView.applyTint(primaryTextColor)
|
||||||
|
searchView.onActionViewExpanded()
|
||||||
|
searchView.isSubmitButtonEnabled = true
|
||||||
|
searchView.queryHint = getString(R.string.search_book_source)
|
||||||
|
searchView.clearFocus()
|
||||||
|
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||||
|
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onQueryTextChange(newText: String?): Boolean {
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inner class SourceAdapter(context: Context) :
|
||||||
|
RecyclerAdapter<BookSource, ItemTextBinding>(context) {
|
||||||
|
|
||||||
|
override fun getViewBinding(parent: ViewGroup): ItemTextBinding {
|
||||||
|
return ItemTextBinding.inflate(inflater, parent, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun convert(
|
||||||
|
holder: ItemViewHolder,
|
||||||
|
binding: ItemTextBinding,
|
||||||
|
item: BookSource,
|
||||||
|
payloads: MutableList<Any>
|
||||||
|
) {
|
||||||
|
binding.textView.text = item.getDisPlayNameGroup()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun registerListener(holder: ItemViewHolder, binding: ItemTextBinding) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -98,6 +98,11 @@ class SelectActionBar @JvmOverloads constructor(
|
|||||||
btnRevertSelection.isClickable = isClickable
|
btnRevertSelection.isClickable = isClickable
|
||||||
btnSelectActionMain.isEnabled = isClickable
|
btnSelectActionMain.isEnabled = isClickable
|
||||||
btnSelectActionMain.isClickable = isClickable
|
btnSelectActionMain.isClickable = isClickable
|
||||||
|
if (isClickable) {
|
||||||
|
ivMenuMore.setColorFilter(context.primaryTextColor)
|
||||||
|
} else {
|
||||||
|
ivMenuMore.setColorFilter(context.secondaryTextColor)
|
||||||
|
}
|
||||||
ivMenuMore.isEnabled = isClickable
|
ivMenuMore.isEnabled = isClickable
|
||||||
ivMenuMore.isClickable = isClickable
|
ivMenuMore.isClickable = isClickable
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<?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"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<io.legado.app.ui.widget.TitleBar
|
||||||
|
android:id="@+id/tool_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="?attr/actionBarStyle"
|
||||||
|
app:attachToActivity="false"
|
||||||
|
app:contentLayout="@layout/view_search"
|
||||||
|
app:fitStatusBar="false"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:titleTextAppearance="@style/ToolbarTitle" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
|
||||||
|
android:id="@+id/recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scrollbars="none"
|
||||||
|
tools:ignore="SpeakableTextPresentCheck" />
|
||||||
|
|
||||||
|
<io.legado.app.ui.widget.anima.RotateLoading
|
||||||
|
android:id="@+id/rotate_loading"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_margin="6dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:loading_width="2dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_msg"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:textColor="@color/secondaryText"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<com.google.android.flexbox.FlexboxLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingRight="12dp"
|
||||||
|
app:flexWrap="wrap"
|
||||||
|
app:justifyContent="space_between">
|
||||||
|
|
||||||
|
<io.legado.app.ui.widget.text.AccentTextView
|
||||||
|
android:id="@+id/tv_footer_left"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:ignore="RtlHardcoded" />
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<io.legado.app.ui.widget.text.AccentTextView
|
||||||
|
android:id="@+id/tv_cancel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:text="@string/cancel"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:ignore="RtlHardcoded" />
|
||||||
|
|
||||||
|
<io.legado.app.ui.widget.text.AccentTextView
|
||||||
|
android:id="@+id/tv_ok"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:text="@string/ok"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:ignore="RtlHardcoded" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.flexbox.FlexboxLayout>
|
||||||
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user