diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-12 18:54:51 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-12 18:54:51 -0600 |
commit | ec778f53323aa3844eadc0aae4c647d2e3a23d20 (patch) | |
tree | d093150da23333b9e9b025c6c10ce06e7f51a128 /androidApp/src/main | |
parent | 9cdf080dfb589c748928657c8ce0a53b3959d3a8 (diff) | |
download | etbsa-trackermap-mobile-ec778f53323aa3844eadc0aae4c647d2e3a23d20.tar.gz etbsa-trackermap-mobile-ec778f53323aa3844eadc0aae4c647d2e3a23d20.tar.bz2 etbsa-trackermap-mobile-ec778f53323aa3844eadc0aae4c647d2e3a23d20.zip |
Fix code style and replaced this to viewLifecycleOwner in observers to avoid leaks
Diffstat (limited to 'androidApp/src/main')
4 files changed, 9 insertions, 7 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt index 07a7b05..27d8756 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt @@ -15,9 +15,8 @@ class DetailsActivity : AppCompatActivity() { private var deviceId: Int = 0 companion object { - - val DEVICE_ID_EXTRA = "device_id" - val ACTION_EXTRA = "action" + const val DEVICE_ID_EXTRA = "device_id" + const val ACTION_EXTRA = "action" } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt index bb0da4f..bb462ef 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt @@ -5,13 +5,14 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.AdapterView import android.widget.ArrayAdapter import androidx.fragment.app.Fragment +import kotlinx.coroutines.DelicateCoroutinesApi import mx.trackermap.TrackerMap.android.databinding.UnitDetailsCommandsBinding import mx.trackermap.TrackerMap.android.details.UnitDetailsAdapter import org.koin.androidx.viewmodel.ext.android.viewModel +@DelicateCoroutinesApi class UnitCommandsFragment: Fragment() { private var _binding: UnitDetailsCommandsBinding? = null private val binding get() = _binding!! @@ -40,7 +41,7 @@ class UnitCommandsFragment: Fragment() { } private fun setupObservers() { - unitCommandsViewModel.commands.observe(this) { commands -> + unitCommandsViewModel.commands.observe(viewLifecycleOwner) { commands -> Log.d("UnitCommandsFragment", "Device commands - $commands") val context = activity!!.applicationContext val adapter = ArrayAdapter<String>(context, android.R.layout.simple_list_item_1) 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 6e38ffe..12ea352 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 @@ -51,7 +51,7 @@ class UnitInformationFragment : Fragment() { } private fun setupObservers() { - unitInformationViewModel.unit.observe(this) { unitInformation -> + unitInformationViewModel.unit.observe(viewLifecycleOwner) { unitInformation -> Log.d("UnitInformationFragment", "Unit Information Fetched - $unitInformation") unitInformation?.let { displayInformation(it) diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt index cc84f06..674c2d3 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt @@ -10,10 +10,12 @@ import android.widget.Toast import androidx.core.widget.doAfterTextChanged import androidx.fragment.app.Fragment import com.zhuinden.liveevent.observe +import kotlinx.coroutines.DelicateCoroutinesApi import mx.trackermap.TrackerMap.android.databinding.LoginBinding import mx.trackermap.TrackerMap.android.units.UnitsActivity import org.koin.androidx.viewmodel.ext.android.viewModel +@DelicateCoroutinesApi class LoginFragment : Fragment() { private var _binding: LoginBinding? = null private val binding get() = _binding!! @@ -54,7 +56,7 @@ class LoginFragment : Fragment() { } private fun setupObservers() { - loginViewModel.loginState.observe(this) { result -> + loginViewModel.loginState.observe(viewLifecycleOwner) { result -> Log.d("LoginFragment", result.toString()) when (result) { LoginViewModel.LoginState.Loading -> { |