Merge "[Sound Panel] Fix bugs for sound panel slice" into tm-qpr-dev
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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 */);
|
||||
})
|
||||
|
Reference in New Issue
Block a user