[Sound Panel] Fix bugs for sound panel slice

1. notify item change when slice live data has update
2. keep showing Output Switcher slice when media state is in "Pause"
   state

Bug: 247043239
Bug: 238715094
Bug: 204165377
Test: verified on device
Change-Id: Ic56a70f2f2835231519e2fccf0d2e649d41b106e
This commit is contained in:
shaoweishen
2022-08-18 03:52:05 +00:00
committed by Shaowei Shen
parent 062b18c736
commit 66098febbc
4 changed files with 71 additions and 15 deletions

View File

@@ -60,6 +60,7 @@ import com.android.settingslib.utils.ThreadUtils;
import com.google.android.setupdesign.DividerItemDecoration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
@@ -339,8 +340,13 @@ public class PanelFragment extends Fragment {
mSliceLiveData.put(uri, sliceLiveData);
sliceLiveData.observe(getViewLifecycleOwner(), slice -> {
// If the Slice has already loaded, do nothing.
// If the Slice has already loaded, refresh list with slice data.
if (mPanelSlicesLoaderCountdownLatch.isSliceLoaded(uri)) {
if (mAdapter != null) {
int itemIndex = (new ArrayList<>(mSliceLiveData.keySet())).indexOf(uri);
mAdapter.notifyItemChanged(itemIndex);
}
return;
}