From 547ce2e85e5b22e7c31f5a51df149919260d54b0 Mon Sep 17 00:00:00 2001 From: Isidro Henoch Date: Wed, 15 Dec 2021 01:00:37 -0600 Subject: Adds the details activity --- androidApp/src/main/AndroidManifest.xml | 3 ++ .../TrackerMap/android/details/DetailsActivity.kt | 32 ++++++++++++++++++++++ .../TrackerMap/android/devices/DevicesFragment.kt | 8 ++++++ .../src/main/res/layout/details_activity.xml | 17 ++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt create mode 100644 androidApp/src/main/res/layout/details_activity.xml (limited to 'androidApp/src/main') diff --git a/androidApp/src/main/AndroidManifest.xml b/androidApp/src/main/AndroidManifest.xml index 889342f..5d56847 100644 --- a/androidApp/src/main/AndroidManifest.xml +++ b/androidApp/src/main/AndroidManifest.xml @@ -23,5 +23,8 @@ + \ No newline at end of file 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 new file mode 100644 index 0000000..c9769e4 --- /dev/null +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt @@ -0,0 +1,32 @@ +package mx.trackermap.TrackerMap.android.details + +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import mx.trackermap.TrackerMap.android.databinding.DetailsActivityBinding + +class DetailsActivity: AppCompatActivity() { + private var _binding: DetailsActivityBinding? = null + private val binding get() = _binding!! + + companion object { + val DEVICE_ID_EXTRA = "device_id" + val ACTION_EXTRA = "action" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + _binding = DetailsActivityBinding.inflate(layoutInflater) + setContentView(binding.root) + + Log.d("DetailsActivity", "Device ID - ${intent.getIntExtra(DEVICE_ID_EXTRA, 0)}") + Log.d("DetailsActivity", "Device ID - ${intent.getSerializableExtra(ACTION_EXTRA)}") + } + + override fun onDestroy() { + super.onDestroy() + + _binding = null + } +} \ No newline at end of file diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt index a3ed7a8..2c11dc2 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt @@ -1,5 +1,6 @@ package mx.trackermap.TrackerMap.android.devices +import android.content.Intent import android.os.Bundle import android.util.Log import android.view.LayoutInflater @@ -9,6 +10,8 @@ import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import kotlinx.coroutines.DelicateCoroutinesApi import mx.trackermap.TrackerMap.android.databinding.DevicesFragmentBinding +import mx.trackermap.TrackerMap.android.details.DetailsActivity +import mx.trackermap.TrackerMap.android.units.UnitsActivity import mx.trackermap.TrackerMap.android.units.UnitsViewModel import mx.trackermap.TrackerMap.client.models.UnitInformation import org.koin.androidx.viewmodel.ext.android.viewModel @@ -62,5 +65,10 @@ class DevicesFragment : Fragment() { private fun itemAction(unit: UnitInformation, action: Action) { Log.d("DevicesFragment", "Action: $action - Unit: $unit") + val activity = requireActivity() + val intent = Intent(activity.applicationContext, DetailsActivity::class.java) + intent.putExtra(DetailsActivity.DEVICE_ID_EXTRA, unit.device.id) + intent.putExtra(DetailsActivity.ACTION_EXTRA, action) + startActivity(intent) } } \ No newline at end of file diff --git a/androidApp/src/main/res/layout/details_activity.xml b/androidApp/src/main/res/layout/details_activity.xml new file mode 100644 index 0000000..1a50487 --- /dev/null +++ b/androidApp/src/main/res/layout/details_activity.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file -- cgit v1.2.3