Files
Flexera-Launcher/src/com/android/launcher3/folder/FolderSpringAnimatorSet.kt
T
TMCandClaude Fable 5.2 38e93c3889 Folders: real icons for every app, and a fade in place when full screen
A folder opened soon after the launcher started could show blank spots
where some of its apps should be. Apps in a folder, other than those in
its icon's preview, were loaded as placeholders, and their icons were
fetched when the folder opened, on the model thread, which is busy with
the rest of the load for a while after every start and reload. With
labels off and no panel behind a full-screen folder, the placeholders
looked like missing apps. Reported from the owner's phone on 2026-11-16
(a nine-app folder showing its first row only, until some time later).
Seen on the emulator with the 1.0.2 release by restarting the launcher
and opening a folder three seconds later: two of its seven apps were
placeholder discs for about a quarter of a second. Every app in a folder
now gets its icon with the home screen's own (WorkspaceItemProcessor).

A full-screen folder fades in and out where it is
(FolderSpringAnimatorSet.buildInPlace). Its apps are at the bottom of
the screen, not at its icon, and the floating folder's animation, which
moves and scales every app between the icon's preview and its place,
looked over that distance like the apps rearranging themselves. The
folder's icon stays as it is behind the dimmed home screen. A folder
that a drag opens still floats and animates as before.

App views taken from the cache for a folder start at rest (alpha,
translation, scale, locked to the grid), in case an animation that was
cut short left one otherwise.

Checked on the emulator with a debug build: a folder opened about three
seconds after a restart shows every icon from its first frame; opening
and closing is a fade with nothing moving; six fast open, close and
reopen sequences over five folders drew every app, with no crash. Not
checked: a folder opened by dragging an app onto it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-16 16:57:34 +01:00

692 lines
29 KiB
Kotlin

