Merge "[Sound Panel] Fix bugs for sound panel slice" into tm-qpr-dev am: 02cf722b24

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/19636172

Change-Id: Ia485be78358748e474650b76c3035d8787a3d33d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Shaowei Shen
2022-10-24 13:20:55 +00:00
committed by Automerger Merge Worker
4 changed files with 71 additions and 15 deletions

View File

@@ -64,7 +64,9 @@ public class MediaOutputUtils {
+ ", play back type : " + pi.getPlaybackType() + ", play back state : "
+ playbackState.getState());
}
if (playbackState.getState() != PlaybackState.STATE_PLAYING) {
if (playbackState.getState() == PlaybackState.STATE_STOPPED
|| playbackState.getState() == PlaybackState.STATE_NONE
|| playbackState.getState() == PlaybackState.STATE_ERROR) {
// do nothing
continue;
}

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;
}

View File

@@ -84,7 +84,7 @@ public class PanelSlicesAdapter
@Override
public void onBindViewHolder(@NonNull SliceRowViewHolder sliceRowViewHolder, int position) {
sliceRowViewHolder.onBind(mSliceLiveData.get(position), position);
sliceRowViewHolder.onBind(mSliceLiveData.get(position).getValue());
}
/**
@@ -132,15 +132,14 @@ public class PanelSlicesAdapter
/**
* Called when the view is displayed.
*/
public void onBind(LiveData<Slice> sliceLiveData, int position) {
sliceLiveData.observe(mPanelFragment.getViewLifecycleOwner(), sliceView);
// Do not show the divider above media devices switcher slice per request
final Slice slice = sliceLiveData.getValue();
public void onBind(Slice slice) {
// Hides slice which reports with error hint or not contain any slice sub-item.
if (slice == null || !isValidSlice(slice)) {
sliceView.setVisibility(View.GONE);
return;
} else {
sliceView.setSlice(slice);
sliceView.setVisibility(View.VISIBLE);
}
// Add divider for the end icon
@@ -154,7 +153,7 @@ public class PanelSlicesAdapter
.action(0 /* attribution */,
SettingsEnums.ACTION_PANEL_INTERACTION,
mMetricsCategory,
sliceLiveData.getValue().getUri().getLastPathSegment()
slice.getUri().getLastPathSegment()
/* log key */,
eventInfo.actionType /* value */);
})