diff options
author | Isidro Henoch <imhenoch@protonmail.com> | 2022-01-12 18:37:07 -0600 |
---|---|---|
committer | Isidro Henoch <imhenoch@protonmail.com> | 2022-01-12 18:37:07 -0600 |
commit | e386cd98427cf323285358057fa099b3f9641591 (patch) | |
tree | 477afcf01a9557384a72af783d8fee7a0353470b /androidApp/src/main/java/mx/trackermap/TrackerMap/android | |
parent | 8b9f4d7d7c1cebd380a617d25f7f580353f24535 (diff) | |
download | etbsa-trackermap-mobile-e386cd98427cf323285358057fa099b3f9641591.tar.gz etbsa-trackermap-mobile-e386cd98427cf323285358057fa099b3f9641591.tar.bz2 etbsa-trackermap-mobile-e386cd98427cf323285358057fa099b3f9641591.zip |
Fixes the empty unit details
Diffstat (limited to 'androidApp/src/main/java/mx/trackermap/TrackerMap/android')
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 |