/*
* Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.folder
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.util.FloatProperty
import android.view.View
import androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_ALPHA
import androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS
import androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_SCALE
import com.android.app.animation.Interpolators
import com.android.launcher3.BubbleTextView
import com.android.launcher3.LauncherAnimUtils
import com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY
import com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_FOLDER_ANIM
import com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY
import com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA
import com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X
import com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y
import com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Z
import com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_FACTORY
import com.android.launcher3.LauncherState
import com.android.launcher3.R
import com.android.launcher3.Utilities.isDarkTheme
import com.android.launcher3.anim.SpringAnimationBuilder
import com.android.launcher3.apppairs.AppPairIcon
import com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW
import com.android.launcher3.util.MultiPropertyFactory
import com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE
/** Holder for Animators created from [FolderAnimationSpringBuilderManager] */
class FolderSpringAnimatorSet(val animatorSet: AnimatorSet) {
fun start() {
animatorSet.start()
}
companion object Factory {
private const val LAUNCHER_SCALE = 0.975f
private const val FOLDER_NAME_ALPHA_DURATION = 32
private const val LARGE_FOLDER_FOOTER_DURATION = 128
private const val STIFFNESS_SHAPE_POSITION = 380f
private const val DAMPING_SHAPE_POSITION = 0.8f
private const val STIFFNESS_ALPHA = 1600f
private const val DAMPING_ALPHA = 0.9f
private const val STIFFNESS_LAUNCHER_SCRIM = 380f
private const val DAMPING_LAUNCHER_SCRIM = 0.98f
private const val WALLPAPER_ZOOM = 0.125f
/**
* Factory method to take data calculated from [FolderAnimationSpringBuilderManager], and
* create a [FolderSpringAnimatorSet] with [SpringAnimationBuilder].
*/
fun build(
folder: Folder,
launcherDelegate: LauncherDelegate,
folderAnimData: FolderAnimationData,
clipRevealData: ClipRevealData,
iconAnimData: List<IconAnimationData>,
): FolderSpringAnimatorSet {
val animatorSet = AnimatorSet()
setupFolder(folder, folderAnimData)
addFolderScaleAndTranslateAnimators(folder, animatorSet, folderAnimData)
addClipRevealAnimators(folder, animatorSet, clipRevealData)
addAlphaAndColorAnimators(folder, animatorSet, folderAnimData)
addWorkspaceAnimators(
folder.context,
animatorSet,
folderAnimData.isOpening,
launcherDelegate,
folder.isFullScreen, // Flexera Launcher: see finalScrimAlpha.
)
launcherDelegate.launcher?.depthController?.folderZoom?.let {
addWallpaperZoomAnimator(folder.context, animatorSet, folderAnimData.isOpening, it)
}
// Flexera Launcher: the blur behind the folder (app.flexera.home.FolderBlur).
addBackdropBlurAnimator(
folder.context,
animatorSet,
folderAnimData.isOpening,
launcherDelegate,
folder.isFullScreen,
)
iconAnimData.forEach { addContentIconAnimators(folder.context, animatorSet, it) }
return FolderSpringAnimatorSet(animatorSet)
}
/** Flexera Launcher: how long a full-screen folder takes to fade in, and to fade out. */
private const val IN_PLACE_FADE_IN_MS = 200L
private const val IN_PLACE_FADE_OUT_MS = 140L
/**
* Flexera Launcher: the animation of a full-screen folder
* (app.flexera.home.FullScreenFolders). Its apps are at the bottom of the screen, not
* where its icon is, so nothing comes out of the icon or goes back into it: the apps, the
* name and the page dots stay where they are and fade in, or out, while the home screen
* behind dims and blurs as before. (The floating folder's animation, [build], moves and
* scales every app between the icon's preview and its place, which over that distance
* looked like the apps rearranging themselves.)
*/
fun buildInPlace(
folder: Folder,
launcherDelegate: LauncherDelegate,
isOpening: Boolean,
): FolderSpringAnimatorSet {
val animatorSet = AnimatorSet()
// Everything at rest. The folder may have floated the last time it opened (a drag
// opens it that way), and its app views are shared with the other folders.
folder.apply {
translationX = 0f
translationY = 0f
translationZ = 0f
setClipPath(null)
}
folder.content.apply {
scaleX = 1f
scaleY = 1f
setClipPath(null)
}
folder.mFooter.apply {
scaleX = 1f
scaleY = 1f
translationX = 0f
translationY = 0f
alpha = 1f
}
folder.folderName.alpha = 1f
folder.iconsInReadingOrder.forEach {
it.alpha = 1f
it.translationX = 0f
it.translationY = 0f
it.scaleX = 1f
it.scaleY = 1f
}
// Opening starts from nothing; closing from however much is showing, which is less
// than all of it when the folder is closed while it is still fading in.
if (isOpening) folder.alpha = 0f
animatorSet.play(
ObjectAnimator.ofFloat(folder, VIEW_ALPHA, if (isOpening) 1f else 0f).apply {
duration = if (isOpening) IN_PLACE_FADE_IN_MS else IN_PLACE_FADE_OUT_MS
interpolator = if (isOpening) Interpolators.DECELERATE else Interpolators.LINEAR
}
)
addWorkspaceAnimators(folder.context, animatorSet, isOpening, launcherDelegate, true)
launcherDelegate.launcher?.depthController?.folderZoom?.let {
addWallpaperZoomAnimator(folder.context, animatorSet, isOpening, it)
}
addBackdropBlurAnimator(folder.context, animatorSet, isOpening, launcherDelegate, true)
animatorSet.addListener(
object : AnimatorListenerAdapter() {
private var cancelled = false
override fun onAnimationCancel(animation: Animator) {
cancelled = true
}
override fun onAnimationEnd(animation: Animator) {
// Closed, the folder is taken off the screen next (Folder.closeComplete)
// and has to be whole for its next opening. Opened, it is whole, unless a
// closing has taken over, which goes on from where this one stopped.
if (!isOpening || !cancelled) folder.alpha = 1f
}
}
)
return FolderSpringAnimatorSet(animatorSet)
}
private fun <T : Any> playSpringAnimation(
context: Context,
animatorSet: AnimatorSet,
isOpening: Boolean,
startDelay: Int,
stiffness: Float,
damping: Float,
startValue: Float,
endValue: Float,
minVisibleChange: Float,
property: FloatProperty<T>,
view: T,
) {
val animatorBuilder =
SpringAnimationBuilder(context)
.setStiffness(stiffness)
.setDampingRatio(damping)
.setStartValue(if (isOpening) startValue else endValue)
.setEndValue(if (isOpening) endValue else startValue)
.setMinimumVisibleChange(minVisibleChange)
val animator =
animatorBuilder.build(view, property).apply {
setStartDelay(startDelay.toLong())
}
animatorSet.play(animator)
}
private fun setupFolder(folder: Folder, folderAnimationData: FolderAnimationData) {
folder.folderIcon.previewItemManager.recomputePreviewDrawingParams()
folder.apply {
pivotX = 0f
pivotY = 0f
}
folder.content.apply {
scaleX = folderAnimationData.startScale
scaleY = folderAnimationData.startScale
pivotX = 0f
pivotY = 0f
}
folder.mFooter.apply {
scaleX = folderAnimationData.startScale
scaleY = folderAnimationData.startScale
pivotX = 0f
pivotY = 0f
}
}
private fun addFolderScaleAndTranslateAnimators(
folder: Folder,
animatorSet: AnimatorSet,
animationData: FolderAnimationData,
) {
val isOpening = animationData.isOpening
playSpringAnimation(
context = folder.context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = animationData.xDistance,
endValue = 0f,
minVisibleChange = MIN_VISIBLE_CHANGE_PIXELS,
property = VIEW_TRANSLATE_X,
view = folder,
)
playSpringAnimation(
context = folder.context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = animationData.yDistance,
endValue = 0f,
minVisibleChange = MIN_VISIBLE_CHANGE_PIXELS,
property = VIEW_TRANSLATE_Y,
view = folder,
)
playSpringAnimation(
context = folder.context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = animationData.initialFolderScale,
endValue = 1f,
minVisibleChange = MIN_VISIBLE_CHANGE_SCALE,
property = SCALE_PROPERTY,
view = folder.content,
)
playSpringAnimation(
context = folder.context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = animationData.initialFolderScale,
endValue = 1f,
minVisibleChange = MIN_VISIBLE_CHANGE_SCALE,
property = SCALE_PROPERTY,
view = folder.mFooter,
)
// Translate the footer so that it tracks the bottom of the content.
playSpringAnimation(
context = folder.context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = -(animationData.contentHeightDifference),
endValue = 0f,
minVisibleChange = MIN_VISIBLE_CHANGE_PIXELS,
property = VIEW_TRANSLATE_Y,
view = folder.mFooter,
)
// Animate the elevation midway so that the shadow is not noticeable in the background.
val midDuration = animationData.defaultDuration / 2
playSpringAnimation(
context = folder.context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = if (animationData.isOpening) midDuration else 0,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = -folder.elevation,
endValue = 0f,
minVisibleChange = MIN_VISIBLE_CHANGE_PIXELS,
property = VIEW_TRANSLATE_Z,
view = folder,
)
// store clip variables
animatorSet.addListener(
FolderOpenCloseAnimationListener(folder, animationData.isOpening)
)
}
private fun addWallpaperZoomAnimator(
context: Context,
animatorSet: AnimatorSet,
isOpening: Boolean,
property: MultiPropertyFactory<*>.MultiProperty,
) {
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = 0f,
endValue = WALLPAPER_ZOOM,
minVisibleChange = MIN_VISIBLE_CHANGE_SCALE,
property = MULTI_PROPERTY_VALUE,
view = property,
)
}
/**
* Flexera Launcher: blurs the home screen behind the folder as it opens, and clears it
* again as it closes, in step with the dimming. Closing always plays, also when the
* setting has been switched off since the folder was opened. A full-screen folder is
* blurred behind as strongly as the app drawer.
*/
private fun addBackdropBlurAnimator(
context: Context,
animatorSet: AnimatorSet,
isOpening: Boolean,
launcherDelegate: LauncherDelegate,
fullScreen: Boolean,
) {
val launcher = launcherDelegate.launcher ?: return
// As with the dimming: a folder in the app list leaves the list as it is.
if (launcher.isInState(LauncherState.ALL_APPS)) return
val blur = launcher.depthController?.folderBlur ?: return
val wanted =
if (isOpening) app.flexera.home.FolderBlur.isOn(context) else blur.value > 0f
if (!wanted) return
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_LAUNCHER_SCRIM,
damping = DAMPING_LAUNCHER_SCRIM,
startValue = 0f,
endValue = app.flexera.home.FolderBlur.strength(fullScreen),
minVisibleChange = MIN_VISIBLE_CHANGE_ALPHA,
property = MULTI_PROPERTY_VALUE,
view = blur,
)
}
private fun addAlphaAndColorAnimators(
folder: Folder,
animatorSet: AnimatorSet,
animationData: FolderAnimationData,
) {
with(folder) {
val folderBackground = folder.background as GradientDrawable
// Set up the Folder background (respects Lawnchair folder color pref).
val isOpening = animationData.isOpening
val initialColor = app.lawnchair.util.resolveFolderPreviewColor(context)
val finalColor = app.lawnchair.util.resolveFolderBackgroundColor(context)
folderBackground.mutate()
folderBackground.setColor(if (isOpening) initialColor else finalColor)
// TODO: convert to spring animation?
animatorSet.play(
ObjectAnimator.ofArgb(
folderBackground,
"color",
if (isOpening) initialColor else finalColor,
if (isOpening) finalColor else initialColor,
)
.apply { duration = animationData.defaultDuration.toLong() }
)
val footerAlphaDuration: Int
var footerStartDelay = 0
val isLargeFolder = folder.itemCount > MAX_NUM_ITEMS_IN_PREVIEW
if (isLargeFolder) {
if (isOpening) {
folder.mFooter.alpha = 0f
footerAlphaDuration = LARGE_FOLDER_FOOTER_DURATION
footerStartDelay = animationData.defaultDuration - footerAlphaDuration
}
}
playSpringAnimation(
context = folder.context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = if (animationData.isOpening) footerStartDelay else 0,
stiffness = STIFFNESS_ALPHA,
damping = DAMPING_ALPHA,
startValue = 0f,
endValue = 1f,
minVisibleChange = MIN_VISIBLE_CHANGE_ALPHA,
property = VIEW_ALPHA,
view = mFooter,
)
// Fade in the folder name, as the text can overlap the icons when grid size is
// small.
folder.folderName.alpha = if (animationData.isOpening) 0f else 1f
playSpringAnimation(
context = folder.context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = if (animationData.isOpening) FOLDER_NAME_ALPHA_DURATION else 0,
stiffness = STIFFNESS_ALPHA,
damping = DAMPING_ALPHA,
startValue = 0f,
endValue = 1f,
minVisibleChange = MIN_VISIBLE_CHANGE_ALPHA,
property = VIEW_ALPHA,
view = folderName,
)
}
}
private fun addClipRevealAnimators(
folder: Folder,
animatorSet: AnimatorSet,
revealData: ClipRevealData,
) {
with(revealData) {
// Clip reveal for folder background.
animatorSet.play(
shapeDelegate.createRevealAnimator(
target = folder,
startRect = backgroundStartRect,
endRect = backgroundEndRect,
endRadius = finalRadius,
isReversed = !isOpening,
)
)
if (!isOpening) {
// Clip reveal for folder content icons.
// Only necessary while closing, where content is not affected by clipPath.
animatorSet.play(
shapeDelegate.createRevealAnimator(
target = folder.content,
startRect = contentStart,
endRect = contentEnd,
endRadius = finalRadius,
isReversed = true,
)
)
}
}
}
private fun addWorkspaceAnimators(
context: Context,
animatorSet: AnimatorSet,
isOpening: Boolean,
launcherDelegate: LauncherDelegate,
fullScreen: Boolean, // Flexera Launcher: see finalScrimAlpha.
) {
val launcher = launcherDelegate.launcher ?: return
// Folder scrim uses a black overlay with alpha 0→dimmed; that replaces the app drawer
// scrim colors and starts fully transparent, so the list background disappears (#6551).
if (launcher.isInState(LauncherState.ALL_APPS)) {
return
}
val scrimView = launcher.scrimView
val workspace = launcher.workspace
val hotseat = launcher.hotseat
val workspaceScale = WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_FOLDER_ANIM)
val hotseatScale = HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_FOLDER_ANIM)
// Flexera Launcher: behind a full-screen folder, whose white labels have no panel
// behind them, as dark as behind the app drawer.
val finalScrimAlpha =
if (fullScreen) {
app.flexera.home.FullScreenFolders.dim()
} else if (isDarkTheme(context)) {
0.32f
} else {
0.2f
}
scrimView.setBackgroundColor(Color.BLACK)
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_LAUNCHER_SCRIM,
damping = DAMPING_LAUNCHER_SCRIM,
startValue = 0f,
endValue = finalScrimAlpha,
minVisibleChange = MIN_VISIBLE_CHANGE_ALPHA,
property = LauncherAnimUtils.VIEW_ALPHA,
view = scrimView,
)
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_LAUNCHER_SCRIM,
damping = DAMPING_LAUNCHER_SCRIM,
startValue = 1f,
endValue = LAUNCHER_SCALE,
minVisibleChange = MIN_VISIBLE_CHANGE_SCALE,
property = workspaceScale,
view = workspace,
)
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = 0,
stiffness = STIFFNESS_LAUNCHER_SCRIM,
damping = DAMPING_LAUNCHER_SCRIM,
startValue = 1f,
endValue = LAUNCHER_SCALE,
minVisibleChange = MIN_VISIBLE_CHANGE_SCALE,
property = hotseatScale,
view = hotseat,
)
animatorSet.addListener(FolderScrimAnimationListener(scrimView, isOpening, launcher))
}
/**
* Gets the [BubbleTextView] from an icon. In some cases the BubbleTextView is the whole
* icon itself, while in others it is contained within the view and only serves to store the
* title text.
*/
private fun getBubbleTextView(v: View): BubbleTextView {
return if (v is AppPairIcon) v.titleTextView else (v as BubbleTextView)
}
private fun addContentIconAnimators(
context: Context,
animatorSet: AnimatorSet,
iconData: IconAnimationData,
) {
with(iconData) {
val titleText = getBubbleTextView(icon)
if (isOpening) {
titleText.setTextVisibility(false)
}
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = if (isOpening) iconDelay + 100 else iconDelay,
stiffness = STIFFNESS_ALPHA,
damping = DAMPING_ALPHA,
startValue = 0f,
endValue = 1f,
minVisibleChange = MIN_VISIBLE_CHANGE_ALPHA,
property = BubbleTextView.TEXT_ALPHA_PROPERTY,
view = titleText,
)
if (!itemsInPreview.contains(icon)) {
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = iconDelay,
stiffness = STIFFNESS_ALPHA,
damping = DAMPING_ALPHA,
startValue = 0f,
endValue = 1f,
minVisibleChange = MIN_VISIBLE_CHANGE_ALPHA,
property = VIEW_ALPHA,
view = icon,
)
}
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = iconDelay,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = xDistance,
endValue = 0f,
minVisibleChange = MIN_VISIBLE_CHANGE_PIXELS,
property = VIEW_TRANSLATE_X,
view = icon,
)
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = iconDelay,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = yDistance,
endValue = 0f,
minVisibleChange = MIN_VISIBLE_CHANGE_PIXELS,
property = VIEW_TRANSLATE_Y,
view = icon,
)
playSpringAnimation(
context = context,
animatorSet = animatorSet,
isOpening = isOpening,
startDelay = iconDelay,
stiffness = STIFFNESS_SHAPE_POSITION,
damping = DAMPING_SHAPE_POSITION,
startValue = initialIconScale,
endValue = 1f,
minVisibleChange = MIN_VISIBLE_CHANGE_SCALE,
property = SCALE_PROPERTY,
view = icon,
)
animatorSet.addListener(
getIconAnimatorListener(
icon = icon,
xDistance = xDistance,
yDistance = yDistance,
initialScale = initialIconScale,
itemsInPreview = itemsInPreview,
isOpening = isOpening,
)
)
}
}
private fun getIconAnimatorListener(
icon: View,
xDistance: Float,
yDistance: Float,
initialScale: Float,
itemsInPreview: List<View>,
isOpening: Boolean,
) =
object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator) {
super.onAnimationStart(animation)
// Necessary to initialize values here because of the start delay.
if (isOpening) {
icon.translationX = xDistance
icon.translationY = yDistance
icon.scaleX = initialScale
icon.scaleY = initialScale
if (!itemsInPreview.contains(icon)) {
icon.alpha = 0f
}
}
}
override fun onAnimationEnd(animation: Animator) {
super.onAnimationEnd(animation)
icon.translationX = 0.0f
icon.translationY = 0.0f
icon.scaleX = 1f
icon.scaleY = 1f
if (!itemsInPreview.contains(icon)) {
icon.alpha = 1f
}
}
}
}
}