From 9c4a6c1f99c7bfcbe1e045b21c37fe106a09b198 Mon Sep 17 00:00:00 2001 From: Kyle Agronick Date: Sun, 17 Dec 2023 12:54:57 -0500 Subject: [PATCH] fix: better overlap calculation --- app/src/main/java/com/agronick/launcher/App.kt | 2 +- app/src/main/java/com/agronick/launcher/Container.kt | 9 +-------- app/src/main/java/com/agronick/launcher/Reorderer.kt | 5 +++-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/agronick/launcher/App.kt b/app/src/main/java/com/agronick/launcher/App.kt index 44ae807..5be1f11 100644 --- a/app/src/main/java/com/agronick/launcher/App.kt +++ b/app/src/main/java/com/agronick/launcher/App.kt @@ -10,7 +10,7 @@ import util.geometry.Vector2 class App(val pkgInfo: PInfo, var size: Int) { var left = 0.0f var top = 0.0f - var drawLast = false + var zIndex = -1 var hidden = false var assignedPos: Pair? = null private var lastCircle: Circle? = null diff --git a/app/src/main/java/com/agronick/launcher/Container.kt b/app/src/main/java/com/agronick/launcher/Container.kt index 89a9223..2a7a263 100644 --- a/app/src/main/java/com/agronick/launcher/Container.kt +++ b/app/src/main/java/com/agronick/launcher/Container.kt @@ -97,14 +97,7 @@ class Container(val appList: AppListProvider, density: Float) { } fun draw(canvas: Canvas) { - flatAppList.filter { - return@filter if (it.drawLast) { - true - } else { - it.drawNormal(canvas) - false - } - }.forEach { + flatAppList.sortedBy { it.zIndex }.forEach { it.drawNormal(canvas) } } diff --git a/app/src/main/java/com/agronick/launcher/Reorderer.kt b/app/src/main/java/com/agronick/launcher/Reorderer.kt index 78d2cc8..45a798e 100644 --- a/app/src/main/java/com/agronick/launcher/Reorderer.kt +++ b/app/src/main/java/com/agronick/launcher/Reorderer.kt @@ -18,7 +18,7 @@ class Reorderer( private val appList = container.appList init { - app.drawLast = true + app.zIndex = 2 lastPosition.add(app) suppressedAppCopy.hidden = true ValueAnimator.ofInt(app.size, (app.size * 1.4).toInt()) @@ -59,7 +59,7 @@ class Reorderer( playTogether(xAnim, yAnim) doOnEnd { lastPosition.remove(app) - app.drawLast = false + app.zIndex = -1 } start() } @@ -69,6 +69,7 @@ class Reorderer( if (overApp == null) { animateAppPosition(app, suppressedAppCopy.left, suppressedAppCopy.top) } else { + overApp.zIndex = 1 Timber.i("Sending ${overApp} to ${suppressedAppCopy.left} ${suppressedAppCopy.top}") animateAppPosition(overApp, suppressedAppCopy.left, suppressedAppCopy.top) Timber.i("Sending ${app} to ${overApp.left} ${overApp.top}")