removing a redundant function
This commit is contained in:
parent
92fd30eec2
commit
04f6e14b3f
|
@ -133,7 +133,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLongPressedIcon != null) {
|
if (mLongPressedIcon != null) {
|
||||||
home_screen_grid.draggedItemMoved(getGridTouchedX(event.x), getGridTouchedY(event.y))
|
home_screen_grid.draggedItemMoved(event.x.toInt(), event.y.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTouchDownY != -1 && !mIgnoreMoveEvents) {
|
if (mTouchDownY != -1 && !mIgnoreMoveEvents) {
|
||||||
|
@ -149,7 +149,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
mIgnoreMoveEvents = false
|
mIgnoreMoveEvents = false
|
||||||
mLongPressedIcon = null
|
mLongPressedIcon = null
|
||||||
(all_apps_fragment as AllAppsFragment).ignoreTouches = false
|
(all_apps_fragment as AllAppsFragment).ignoreTouches = false
|
||||||
home_screen_grid.itemDraggingStopped(getGridTouchedX(event.x), getGridTouchedY(event.y))
|
home_screen_grid.itemDraggingStopped(event.x.toInt(), event.y.toInt())
|
||||||
if (!mIgnoreUpEvent) {
|
if (!mIgnoreUpEvent) {
|
||||||
if (all_apps_fragment.y < mScreenHeight * 0.7) {
|
if (all_apps_fragment.y < mScreenHeight * 0.7) {
|
||||||
showFragment(all_apps_fragment)
|
showFragment(all_apps_fragment)
|
||||||
|
@ -230,7 +230,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
|
|
||||||
mIgnoreMoveEvents = true
|
mIgnoreMoveEvents = true
|
||||||
main_holder.performHapticFeedback()
|
main_holder.performHapticFeedback()
|
||||||
val clickedGridItem = home_screen_grid.isClickingGridItem(getGridTouchedX(x), getGridTouchedY(y))
|
val clickedGridItem = home_screen_grid.isClickingGridItem(x.toInt(), y.toInt())
|
||||||
if (clickedGridItem != null) {
|
if (clickedGridItem != null) {
|
||||||
showHomeIconMenu(x, y - resources.getDimension(R.dimen.icon_long_press_anchor_offset_y), clickedGridItem, false)
|
showHomeIconMenu(x, y - resources.getDimension(R.dimen.icon_long_press_anchor_offset_y), clickedGridItem, false)
|
||||||
return
|
return
|
||||||
|
@ -240,16 +240,12 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun homeScreenClicked(x: Float, y: Float) {
|
fun homeScreenClicked(x: Float, y: Float) {
|
||||||
val clickedGridItem = home_screen_grid.isClickingGridItem(getGridTouchedX(x), getGridTouchedY(y))
|
val clickedGridItem = home_screen_grid.isClickingGridItem(x.toInt(), y.toInt())
|
||||||
if (clickedGridItem != null) {
|
if (clickedGridItem != null) {
|
||||||
launchApp(clickedGridItem.packageName)
|
launchApp(clickedGridItem.packageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getGridTouchedX(x: Float) = Math.min(Math.max(x.toInt(), 0), home_screen_grid.width)
|
|
||||||
|
|
||||||
private fun getGridTouchedY(y: Float) = Math.min(Math.max(y.toInt(), 0), home_screen_grid.height)
|
|
||||||
|
|
||||||
fun showHomeIconMenu(x: Float, y: Float, gridItem: HomeScreenGridItem, isOnAllAppsFragment: Boolean) {
|
fun showHomeIconMenu(x: Float, y: Float, gridItem: HomeScreenGridItem, isOnAllAppsFragment: Boolean) {
|
||||||
mLongPressedIcon = gridItem
|
mLongPressedIcon = gridItem
|
||||||
home_screen_popup_menu_anchor.x = x
|
home_screen_popup_menu_anchor.x = x
|
||||||
|
|
|
@ -42,7 +42,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
||||||
private var gridCenters = ArrayList<Pair<Int, Int>>()
|
private var gridCenters = ArrayList<Pair<Int, Int>>()
|
||||||
private var draggedItemCurrentCoords = Pair(-1, -1)
|
private var draggedItemCurrentCoords = Pair(-1, -1)
|
||||||
|
|
||||||
var sideMargins = Rect() // apply fake margins at the home screen. Real ones would cause the icons be cut at dragging at screen sides
|
private var sideMargins = Rect() // apply fake margins at the home screen. Real ones would cause the icons be cut at dragging at screen sides
|
||||||
|
|
||||||
init {
|
init {
|
||||||
textPaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
|
textPaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
|
|
Loading…
Reference in New Issue