commit | 8ed63631dda642a6dc503d04e6152cadc4dcc888 | [log] [tgz] |
---|---|---|
author | Abdullah Tabassum <abdullahirum@google.com> | Fri Apr 28 00:03:43 2023 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Apr 28 00:03:43 2023 +0000 |
tree | 47d788c04f0f3926ab6d0c99113283dd187ce056 | |
parent | d0ab23393600714d7a708549236ed25bfdfcfee4 [diff] | |
parent | be6f23f0338457b51b3a40c157e60b2991581a93 [diff] |
Merge "Restore selected color position" into udc-dev am: be6f23f033 Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/22889905 Change-Id: I63d3964f4c922c9ef3613f2f7b9b9f1134ee5b41 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/customization/picker/color/ui/binder/ColorPickerBinder.kt b/src/com/android/customization/picker/color/ui/binder/ColorPickerBinder.kt index 3dba27e..3eadec5 100644 --- a/src/com/android/customization/picker/color/ui/binder/ColorPickerBinder.kt +++ b/src/com/android/customization/picker/color/ui/binder/ColorPickerBinder.kt
@@ -92,6 +92,22 @@ launch { viewModel.colorOptions.collect { colorOptions -> colorOptionAdapter.setItems(colorOptions) + // the same recycler view is used for different color types tabs + // the scroll state of each tab should be independent of others + var indexToFocus = 0 + colorOptions.forEachIndexed { index, colorOption -> + if (colorOption.isSelected.value) { + indexToFocus = index + } + } + val linearLayoutManager = + object : LinearLayoutManager(view.context, HORIZONTAL, false) { + override fun onLayoutCompleted(state: RecyclerView.State?) { + super.onLayoutCompleted(state) + scrollToPosition(indexToFocus) + } + } + colorOptionContainerView.layoutManager = linearLayoutManager } } }