|
|
|
@ -11,6 +11,7 @@ import android.widget.Toast
|
|
|
|
|
import androidx.core.content.res.ResourcesCompat
|
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
|
import androidx.fragment.app.viewModels
|
|
|
|
|
import androidx.lifecycle.ViewModelProvider
|
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
|
|
|
import com.google.gson.JsonParser
|
|
|
|
@ -131,11 +132,8 @@ class FirstFragment: Fragment(R.layout.fragment_map_page) {
|
|
|
|
|
val phone = clickedData?.get("phone")?.asString ?: ""
|
|
|
|
|
val restaurant = RestaurantData(lat.toDouble(), lon.toDouble(), name,address,phone)
|
|
|
|
|
|
|
|
|
|
viewLifecycleOwner.lifecycleScope.launch {
|
|
|
|
|
withContext(Dispatchers.IO) {
|
|
|
|
|
restaurantViewModel.insert(restaurant)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val restaurantViewModel = ViewModelProvider(this, RestaurantViewModelFactory((requireActivity().application as MappingApplication).repository)).get(RestaurantViewModel::class.java)
|
|
|
|
|
restaurantViewModel.insert(restaurant)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setSelectedIcon(it)
|
|
|
|
@ -150,9 +148,6 @@ class FirstFragment: Fragment(R.layout.fragment_map_page) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val restaurantViewModel: RestaurantViewModel by viewModels {
|
|
|
|
|
RestaurantViewModelFactory((requireActivity().application as MappingApplication).repository)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun toggleLayout() {
|
|
|
|
|
mapLayout?.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 2f)
|
|
|
|
|