|
|
@ -13,6 +13,7 @@ import androidx.recyclerview.widget.DividerItemDecoration |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
|
|
|
|
import io.legado.app.data.entities.SearchBook |
|
|
|
import io.legado.app.utils.getViewModel |
|
|
|
import io.legado.app.utils.getViewModel |
|
|
|
import kotlinx.android.synthetic.main.dialog_change_source.* |
|
|
|
import kotlinx.android.synthetic.main.dialog_change_source.* |
|
|
|
|
|
|
|
|
|
|
@ -22,11 +23,12 @@ class ChangeSourceDialog : DialogFragment() { |
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
const val tag = "changeSourceDialog" |
|
|
|
const val tag = "changeSourceDialog" |
|
|
|
|
|
|
|
|
|
|
|
fun newInstance(name: String, author: String): ChangeSourceDialog { |
|
|
|
fun newInstance(name: String, author: String, bookUrl: String? = null): ChangeSourceDialog { |
|
|
|
val changeSourceDialog = ChangeSourceDialog() |
|
|
|
val changeSourceDialog = ChangeSourceDialog() |
|
|
|
val bundle = Bundle() |
|
|
|
val bundle = Bundle() |
|
|
|
bundle.putString("name", name) |
|
|
|
bundle.putString("name", name) |
|
|
|
bundle.putString("author", author) |
|
|
|
bundle.putString("author", author) |
|
|
|
|
|
|
|
bundle.putString("bookUrl", bookUrl) |
|
|
|
changeSourceDialog.arguments = bundle |
|
|
|
changeSourceDialog.arguments = bundle |
|
|
|
return changeSourceDialog |
|
|
|
return changeSourceDialog |
|
|
|
} |
|
|
|
} |
|
|
@ -50,6 +52,9 @@ class ChangeSourceDialog : DialogFragment() { |
|
|
|
bundle.getString("author")?.let { |
|
|
|
bundle.getString("author")?.let { |
|
|
|
viewModel.author = it |
|
|
|
viewModel.author = it |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
bundle.getString("bookUrl")?.let { |
|
|
|
|
|
|
|
viewModel.curBookUrl = it |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
tool_bar.inflateMenu(R.menu.search_view) |
|
|
|
tool_bar.inflateMenu(R.menu.search_view) |
|
|
|
showTitle() |
|
|
|
showTitle() |
|
|
@ -72,6 +77,17 @@ class ChangeSourceDialog : DialogFragment() { |
|
|
|
|
|
|
|
|
|
|
|
private fun initRecyclerView() { |
|
|
|
private fun initRecyclerView() { |
|
|
|
changeSourceAdapter = ChangeSourceAdapter(requireContext()) |
|
|
|
changeSourceAdapter = ChangeSourceAdapter(requireContext()) |
|
|
|
|
|
|
|
changeSourceAdapter.callBack = object : ChangeSourceAdapter.CallBack { |
|
|
|
|
|
|
|
override fun changeTo(searchBook: SearchBook) { |
|
|
|
|
|
|
|
callBack?.changeTo(searchBook.toBook()) |
|
|
|
|
|
|
|
dismiss() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun curBookUrl(): String { |
|
|
|
|
|
|
|
return viewModel.curBookUrl |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
recycler_view.layoutManager = LinearLayoutManager(context) |
|
|
|
recycler_view.layoutManager = LinearLayoutManager(context) |
|
|
|
recycler_view.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayout.VERTICAL)) |
|
|
|
recycler_view.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayout.VERTICAL)) |
|
|
|
recycler_view.adapter = changeSourceAdapter |
|
|
|
recycler_view.adapter = changeSourceAdapter |
|
|
|