Skip to content

Commit 9c4a6c1

Browse files
committed
fix: better overlap calculation
1 parent 64c2b55 commit 9c4a6c1

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

app/src/main/java/com/agronick/launcher/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import util.geometry.Vector2
1010
class App(val pkgInfo: PInfo, var size: Int) {
1111
var left = 0.0f
1212
var top = 0.0f
13-
var drawLast = false
13+
var zIndex = -1
1414
var hidden = false
1515
var assignedPos: Pair<Int, Int>? = null
1616
private var lastCircle: Circle? = null

app/src/main/java/com/agronick/launcher/Container.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,7 @@ class Container(val appList: AppListProvider, density: Float) {
9797
}
9898

9999
fun draw(canvas: Canvas) {
100-
flatAppList.filter {
101-
return@filter if (it.drawLast) {
102-
true
103-
} else {
104-
it.drawNormal(canvas)
105-
false
106-
}
107-
}.forEach {
100+
flatAppList.sortedBy { it.zIndex }.forEach {
108101
it.drawNormal(canvas)
109102
}
110103
}

app/src/main/java/com/agronick/launcher/Reorderer.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Reorderer(
1818
private val appList = container.appList
1919

2020
init {
21-
app.drawLast = true
21+
app.zIndex = 2
2222
lastPosition.add(app)
2323
suppressedAppCopy.hidden = true
2424
ValueAnimator.ofInt(app.size, (app.size * 1.4).toInt())
@@ -59,7 +59,7 @@ class Reorderer(
5959
playTogether(xAnim, yAnim)
6060
doOnEnd {
6161
lastPosition.remove(app)
62-
app.drawLast = false
62+
app.zIndex = -1
6363
}
6464
start()
6565
}
@@ -69,6 +69,7 @@ class Reorderer(
6969
if (overApp == null) {
7070
animateAppPosition(app, suppressedAppCopy.left, suppressedAppCopy.top)
7171
} else {
72+
overApp.zIndex = 1
7273
Timber.i("Sending ${overApp} to ${suppressedAppCopy.left} ${suppressedAppCopy.top}")
7374
animateAppPosition(overApp, suppressedAppCopy.left, suppressedAppCopy.top)
7475
Timber.i("Sending ${app} to ${overApp.left} ${overApp.top}")

0 commit comments

Comments
 (0)