From 4292ebfee3426cee1402b0b86dcadc03f167ad00 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Thu, 19 Sep 2024 13:47:11 +0530 Subject: [PATCH 1/9] viewmodel removed from cons --- .../tasks/polygon/DrawAreaTaskFragment.kt | 3 ++- .../tasks/polygon/DrawAreaTaskMapFragment.kt | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt index 80452ee2fa..ebb20c3e25 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt @@ -59,7 +59,8 @@ class DrawAreaTaskFragment : AbstractTaskFragment() { // NOTE(#2493): Multiplying by a random prime to allow for some mathematical "uniqueness". // Otherwise, the sequentially generated ID might conflict with an ID produced by Google Maps. val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() * 11411 } - drawAreaTaskMapFragment = DrawAreaTaskMapFragment.newInstance(viewModel, map) + drawAreaTaskMapFragment = + DrawAreaTaskMapFragment.newInstance(map).apply { setViewModel(viewModel) } parentFragmentManager .beginTransaction() .add(rowLayout.id, drawAreaTaskMapFragment, DrawAreaTaskMapFragment::class.java.simpleName) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt index fa32c8c052..004ca69fe6 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt @@ -26,10 +26,10 @@ import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch @AndroidEntryPoint -class DrawAreaTaskMapFragment(private val viewModel: DrawAreaTaskViewModel) : - AbstractMapFragmentWithControls() { +class DrawAreaTaskMapFragment : AbstractMapFragmentWithControls() { private lateinit var mapViewModel: BaseMapViewModel + private lateinit var viewModel: DrawAreaTaskViewModel override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -40,15 +40,17 @@ class DrawAreaTaskMapFragment(private val viewModel: DrawAreaTaskViewModel) : override fun onMapReady(map: MapFragment) { viewLifecycleOwner.lifecycleScope.launch { - viewModel.draftArea.collect { feature: Feature? -> - map.setFeatures(if (feature == null) setOf() else setOf(feature)) + if (this@DrawAreaTaskMapFragment::viewModel.isInitialized) { + viewModel.draftArea.collect { feature: Feature? -> + map.setFeatures(if (feature == null) setOf() else setOf(feature)) + } } } } override fun onMapCameraMoved(position: CameraPosition) { super.onMapCameraMoved(position) - if (!viewModel.isMarkedComplete()) { + if (this@DrawAreaTaskMapFragment::viewModel.isInitialized && !viewModel.isMarkedComplete()) { val mapCenter = position.coordinates viewModel.updateLastVertexAndMaybeCompletePolygon(mapCenter) { c1, c2 -> map.getDistanceInPixels(c1, c2) @@ -56,8 +58,11 @@ class DrawAreaTaskMapFragment(private val viewModel: DrawAreaTaskViewModel) : } } + fun setViewModel(viewModel: DrawAreaTaskViewModel) { + this.viewModel = viewModel + } + companion object { - fun newInstance(viewModel: DrawAreaTaskViewModel, map: MapFragment) = - DrawAreaTaskMapFragment(viewModel).apply { this.map = map } + fun newInstance(map: MapFragment) = DrawAreaTaskMapFragment().apply { this.map = map } } } From 6a3ec1823d46da9dc473a24dba662098afb26450 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sat, 21 Sep 2024 07:57:38 +0530 Subject: [PATCH 2/9] workaroudn --- .../location/CaptureLocationTaskFragment.kt | 7 ++----- .../CaptureLocationTaskMapFragment.kt | 21 +++++++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt index e4ea943836..0f93bb1486 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt @@ -41,13 +41,10 @@ class CaptureLocationTaskFragment : AbstractTaskFragment Date: Sat, 21 Sep 2024 08:03:21 +0530 Subject: [PATCH 3/9] workaround --- .../tasks/point/DropPinTaskFragment.kt | 3 ++- .../tasks/point/DropPinTaskMapFragment.kt | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskFragment.kt index a6e2c141c2..493914514a 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskFragment.kt @@ -47,9 +47,10 @@ class DropPinTaskFragment : AbstractTaskFragment() { // NOTE(#2493): Multiplying by a random prime to allow for some mathematical "uniqueness". // Otherwise, the sequentially generated ID might conflict with an ID produced by Google Maps. val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() * 11617 } + val fragment = DropPinTaskMapFragment.newInstance(map).apply { setViewModel(viewModel) } parentFragmentManager .beginTransaction() - .add(rowLayout.id, DropPinTaskMapFragment.newInstance(viewModel, map), "Drop a pin fragment") + .add(rowLayout.id, fragment, "Drop a pin fragment") .commit() return rowLayout } diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt index 748970ec75..fa7d8ff7f9 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt @@ -23,10 +23,10 @@ import com.google.android.ground.ui.map.MapFragment import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint -class DropPinTaskMapFragment(private val viewModel: DropPinTaskViewModel) : - AbstractMapFragmentWithControls() { +class DropPinTaskMapFragment : AbstractMapFragmentWithControls() { private lateinit var mapViewModel: BaseMapViewModel + private lateinit var viewModel: DropPinTaskViewModel override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -36,16 +36,23 @@ class DropPinTaskMapFragment(private val viewModel: DropPinTaskViewModel) : override fun getMapViewModel(): BaseMapViewModel = mapViewModel override fun onMapReady(map: MapFragment) { - viewModel.features.observe(this) { map.setFeatures(it) } + if (this@DropPinTaskMapFragment::viewModel.isInitialized) { + viewModel.features.observe(this) { map.setFeatures(it) } + } } override fun onMapCameraMoved(position: CameraPosition) { super.onMapCameraMoved(position) - viewModel.updateCameraPosition(position) + if (this@DropPinTaskMapFragment::viewModel.isInitialized) { + viewModel.updateCameraPosition(position) + } + } + + fun setViewModel(viewModel: DropPinTaskViewModel) { + this.viewModel = viewModel } companion object { - fun newInstance(viewModel: DropPinTaskViewModel, map: MapFragment) = - DropPinTaskMapFragment(viewModel).apply { this.map = map } + fun newInstance(map: MapFragment) = DropPinTaskMapFragment().apply { this.map = map } } } From 2d581e49cb88378eb76a584b54b63859168b4753 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sat, 21 Sep 2024 09:49:36 +0530 Subject: [PATCH 4/9] using bundle for drawtask --- .../datacollection/DataCollectionFragment.kt | 2 +- .../tasks/polygon/DrawAreaTaskFragment.kt | 4 ++-- .../tasks/polygon/DrawAreaTaskMapFragment.kt | 20 ++++++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataCollectionFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataCollectionFragment.kt index 57fa07c5c6..79ceee37c4 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataCollectionFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataCollectionFragment.kt @@ -46,7 +46,7 @@ class DataCollectionFragment : AbstractFragment(), BackPressListener { @Inject lateinit var navigator: Navigator @Inject lateinit var viewPagerAdapterFactory: DataCollectionViewPagerAdapterFactory - private val viewModel: DataCollectionViewModel by hiltNavGraphViewModels(R.id.data_collection) + val viewModel: DataCollectionViewModel by hiltNavGraphViewModels(R.id.data_collection) private lateinit var binding: DataCollectionFragBinding private lateinit var progressBar: ProgressBar diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt index ebb20c3e25..355eac8f1d 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt @@ -59,8 +59,8 @@ class DrawAreaTaskFragment : AbstractTaskFragment() { // NOTE(#2493): Multiplying by a random prime to allow for some mathematical "uniqueness". // Otherwise, the sequentially generated ID might conflict with an ID produced by Google Maps. val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() * 11411 } - drawAreaTaskMapFragment = - DrawAreaTaskMapFragment.newInstance(map).apply { setViewModel(viewModel) } + drawAreaTaskMapFragment = DrawAreaTaskMapFragment.newInstance(map, super.taskId) + println("====== DrawAreaTaskFragment ${viewModel}") parentFragmentManager .beginTransaction() .add(rowLayout.id, drawAreaTaskMapFragment, DrawAreaTaskMapFragment::class.java.simpleName) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt index 004ca69fe6..68dd58c814 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt @@ -19,6 +19,7 @@ import android.os.Bundle import androidx.lifecycle.lifecycleScope import com.google.android.ground.ui.common.AbstractMapFragmentWithControls import com.google.android.ground.ui.common.BaseMapViewModel +import com.google.android.ground.ui.datacollection.DataCollectionFragment import com.google.android.ground.ui.map.CameraPosition import com.google.android.ground.ui.map.Feature import com.google.android.ground.ui.map.MapFragment @@ -34,6 +35,14 @@ class DrawAreaTaskMapFragment : AbstractMapFragmentWithControls() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mapViewModel = getViewModel(BaseMapViewModel::class.java) + arguments?.let { + val taskId = it.getString("taskId") + taskId?.let { + viewModel = + (requireParentFragment() as DataCollectionFragment).viewModel.getTaskViewModel(taskId) + as DrawAreaTaskViewModel + } + } } override fun getMapViewModel(): BaseMapViewModel = mapViewModel @@ -58,11 +67,12 @@ class DrawAreaTaskMapFragment : AbstractMapFragmentWithControls() { } } - fun setViewModel(viewModel: DrawAreaTaskViewModel) { - this.viewModel = viewModel - } - companion object { - fun newInstance(map: MapFragment) = DrawAreaTaskMapFragment().apply { this.map = map } + fun newInstance(map: MapFragment, taskId: String): DrawAreaTaskMapFragment { + val fragment = DrawAreaTaskMapFragment().apply { this.map = map } + val args = Bundle().apply { putString("taskId", taskId) } + fragment.arguments = args + return fragment + } } } From c0895cc7970629d3bd3929d8d5414fafbf793959 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sat, 21 Sep 2024 10:19:46 +0530 Subject: [PATCH 5/9] error handle --- .../tasks/polygon/DrawAreaTaskMapFragment.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt index 68dd58c814..6100a36072 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt @@ -25,6 +25,7 @@ import com.google.android.ground.ui.map.Feature import com.google.android.ground.ui.map.MapFragment import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch +import timber.log.Timber @AndroidEntryPoint class DrawAreaTaskMapFragment : AbstractMapFragmentWithControls() { @@ -36,11 +37,15 @@ class DrawAreaTaskMapFragment : AbstractMapFragmentWithControls() { super.onCreate(savedInstanceState) mapViewModel = getViewModel(BaseMapViewModel::class.java) arguments?.let { - val taskId = it.getString("taskId") - taskId?.let { - viewModel = - (requireParentFragment() as DataCollectionFragment).viewModel.getTaskViewModel(taskId) - as DrawAreaTaskViewModel + try { + val taskId = it.getString("taskId") + taskId?.let { + viewModel = + (requireParentFragment() as DataCollectionFragment).viewModel.getTaskViewModel(taskId) + as DrawAreaTaskViewModel + } + } catch (e: Exception) { + Timber.e("DrawAreaTaskMapFragment - $e") } } } From a07316a986b470a13bcc6642ca5d8743cfbb1694 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sat, 21 Sep 2024 10:24:37 +0530 Subject: [PATCH 6/9] using bundle --- .../location/CaptureLocationTaskFragment.kt | 2 +- .../CaptureLocationTaskMapFragment.kt | 25 +++++++++++++++---- .../tasks/polygon/DrawAreaTaskFragment.kt | 1 - 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt index 0f93bb1486..f6dd4b8cf0 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt @@ -41,7 +41,7 @@ class CaptureLocationTaskFragment : AbstractTaskFragment() { // Otherwise, the sequentially generated ID might conflict with an ID produced by Google Maps. val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() * 11411 } drawAreaTaskMapFragment = DrawAreaTaskMapFragment.newInstance(map, super.taskId) - println("====== DrawAreaTaskFragment ${viewModel}") parentFragmentManager .beginTransaction() .add(rowLayout.id, drawAreaTaskMapFragment, DrawAreaTaskMapFragment::class.java.simpleName) From dceee03106bafcbe493dfea63897d9d3d2befd57 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sat, 21 Sep 2024 10:27:29 +0530 Subject: [PATCH 7/9] using bundle --- .../tasks/point/DropPinTaskFragment.kt | 2 +- .../tasks/point/DropPinTaskMapFragment.kt | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskFragment.kt index 493914514a..5fdb1c164f 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskFragment.kt @@ -47,7 +47,7 @@ class DropPinTaskFragment : AbstractTaskFragment() { // NOTE(#2493): Multiplying by a random prime to allow for some mathematical "uniqueness". // Otherwise, the sequentially generated ID might conflict with an ID produced by Google Maps. val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() * 11617 } - val fragment = DropPinTaskMapFragment.newInstance(map).apply { setViewModel(viewModel) } + val fragment = DropPinTaskMapFragment.newInstance(map, super.taskId) parentFragmentManager .beginTransaction() .add(rowLayout.id, fragment, "Drop a pin fragment") diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt index fa7d8ff7f9..3f34e58260 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt @@ -18,9 +18,11 @@ package com.google.android.ground.ui.datacollection.tasks.point import android.os.Bundle import com.google.android.ground.ui.common.AbstractMapFragmentWithControls import com.google.android.ground.ui.common.BaseMapViewModel +import com.google.android.ground.ui.datacollection.DataCollectionFragment import com.google.android.ground.ui.map.CameraPosition import com.google.android.ground.ui.map.MapFragment import dagger.hilt.android.AndroidEntryPoint +import timber.log.Timber @AndroidEntryPoint class DropPinTaskMapFragment : AbstractMapFragmentWithControls() { @@ -31,6 +33,18 @@ class DropPinTaskMapFragment : AbstractMapFragmentWithControls() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mapViewModel = getViewModel(BaseMapViewModel::class.java) + arguments?.let { + try { + val taskId = it.getString("taskId") + taskId?.let { + viewModel = + (requireParentFragment() as DataCollectionFragment).viewModel.getTaskViewModel(taskId) + as DropPinTaskViewModel + } + } catch (e: Exception) { + Timber.e("DropPinTaskMapFragment - $e") + } + } } override fun getMapViewModel(): BaseMapViewModel = mapViewModel @@ -53,6 +67,11 @@ class DropPinTaskMapFragment : AbstractMapFragmentWithControls() { } companion object { - fun newInstance(map: MapFragment) = DropPinTaskMapFragment().apply { this.map = map } + fun newInstance(map: MapFragment, taskId: String): DropPinTaskMapFragment { + val fragment = DropPinTaskMapFragment().apply { this.map = map } + val args = Bundle().apply { putString("taskId", taskId) } + fragment.arguments = args + return fragment + } } } From 4f5526bb19a3da74086e7818aa09da93e39af9b0 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sat, 21 Sep 2024 11:25:01 +0530 Subject: [PATCH 8/9] cleaup --- .../tasks/location/CaptureLocationTaskFragment.kt | 2 +- .../ui/datacollection/tasks/point/DropPinTaskFragment.kt | 2 +- .../ui/datacollection/tasks/point/DropPinTaskMapFragment.kt | 4 ---- .../ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt index f6dd4b8cf0..76fdb178ae 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskFragment.kt @@ -41,7 +41,7 @@ class CaptureLocationTaskFragment : AbstractTaskFragment() { // NOTE(#2493): Multiplying by a random prime to allow for some mathematical "uniqueness". // Otherwise, the sequentially generated ID might conflict with an ID produced by Google Maps. val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() * 11617 } - val fragment = DropPinTaskMapFragment.newInstance(map, super.taskId) + val fragment = DropPinTaskMapFragment.newInstance(map, taskId) parentFragmentManager .beginTransaction() .add(rowLayout.id, fragment, "Drop a pin fragment") diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt index 3f34e58260..eeb987343a 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt @@ -62,10 +62,6 @@ class DropPinTaskMapFragment : AbstractMapFragmentWithControls() { } } - fun setViewModel(viewModel: DropPinTaskViewModel) { - this.viewModel = viewModel - } - companion object { fun newInstance(map: MapFragment, taskId: String): DropPinTaskMapFragment { val fragment = DropPinTaskMapFragment().apply { this.map = map } diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt index a7351da3f2..fa03cf0fd0 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt @@ -59,7 +59,7 @@ class DrawAreaTaskFragment : AbstractTaskFragment() { // NOTE(#2493): Multiplying by a random prime to allow for some mathematical "uniqueness". // Otherwise, the sequentially generated ID might conflict with an ID produced by Google Maps. val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() * 11411 } - drawAreaTaskMapFragment = DrawAreaTaskMapFragment.newInstance(map, super.taskId) + drawAreaTaskMapFragment = DrawAreaTaskMapFragment.newInstance(map, taskId) parentFragmentManager .beginTransaction() .add(rowLayout.id, drawAreaTaskMapFragment, DrawAreaTaskMapFragment::class.java.simpleName) From a68190f44fb1cebc27d48606a185f0818f488985 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sun, 22 Sep 2024 07:46:51 +0530 Subject: [PATCH 9/9] log fix --- .../tasks/location/CaptureLocationTaskMapFragment.kt | 2 +- .../ui/datacollection/tasks/point/DropPinTaskMapFragment.kt | 2 +- .../ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskMapFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskMapFragment.kt index 0bedb176da..b179ed5c12 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskMapFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/location/CaptureLocationTaskMapFragment.kt @@ -46,7 +46,7 @@ class CaptureLocationTaskMapFragment : AbstractMapFragmentWithControls() { as CaptureLocationTaskViewModel } } catch (e: Exception) { - Timber.e("CaptureLocationTaskMapFragment - $e") + Timber.e(e) } } } diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt index eeb987343a..d3fa8fd10b 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/point/DropPinTaskMapFragment.kt @@ -42,7 +42,7 @@ class DropPinTaskMapFragment : AbstractMapFragmentWithControls() { as DropPinTaskViewModel } } catch (e: Exception) { - Timber.e("DropPinTaskMapFragment - $e") + Timber.e(e) } } } diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt index 6100a36072..f0c0d6678f 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskMapFragment.kt @@ -45,7 +45,7 @@ class DrawAreaTaskMapFragment : AbstractMapFragmentWithControls() { as DrawAreaTaskViewModel } } catch (e: Exception) { - Timber.e("DrawAreaTaskMapFragment - $e") + Timber.e(e) } } }