Skip to content

Commit

Permalink
Merge pull request #26 from SimformSolutionsPvtLtd/develop
Browse files Browse the repository at this point in the history
Develop to Main

LGTM.
  • Loading branch information
yashwantgowla-simform authored Mar 28, 2023
2 parents 8f0eee3 + 5806f3f commit c6364fa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,8 @@ class SSPullToRefreshLayout(context: Context?, attrs: AttributeSet? = null) :
}
refreshView.visibility = GONE
addView(refreshView, mRefreshLayoutParams)
when(refreshView) {
is SSAnimationView -> { }
is SSLottieAnimationView -> {
refreshView.setAnimation(mLottieAnimationAssetFileName)
}
else -> {
throw ClassCastException("Need SSLottieAnimationView or SSGifAnimationView as RefreshView")
}
}
if (refreshView !is RefreshCallbacks) throw ClassCastException("RefreshView must implement RefreshCallbacks")
if (refreshView is SSLottieAnimationView) refreshView.setAnimation(mLottieAnimationAssetFileName)
mRefreshView = refreshView
}

Expand Down Expand Up @@ -685,7 +678,7 @@ class SSPullToRefreshLayout(context: Context?, attrs: AttributeSet? = null) :
else -> {
}
}
return mIsBeingDragged
return if (mRefreshView.hasPoint(ev.rawX.toInt(), ev.rawY.toInt())) false else mIsBeingDragged
}

override fun onTouchEvent(ev: MotionEvent): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.simform.refresh

import android.view.View

/**
* Defines the coordinates of the view in its window
*
* @return Pair of [Int] representing x and y
*/
val View.windowCoordinates: Pair<Int, Int>
get() {
val location = IntArray(2)
getLocationInWindow(location)
val x = location[0]
val y = location[1]
return x to y
}

/**
* Check if view bounds include the given point in window
*
* @param x The x coordinate of the point
* @param y The y coordinate of the point
*
* @return True if the view contains given point, false otherwise
*/
fun View.hasPoint(x: Int, y: Int): Boolean {
val viewCoordinates = windowCoordinates
return x in viewCoordinates.first..(viewCoordinates.first + width) &&
y in viewCoordinates.second..(viewCoordinates.second + height)
}

0 comments on commit c6364fa

Please sign in to comment.