Skip to content

Commit

Permalink
fix: better overlap calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
agronick committed Dec 17, 2023
1 parent 64c2b55 commit 9c4a6c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/agronick/launcher/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int, Int>? = null
private var lastCircle: Circle? = null
Expand Down
9 changes: 1 addition & 8 deletions app/src/main/java/com/agronick/launcher/Container.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/agronick/launcher/Reorderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -59,7 +59,7 @@ class Reorderer(
playTogether(xAnim, yAnim)
doOnEnd {
lastPosition.remove(app)
app.drawLast = false
app.zIndex = -1
}
start()
}
Expand All @@ -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}")
Expand Down

0 comments on commit 9c4a6c1

Please sign in to comment.