mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Prevent requestLayout() when updating drawables that don't change size
Fix: 354224963 Test: presubmits passing, manual Flag: com.android.launcher3.enable_refactor_task_thumbnail Change-Id: I31d9a51ed621f411bcafbb5bf885ee2587df057f
This commit is contained in:
@@ -19,19 +19,19 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<ImageView
|
||||
<com.android.quickstep.views.FixedSizeImageView
|
||||
android:id="@+id/task_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="matrix"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<com.android.quickstep.task.thumbnail.LiveTileView
|
||||
android:id="@+id/task_thumbnail_live_tile"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/task_thumbnail_scrim"
|
||||
@@ -44,10 +44,11 @@
|
||||
android:id="@+id/splash_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/black"
|
||||
android:alpha="0"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<ImageView
|
||||
<com.android.quickstep.views.FixedSizeImageView
|
||||
android:id="@+id/splash_icon"
|
||||
android:layout_width="@dimen/task_thumbnail_splash_icon_size"
|
||||
android:layout_height="@dimen/task_thumbnail_splash_icon_size"
|
||||
|
||||
@@ -24,10 +24,9 @@ import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewOutlineProvider
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.isInvisible
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.Utilities
|
||||
import com.android.launcher3.util.ViewPool
|
||||
@@ -40,6 +39,7 @@ import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.SnapshotSplash
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.Uninitialized
|
||||
import com.android.quickstep.task.viewmodel.TaskThumbnailViewModel
|
||||
import com.android.quickstep.util.TaskCornerRadius
|
||||
import com.android.quickstep.views.FixedSizeImageView
|
||||
import com.android.systemui.shared.system.QuickStepContract
|
||||
import kotlin.math.abs
|
||||
import kotlinx.coroutines.CoroutineName
|
||||
@@ -59,9 +59,9 @@ class TaskThumbnailView : ConstraintLayout, ViewPool.Reusable {
|
||||
|
||||
private val scrimView: View by lazy { findViewById(R.id.task_thumbnail_scrim) }
|
||||
private val liveTileView: LiveTileView by lazy { findViewById(R.id.task_thumbnail_live_tile) }
|
||||
private val thumbnailView: ImageView by lazy { findViewById(R.id.task_thumbnail) }
|
||||
private val thumbnailView: FixedSizeImageView by lazy { findViewById(R.id.task_thumbnail) }
|
||||
private val splashBackground: View by lazy { findViewById(R.id.splash_background) }
|
||||
private val splashIcon: ImageView by lazy { findViewById(R.id.splash_icon) }
|
||||
private val splashIcon: FixedSizeImageView by lazy { findViewById(R.id.splash_icon) }
|
||||
|
||||
private var uiState: TaskThumbnailUiState = Uninitialized
|
||||
private var inheritedScale: Float = 1f
|
||||
@@ -173,8 +173,8 @@ class TaskThumbnailView : ConstraintLayout, ViewPool.Reusable {
|
||||
}
|
||||
|
||||
private fun resetViews() {
|
||||
liveTileView.isVisible = false
|
||||
thumbnailView.isVisible = false
|
||||
liveTileView.isInvisible = true
|
||||
thumbnailView.isInvisible = true
|
||||
splashBackground.alpha = 0f
|
||||
splashIcon.alpha = 0f
|
||||
scrimView.alpha = 0f
|
||||
@@ -186,7 +186,7 @@ class TaskThumbnailView : ConstraintLayout, ViewPool.Reusable {
|
||||
}
|
||||
|
||||
private fun drawLiveWindow() {
|
||||
liveTileView.isVisible = true
|
||||
liveTileView.isInvisible = false
|
||||
}
|
||||
|
||||
private fun drawSnapshotSplash(snapshotSplash: SnapshotSplash) {
|
||||
@@ -199,7 +199,7 @@ class TaskThumbnailView : ConstraintLayout, ViewPool.Reusable {
|
||||
private fun drawSnapshot(snapshot: Snapshot) {
|
||||
drawBackground(snapshot.backgroundColor)
|
||||
thumbnailView.setImageBitmap(snapshot.bitmap)
|
||||
thumbnailView.isVisible = true
|
||||
thumbnailView.isInvisible = false
|
||||
setImageMatrix()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.quickstep.views
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
|
||||
/**
|
||||
* An [ImageView] that does not requestLayout() unless setLayoutParams is called.
|
||||
*
|
||||
* This is useful, particularly during animations, for [ImageView]s that are not supposed to be
|
||||
* resized.
|
||||
*/
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
class FixedSizeImageView : ImageView {
|
||||
private var shouldRequestLayoutOnChanges = false
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
) : super(context, attrs, defStyleAttr)
|
||||
|
||||
override fun setLayoutParams(params: ViewGroup.LayoutParams?) {
|
||||
shouldRequestLayoutOnChanges = true
|
||||
super.setLayoutParams(params)
|
||||
shouldRequestLayoutOnChanges = false
|
||||
}
|
||||
|
||||
override fun requestLayout() {
|
||||
if (shouldRequestLayoutOnChanges) {
|
||||
super.requestLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user