From 0c8576a60e59f9d7a2fb2044752d10e564237a4f Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Fri, 17 Dec 2021 01:57:23 -0600 Subject: Implemented SwipeLayout using Zerobranch's library --- androidApp/build.gradle.kts | 1 + .../TrackerMap/android/devices/DevicesAdapter.kt | 24 +- androidApp/src/main/res/layout/unit_item.xml | 314 +++++++++++---------- 3 files changed, 170 insertions(+), 169 deletions(-) diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 0e25404..01508ac 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -36,5 +36,6 @@ dependencies { implementation("androidx.core:core-ktx:1.7.0") implementation("androidx.fragment:fragment-ktx:1.4.0") implementation("io.ktor:ktor-client-serialization:1.6.6") + implementation("com.github.zerobranch:SwipeLayout:1.3.1") implementation(group = "", name = "WhirlyGlobeMaply", ext = "aar") } \ No newline at end of file diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt index c54e8bf..4852757 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt @@ -32,8 +32,6 @@ class DevicesAdapter( } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - holder.toggleOptions(false) - val unit = units[position] val context = holder.itemView.context holder.binding.apply { @@ -86,25 +84,5 @@ class DevicesAdapter( override fun getItemCount(): Int = units.size - inner class ViewHolder(val binding: UnitItemBinding) : RecyclerView.ViewHolder(binding.root) { - init { - binding.unitCard.setOnLongClickListener { - toggleOptions(binding.itemOptions.visibility == View.GONE) - true - } - } - - fun toggleOptions(shouldExpand: Boolean) { - val context = binding.root.context - binding.unitCard.setCardBackgroundColor( - ResourcesCompat.getColor( - context.resources, - if (shouldExpand) R.color.background else R.color.darkBackground, - context.theme - ) - ) - binding.itemOptions.visibility = if (shouldExpand) View.VISIBLE else View.GONE - binding.unitCard.cardElevation = if (shouldExpand) 5.0F else 0.0F - } - } + inner class ViewHolder(val binding: UnitItemBinding) : RecyclerView.ViewHolder(binding.root) } \ No newline at end of file diff --git a/androidApp/src/main/res/layout/unit_item.xml b/androidApp/src/main/res/layout/unit_item.xml index f7ace03..8b6b667 100644 --- a/androidApp/src/main/res/layout/unit_item.xml +++ b/androidApp/src/main/res/layout/unit_item.xml @@ -1,173 +1,195 @@ - - - - - + + + + - - + + + android:layout_height="match_parent" + android:layout_marginHorizontal="8dp" + android:layout_weight="1" + android:text="@string/unit_reports" + android:textColor="@color/colorAccent" + android:textSize="12sp" + style="?borderlessButtonStyle" /> + + - + - + + + android:animateLayoutChanges="true"> - - - - - - + android:layout_marginEnd="5dp" + android:src="@drawable/ic_baseline_fiber_manual_record_24" + app:tint="?android:textColorPrimary" /> + android:layout_toEndOf="@id/statusIcon" + android:visibility="gone" + android:layout_marginEnd="5dp" + android:src="@drawable/ic_baseline_lock_24" /> - - + android:layout_toEndOf="@id/engineStopIcon" + style="@style/TextAppearance.AppCompat.Body2" + tools:text="1AAUTO" /> - - - - - - - - - - - - - - - - - - \ No newline at end of file + android:layout_below="@id/unitName"> + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3