mirror of
https://github.com/ev-map/EVMap.git
synced 2026-05-19 12:26:20 -04:00
work around double call of onViewCreated in MaterialDialogFragment
This commit is contained in:
@@ -45,7 +45,7 @@ class DataSourceSelectDialog : MaterialDialogFragment() {
|
||||
|
||||
private lateinit var prefs: PreferenceDataSource
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
override fun initView(view: View, savedInstanceState: Bundle?) {
|
||||
val args = requireArguments()
|
||||
binding.btnCancel.visibility =
|
||||
if (args.getBoolean("cancel_enabled")) View.VISIBLE else View.GONE
|
||||
|
||||
@@ -53,7 +53,7 @@ class MultiSelectDialog : MaterialDialogFragment() {
|
||||
setFullSize(maxWidthDp = 500)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
override fun initView(view: View, savedInstanceState: Bundle?) {
|
||||
val args = requireArguments()
|
||||
val data = args.getSerializable("data") as HashMap<String, String>
|
||||
val selected = args.getSerializable("selected") as HashSet<String>
|
||||
|
||||
@@ -22,9 +22,7 @@ class OpensourceDonationsDialogFragment : MaterialDialogFragment() {
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
override fun initView(view: View, savedInstanceState: Bundle?) {
|
||||
val prefs = PreferenceDataSource(requireContext())
|
||||
binding.btnOk.setOnClickListener {
|
||||
prefs.opensourceDonationsDialogShown = true
|
||||
|
||||
@@ -63,7 +63,7 @@ fun showEditTextDialog(
|
||||
* https://github.com/material-components/material-components-android/issues/540 and
|
||||
* https://dev.to/bhullnatik/how-to-use-material-dialogs-with-dialogfragment-28i1
|
||||
*/
|
||||
open class MaterialDialogFragment : AppCompatDialogFragment() {
|
||||
abstract class MaterialDialogFragment : AppCompatDialogFragment() {
|
||||
|
||||
private lateinit var dialogView: View
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
@@ -73,10 +73,12 @@ open class MaterialDialogFragment : AppCompatDialogFragment() {
|
||||
|
||||
setView(dialogView)
|
||||
}.create()
|
||||
onViewCreated(dialogView, savedInstanceState)
|
||||
initView(dialogView, savedInstanceState)
|
||||
return dialog
|
||||
}
|
||||
|
||||
abstract fun initView(view: View, savedInstanceState: Bundle?)
|
||||
|
||||
override fun getView(): View {
|
||||
return dialogView
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@ import androidx.lifecycle.*
|
||||
import com.car2go.maps.AnyMap
|
||||
import com.car2go.maps.model.LatLng
|
||||
import com.car2go.maps.model.LatLngBounds
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import net.vonforst.evmap.api.ChargepointApi
|
||||
import net.vonforst.evmap.api.availability.ChargeLocationStatus
|
||||
@@ -277,7 +279,11 @@ class MapViewModel(application: Application, private val state: SavedStateHandle
|
||||
}
|
||||
|
||||
suspend fun copyFiltersToCustom() {
|
||||
filterStatus.value?.let { db.filterValueDao().copyFiltersToCustom(it, prefs.dataSource) }
|
||||
filterStatus.value?.let {
|
||||
withContext(Dispatchers.IO) {
|
||||
db.filterValueDao().copyFiltersToCustom(it, prefs.dataSource)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setMapType(type: AnyMap.Type) {
|
||||
|
||||
Reference in New Issue
Block a user