commit | 3de761e8eb281fa3075aa18dfc61979d3fbc68e8 | [log] [tgz] |
---|---|---|
author | Ale Nijamkin <nijamkin@google.com> | Mon Jan 23 21:19:30 2023 +0000 |
committer | Android (Google) Code Review <android-gerrit@google.com> | Mon Jan 23 21:19:30 2023 +0000 |
tree | a6a68c736894f73e51b94dbf35471b1b63fc9699 | |
parent | b968c7a46e6e6af1d8eaaafc518a09c7aff60436 [diff] | |
parent | 3e05a1e92cbca40d3d1fe612e060ab376d42cb51 [diff] |
Merge "Auto-scroll to the selected quick affordance." into tm-qpr-dev
diff --git a/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt b/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt index 74d38b1..30372fe 100644 --- a/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt +++ b/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt
@@ -74,6 +74,16 @@ launch { viewModel.quickAffordances.collect { affordances -> affordancesAdapter.setItems(affordances) + + // Scroll the view to show the first selected affordance. + val selectedPosition = affordances.indexOfFirst { it.isSelected } + if (selectedPosition != -1) { + // We use "post" because we need to give the adapter item a pass to + // update the view. + affordancesView.post { + affordancesView.smoothScrollToPosition(selectedPosition) + } + } } }