From 561f3e19b6fbcfcca3fd568dde8793d9fbfd0aa5 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Thu, 13 Jan 2022 01:13:44 -0600 Subject: Enable user input on DetailsActivity only for details and commands tabs --- .../TrackerMap/android/details/DetailsActivity.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'androidApp') 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 504cac8..0b0313b 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 @@ -3,6 +3,7 @@ package mx.trackermap.TrackerMap.android.details import android.os.Bundle import android.util.Log import androidx.appcompat.app.AppCompatActivity +import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator import mx.trackermap.TrackerMap.android.R import mx.trackermap.TrackerMap.android.databinding.DetailsActivityBinding @@ -57,6 +58,17 @@ class DetailsActivity : AppCompatActivity() { else -> 2 }, false ) - binding.detailsPager.isUserInputEnabled = false + binding.detailsTabs.addOnTabSelectedListener(object: TabLayout.OnTabSelectedListener { + override fun onTabSelected(tab: TabLayout.Tab?) { + binding.detailsPager.isUserInputEnabled = + when (tab?.position) { + 0 -> true + 1 -> false + else -> true + } + } + override fun onTabUnselected(tab: TabLayout.Tab?) {} + override fun onTabReselected(tab: TabLayout.Tab?) {} + }) } } \ No newline at end of file -- cgit v1.2.3