Skip to content

Commit

Permalink
Reverted back to old scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
agronick committed Aug 15, 2022
1 parent d62970f commit c85beff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 40 deletions.
11 changes: 7 additions & 4 deletions app/src/main/java/com/agronick/launcher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import android.view.Window
import androidx.core.view.GestureDetectorCompat



class MainActivity : Activity(), GestureDetector.OnGestureListener {
private var wasScrolling = false
private lateinit var mDetector: GestureDetectorCompat
private lateinit var mainView: MainView

Expand Down Expand Up @@ -45,8 +45,9 @@ class MainActivity : Activity(), GestureDetector.OnGestureListener {
} else if (mainView.reorderer != null) {
mainView.handleLongPress(event)
return true
} else if (mainView.wasScrolling && event.action == MotionEvent.ACTION_UP) {
} else if (wasScrolling && event.action == MotionEvent.ACTION_UP) {
mainView.checkOverPanLimit()
wasScrolling = false
return true
} else {
super.onTouchEvent(event)
Expand Down Expand Up @@ -114,8 +115,10 @@ class MainActivity : Activity(), GestureDetector.OnGestureListener {
distanceX: Float,
distanceY: Float
): Boolean {
mainView.handleScroll(distanceX, distanceY)
mainView.wasScrolling = true
mainView.offsetLeft -= distanceX
mainView.offsetTop -= distanceY
mainView.prepareInvalidate()
wasScrolling = true
return true
}

Expand Down
48 changes: 12 additions & 36 deletions app/src/main/java/com/agronick/launcher/MainView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.animation.AnimatorSet
import android.animation.ValueAnimator
import android.content.Context
import android.graphics.Canvas
import android.util.Log
import android.view.HapticFeedbackConstants
import android.view.MotionEvent
import android.view.View
Expand All @@ -24,19 +23,6 @@ class MainView(context: Context, appList: List<PInfo>) : View(context) {
private var edgeLimit = 100000f
var allHidden = false

var scrollEndFn: (() -> Unit)? = null
var wasScrolling = false
set(value: Boolean) {
if (!wasScrolling) {
Log.e(StaticValues.tag, "ScrollEndFn without scroll")
}
if (scrollEndFn != null) {
scrollEndFn!!()
scrollEndFn = null
}
field = value
}

private val STATE_NONE = 0
private val STATE_REORDERING = 1
private val STATE_OPENING = 2
Expand Down Expand Up @@ -98,26 +84,19 @@ class MainView(context: Context, appList: List<PInfo>) : View(context) {
val offset = getRelativePosition(Pair(event.x, event.y))
if (state == STATE_REORDERING) {
if (event.action == MotionEvent.ACTION_UP) {
val scrollEndEvent = {
reorderer!!.onStopReorder(
when (container.getLimit(offsetLeft, offsetTop, canvasSize)) {
Pair(offsetLeft, offsetTop) -> container.getAppAtPoint(
Vector2(
offset.x,
offset.y
)
reorderer!!.onStopReorder(
when (container.getLimit(offsetLeft, offsetTop, canvasSize)) {
Pair(offsetLeft, offsetTop) -> container.getAppAtPoint(
Vector2(
offset.x,
offset.y
)
else -> null
}
)
reorderer = null
resetReorderEdgeTimer()
}
if (wasScrolling) {
scrollEndFn = scrollEndEvent
} else {
scrollEndEvent()
}
)
else -> null
}
)
reorderer = null
resetReorderEdgeTimer()
} else {
reorderer!!.onMove(offset)
val newOffsets =
Expand Down Expand Up @@ -168,10 +147,7 @@ class MainView(context: Context, appList: List<PInfo>) : View(context) {
duration = StaticValues.durationOpen
playTogether(*animators.toTypedArray())
start()
doOnEnd { wasScrolling = false }
}
} else {
wasScrolling = false
}
}

Expand Down

0 comments on commit c85beff

Please sign in to comment.