mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-05-22 13:34:11 +02:00
show a shadow at dragging from All Apps Fragment too
This commit is contained in:
parent
1ec3112032
commit
6cf61d534a
@ -206,27 +206,29 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||||||
}
|
}
|
||||||
|
|
||||||
item.drawable!!.draw(canvas)
|
item.drawable!!.draw(canvas)
|
||||||
} else if (draggedItemCurrentCoords.first != -1 && draggedItemCurrentCoords.second != -1) {
|
}
|
||||||
// draw a circle under the current cell
|
}
|
||||||
val center = gridCenters.minBy { Math.abs(it.first - draggedItemCurrentCoords.first) + Math.abs(it.second - draggedItemCurrentCoords.second) }
|
|
||||||
val gridCells = getClosestGridCells(center)
|
|
||||||
if (gridCells != null) {
|
|
||||||
val shadowX = rowXCoords[gridCells.first] + iconMargin.toFloat() + iconSize / 2
|
|
||||||
val shadowY = if (gridCells.second == ROW_COUNT - 1) {
|
|
||||||
rowYCoords[gridCells.second] + rowHeight - iconSize / 2 - iconMargin * 2
|
|
||||||
} else {
|
|
||||||
rowYCoords[gridCells.second] + iconSize
|
|
||||||
}
|
|
||||||
|
|
||||||
canvas.drawCircle(shadowX, shadowY.toFloat(), iconSize / 2f, dragShadowCirclePaint)
|
if (draggedItem != null && draggedItemCurrentCoords.first != -1 && draggedItemCurrentCoords.second != -1) {
|
||||||
|
// draw a circle under the current cell
|
||||||
|
val center = gridCenters.minBy { Math.abs(it.first - draggedItemCurrentCoords.first) + Math.abs(it.second - draggedItemCurrentCoords.second) }
|
||||||
|
val gridCells = getClosestGridCells(center)
|
||||||
|
if (gridCells != null) {
|
||||||
|
val shadowX = rowXCoords[gridCells.first] + iconMargin.toFloat() + iconSize / 2
|
||||||
|
val shadowY = if (gridCells.second == ROW_COUNT - 1) {
|
||||||
|
rowYCoords[gridCells.second] + rowHeight - iconSize / 2 - iconMargin * 2
|
||||||
|
} else {
|
||||||
|
rowYCoords[gridCells.second] + iconSize
|
||||||
}
|
}
|
||||||
|
|
||||||
// show the icon itself at dragging
|
canvas.drawCircle(shadowX, shadowY.toFloat(), iconSize / 2f, dragShadowCirclePaint)
|
||||||
val drawableX = draggedItemCurrentCoords.first - iconSize
|
|
||||||
val drawableY = draggedItemCurrentCoords.second - (iconSize * 1.5f).toInt()
|
|
||||||
item.drawable!!.setBounds(drawableX, drawableY, drawableX + iconSize, drawableY + iconSize)
|
|
||||||
item.drawable!!.draw(canvas)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show the app icon itself at dragging
|
||||||
|
val drawableX = draggedItemCurrentCoords.first - iconSize
|
||||||
|
val drawableY = draggedItemCurrentCoords.second - (iconSize * 1.5f).toInt()
|
||||||
|
draggedItem!!.drawable!!.setBounds(drawableX, drawableY, drawableX + iconSize, drawableY + iconSize)
|
||||||
|
draggedItem!!.drawable!!.draw(canvas)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user