|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package io.legado.app.ui.changesource |
|
|
|
|
|
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.util.DisplayMetrics |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
@ -8,17 +9,40 @@ import androidx.appcompat.widget.SearchView |
|
|
|
|
import androidx.fragment.app.DialogFragment |
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
import io.legado.app.R |
|
|
|
|
import io.legado.app.utils.getViewModel |
|
|
|
|
import kotlinx.android.synthetic.main.dialog_change_source.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChangeSourceDialog(val name: String, val author: String) : DialogFragment() { |
|
|
|
|
class ChangeSourceDialog : DialogFragment() { |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
fun newInstance(name: String, author: String): ChangeSourceDialog { |
|
|
|
|
val changeSourceDialog = ChangeSourceDialog() |
|
|
|
|
val bundle = Bundle() |
|
|
|
|
bundle.putString("name", name) |
|
|
|
|
bundle.putString("author", author) |
|
|
|
|
changeSourceDialog.arguments = bundle |
|
|
|
|
return changeSourceDialog |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private lateinit var viewModel: ChangeSourceViewModel |
|
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
|
|
|
viewModel = getViewModel(ChangeSourceViewModel::class.java) |
|
|
|
|
return inflater.inflate(R.layout.dialog_change_source, container) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
|
arguments?.let { bundle -> |
|
|
|
|
bundle.getString("name")?.let { |
|
|
|
|
viewModel.name = it |
|
|
|
|
} |
|
|
|
|
bundle.getString("author")?.let { |
|
|
|
|
viewModel.author = it |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
tool_bar.inflateMenu(R.menu.search_view) |
|
|
|
|
showTitle() |
|
|
|
|
initRecyclerView() |
|
|
|
@ -27,12 +51,14 @@ class ChangeSourceDialog(val name: String, val author: String) : DialogFragment( |
|
|
|
|
|
|
|
|
|
override fun onStart() { |
|
|
|
|
super.onStart() |
|
|
|
|
dialog?.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) |
|
|
|
|
val dm = DisplayMetrics() |
|
|
|
|
activity?.windowManager?.defaultDisplay?.getMetrics(dm) |
|
|
|
|
dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun showTitle() { |
|
|
|
|
tool_bar.title = name |
|
|
|
|
tool_bar.subtitle = getString(R.string.author_show, author) |
|
|
|
|
tool_bar.title = viewModel.name |
|
|
|
|
tool_bar.subtitle = getString(R.string.author_show, viewModel.author) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun initRecyclerView() { |
|
|
|
|