Merge "[BugFix] Automatically slide to the active player each time tapping a media recommendation." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7a1e137d0d
@@ -115,7 +115,7 @@ class MediaCarouselController @Inject constructor(
|
||||
private var needsReordering: Boolean = false
|
||||
private var keysNeedRemoval = mutableSetOf<String>()
|
||||
private var bgColor = getBackgroundColor()
|
||||
private var shouldScrollToActivePlayer: Boolean = false
|
||||
protected var shouldScrollToActivePlayer: Boolean = false
|
||||
private var isRtl: Boolean = false
|
||||
set(value) {
|
||||
if (value != field) {
|
||||
@@ -309,7 +309,7 @@ class MediaCarouselController @Inject constructor(
|
||||
} else {
|
||||
existingPlayer.bindPlayer(dataCopy, key)
|
||||
MediaPlayerData.addMediaPlayer(key, dataCopy, existingPlayer)
|
||||
if (visualStabilityManager.isReorderingAllowed) {
|
||||
if (visualStabilityManager.isReorderingAllowed || shouldScrollToActivePlayer) {
|
||||
reorderAllPlayers()
|
||||
} else {
|
||||
needsReordering = true
|
||||
@@ -340,7 +340,7 @@ class MediaCarouselController @Inject constructor(
|
||||
val lp = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
newRecs.recommendationViewHolder?.recommendations?.setLayoutParams(lp)
|
||||
newRecs.bindRecommendation(data, bgColor, { v -> shouldScrollToActivePlayer = true })
|
||||
newRecs.bindRecommendation(data, bgColor)
|
||||
MediaPlayerData.addMediaRecommendation(key, newRecs)
|
||||
updatePlayerToState(newRecs, noAnimation = true)
|
||||
reorderAllPlayers()
|
||||
@@ -656,7 +656,7 @@ class MediaCarouselController @Inject constructor(
|
||||
@VisibleForTesting
|
||||
internal object MediaPlayerData {
|
||||
private val EMPTY = MediaData(-1, false, 0, null, null, null, null, null,
|
||||
emptyList(), emptyList(), "INVALID", null, null, null, false, null)
|
||||
emptyList(), emptyList(), "INVALID", null, null, null, true, null)
|
||||
|
||||
data class MediaSortKey(
|
||||
// Is Smartspace media recommendation. When the Smartspace media is present, it should
|
||||
@@ -709,7 +709,7 @@ internal object MediaPlayerData {
|
||||
/** Returns the index of the first non-timeout media. */
|
||||
fun getActiveMediaIndex(): Int {
|
||||
mediaPlayers.entries.forEachIndexed { index, e ->
|
||||
if (e.key.data.active) {
|
||||
if (!e.key.isSsMediaRec && e.key.data.active) {
|
||||
return index
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,10 +473,7 @@ public class MediaControlPanel {
|
||||
}
|
||||
|
||||
/** Bind this recommendation view based on the data given. */
|
||||
public void bindRecommendation(
|
||||
@NonNull SmartspaceTarget target,
|
||||
@NonNull int backgroundColor,
|
||||
@Nullable View.OnClickListener callback) {
|
||||
public void bindRecommendation(@NonNull SmartspaceTarget target, @NonNull int backgroundColor) {
|
||||
if (mRecommendationViewHolder == null) {
|
||||
return;
|
||||
}
|
||||
@@ -536,10 +533,7 @@ public class MediaControlPanel {
|
||||
mediaCoverImageView.setImageIcon(recommendation.getIcon());
|
||||
|
||||
// Set up the click listener if applicable.
|
||||
setSmartspaceRecItemOnClickListener(
|
||||
mediaCoverImageView,
|
||||
recommendation,
|
||||
callback);
|
||||
setSmartspaceRecItemOnClickListener(mediaCoverImageView, recommendation);
|
||||
|
||||
if (uiComponentIndex < MEDIA_RECOMMENDATION_ITEMS_PER_ROW) {
|
||||
setVisibleAndAlpha(collapsedSet,
|
||||
@@ -667,8 +661,7 @@ public class MediaControlPanel {
|
||||
|
||||
private void setSmartspaceRecItemOnClickListener(
|
||||
@NonNull View view,
|
||||
@NonNull SmartspaceAction action,
|
||||
@Nullable View.OnClickListener callback) {
|
||||
@NonNull SmartspaceAction action) {
|
||||
if (view == null || action == null || action.getIntent() == null) {
|
||||
Log.e(TAG, "No tap action can be set up");
|
||||
return;
|
||||
@@ -691,9 +684,8 @@ public class MediaControlPanel {
|
||||
view.getContext().startActivity(action.getIntent());
|
||||
}
|
||||
|
||||
if (callback != null) {
|
||||
callback.onClick(v);
|
||||
}
|
||||
// Automatically scroll to the active player once the media is loaded.
|
||||
mMediaCarouselController.setShouldScrollToActivePlayer(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user