|
|
@ -14,6 +14,7 @@ import io.legado.app.databinding.DialogSearchScopeBinding |
|
|
|
import io.legado.app.databinding.ItemCheckBoxBinding |
|
|
|
import io.legado.app.databinding.ItemCheckBoxBinding |
|
|
|
import io.legado.app.databinding.ItemRadioButtonBinding |
|
|
|
import io.legado.app.databinding.ItemRadioButtonBinding |
|
|
|
import io.legado.app.lib.theme.primaryColor |
|
|
|
import io.legado.app.lib.theme.primaryColor |
|
|
|
|
|
|
|
import io.legado.app.utils.applyTint |
|
|
|
import io.legado.app.utils.setLayout |
|
|
|
import io.legado.app.utils.setLayout |
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
@ -24,8 +25,9 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) { |
|
|
|
|
|
|
|
|
|
|
|
private val binding by viewBinding(DialogSearchScopeBinding::bind) |
|
|
|
private val binding by viewBinding(DialogSearchScopeBinding::bind) |
|
|
|
val callback: Callback get() = parentFragment as? Callback ?: activity as Callback |
|
|
|
val callback: Callback get() = parentFragment as? Callback ?: activity as Callback |
|
|
|
var groups = arrayListOf<String>() |
|
|
|
var groups: List<String> = arrayListOf() |
|
|
|
var sources = arrayListOf<BookSource>() |
|
|
|
var sources: List<BookSource> = arrayListOf() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val adapter by lazy { |
|
|
|
val adapter by lazy { |
|
|
|
RecyclerAdapter() |
|
|
|
RecyclerAdapter() |
|
|
@ -39,14 +41,20 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) { |
|
|
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
binding.toolBar.setBackgroundColor(primaryColor) |
|
|
|
binding.toolBar.setBackgroundColor(primaryColor) |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
|
|
|
|
initMenu() |
|
|
|
initOtherView() |
|
|
|
initOtherView() |
|
|
|
initData() |
|
|
|
initData() |
|
|
|
upData() |
|
|
|
upData() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun initMenu() { |
|
|
|
|
|
|
|
binding.toolBar.inflateMenu(R.menu.change_source) |
|
|
|
|
|
|
|
binding.toolBar.menu.applyTint(requireContext()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun initOtherView() { |
|
|
|
private fun initOtherView() { |
|
|
|
binding.rgScope.setOnCheckedChangeListener { _, _ -> |
|
|
|
binding.rgScope.setOnCheckedChangeListener { group, checkedId -> |
|
|
|
|
|
|
|
binding.toolBar.menu.findItem(R.id.menu_screen)?.isVisible = checkedId == R.id.rb_source |
|
|
|
upData() |
|
|
|
upData() |
|
|
|
} |
|
|
|
} |
|
|
|
binding.tvCancel.setOnClickListener { |
|
|
|
binding.tvCancel.setOnClickListener { |
|
|
@ -73,9 +81,11 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) { |
|
|
|
|
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
private fun initData() { |
|
|
|
launch { |
|
|
|
launch { |
|
|
|
withContext(IO) { |
|
|
|
groups = withContext(IO) { |
|
|
|
groups.addAll(appDb.bookSourceDao.allGroups) |
|
|
|
appDb.bookSourceDao.allGroups |
|
|
|
sources.addAll(appDb.bookSourceDao.allEnabled) |
|
|
|
} |
|
|
|
|
|
|
|
sources = withContext(IO) { |
|
|
|
|
|
|
|
appDb.bookSourceDao.allEnabled |
|
|
|
} |
|
|
|
} |
|
|
|
upData() |
|
|
|
upData() |
|
|
|
} |
|
|
|
} |
|
|
|