From b455d58c0300cf7aaca6ee998b15a5e7e39ed1a9 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Mon, 16 Sep 2019 15:09:40 +0800 Subject: [PATCH] Only add divider in recyclerView once Only add divider in recyclerView once or more and more dividers will be set in recyclerView. Change-Id: I765ed888d460be221341dafe3521a849b8dd3889 Fix: 139452947 Test: Show panel many times and see the divider. --- src/com/android/settings/panel/PanelFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java index 54d9e8d8b90..0ac80799dff 100644 --- a/src/com/android/settings/panel/PanelFragment.java +++ b/src/com/android/settings/panel/PanelFragment.java @@ -276,10 +276,12 @@ public class PanelFragment extends Fragment { .addOnGlobalLayoutListener(mOnGlobalLayoutListener); mPanelSlices.setVisibility(View.VISIBLE); - DividerItemDecoration itemDecoration = new DividerItemDecoration(getActivity()); + final DividerItemDecoration itemDecoration = new DividerItemDecoration(getActivity()); itemDecoration .setDividerCondition(DividerItemDecoration.DIVIDER_CONDITION_BOTH); - mPanelSlices.addItemDecoration(itemDecoration); + if (mPanelSlices.getItemDecorationCount() == 0) { + mPanelSlices.addItemDecoration(itemDecoration); + } } }