diff options
Diffstat (limited to 'androidApp/src/main/java')
3 files changed, 20 insertions, 6 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt index b1c5daf..6e38ffe 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt @@ -7,7 +7,8 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.* +import android.widget.LinearLayout +import android.widget.TextView import androidx.core.widget.TextViewCompat import androidx.fragment.app.Fragment import com.google.android.material.button.MaterialButton diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationViewModel.kt index 11daaaf..4705c00 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationViewModel.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationViewModel.kt @@ -9,7 +9,6 @@ import kotlinx.coroutines.launch import mx.trackermap.TrackerMap.client.models.UnitInformation import mx.trackermap.TrackerMap.controllers.UnitsController import org.koin.core.component.KoinComponent -import org.koin.core.component.inject @DelicateCoroutinesApi class UnitInformationViewModel constructor( @@ -23,6 +22,8 @@ class UnitInformationViewModel constructor( } fun fetchUnit(deviceId: Int) { - unit.postValue(unitsController.getUnit(deviceId)) + viewModelScope.launch { + unit.postValue(unitsController.getUnit(deviceId)) + } } }
\ No newline at end of file diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt index e198ce0..5213577 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt @@ -3,8 +3,6 @@ package mx.trackermap.TrackerMap.android.units import android.content.Intent import android.os.Bundle import android.util.Log -import android.view.Gravity -import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.widget.doAfterTextChanged import androidx.fragment.app.commit @@ -13,7 +11,6 @@ import mx.trackermap.TrackerMap.android.R import mx.trackermap.TrackerMap.android.databinding.UnitsActivityBinding import mx.trackermap.TrackerMap.android.devices.DevicesFragment import mx.trackermap.TrackerMap.android.map.UnitMapFragment -import mx.trackermap.TrackerMap.android.session.LoginActivity import mx.trackermap.TrackerMap.android.session.UserInformationActivity import org.koin.androidx.viewmodel.ext.android.viewModel @@ -38,9 +35,20 @@ class UnitsActivity : AppCompatActivity() { setContentView(binding.root) setupEvents() + } + + override fun onResume() { + super.onResume() + setupObservers() } + override fun onPause() { + super.onPause() + + removeObservers() + } + override fun onDestroy() { super.onDestroy() _binding = null @@ -87,4 +95,8 @@ class UnitsActivity : AppCompatActivity() { } } } + + private fun removeObservers() { + unitsViewModel.unitsDisplayMode.removeObservers(this) + } }
\ No newline at end of file |