Reformat code

This commit is contained in:
Ensar Sarajčić 2023-08-03 16:58:18 +02:00
parent 651d3b041c
commit 36558b8949
3 changed files with 16 additions and 1 deletions

View file

@ -26,7 +26,12 @@ class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
setContentView(binding.root)
updateIcons()
updateMaterialActivityViews(binding.manageHiddenIconsCoordinator, binding.manageHiddenIconsList, useTransparentNavigation = true, useTopSearchMenu = false)
updateMaterialActivityViews(
binding.manageHiddenIconsCoordinator,
binding.manageHiddenIconsList,
useTransparentNavigation = true,
useTopSearchMenu = false
)
setupMaterialScrollListener(binding.manageHiddenIconsList, binding.manageHiddenIconsToolbar)
val layoutManager = binding.manageHiddenIconsList.layoutManager as MyGridLayoutManager

View file

@ -47,10 +47,12 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) {
currentCoords.y = event.rawY
actionDownMS = System.currentTimeMillis()
}
MotionEvent.ACTION_MOVE -> {
currentCoords.x = event.rawX
currentCoords.y = event.rawY
}
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
longPressHandler.removeCallbacksAndMessages(null)
}

View file

@ -123,6 +123,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
dragDirection = DRAGGING_BOTTOM
}
}
MotionEvent.ACTION_MOVE -> {
val minWidth = minResizeWidthCells * cellWidth
val minHeight = minResizeHeightCells * cellHeight
@ -153,6 +154,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.left = wantedLeft
}
DRAGGING_TOP -> {
val newHeight = frameRect.bottom - event.rawY.toInt()
val wantedTop = if (newHeight >= minHeight) {
@ -179,6 +181,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.top = wantedTop
}
DRAGGING_RIGHT -> {
val newWidth = event.rawX.toInt() - frameRect.left
val wantedRight = if (newWidth >= minWidth) {
@ -205,6 +208,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.right = wantedRight
}
DRAGGING_BOTTOM -> {
val newHeight = event.rawY.toInt() - frameRect.top
val wantedBottom = if (newHeight >= minHeight) {
@ -241,6 +245,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
redrawFrame()
}
}
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
if (dragDirection == DRAGGING_NONE) {
onClickListener?.invoke()
@ -269,6 +274,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.left = cellsRect.left * cellWidth + sideMargins.left
}
}
DRAGGING_TOP -> {
val wantedTop = roundToClosestMultiplyOfNumber(frameRect.top - sideMargins.top, cellHeight)
val wantedTopCellY = wantedTop / cellHeight
@ -289,6 +295,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.top = cellsRect.top * cellHeight + sideMargins.top
}
}
DRAGGING_RIGHT -> {
val wantedRight = roundToClosestMultiplyOfNumber(frameRect.right - sideMargins.left, cellWidth)
val wantedRightCellX = wantedRight / cellWidth - 1
@ -309,6 +316,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.right = (cellsRect.right + 1) * cellWidth + sideMargins.left
}
}
DRAGGING_BOTTOM -> {
val wantedBottom = roundToClosestMultiplyOfNumber(frameRect.bottom - sideMargins.top, cellHeight)
val wantedBottomCellY = wantedBottom / cellHeight - 1