Skip to content

Commit 5f2ad16

Browse files
nishchal-vSohamSimform
authored andcommitted
UNT-T5913: 🐞 Fix Coordinator layout issue
1 parent 144025e commit 5f2ad16

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

sspulltorefresh/src/main/java/com/simform/refresh/SSPullToRefreshLayout.kt

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,9 @@ class SSPullToRefreshLayout(context: Context?, attrs: AttributeSet? = null) :
394394
override fun onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int): Boolean {
395395
return when (mRefreshStyle) {
396396
RefreshStyle.FLOAT -> (isEnabled
397-
&& canChildScrollUp(mTarget)
398397
&& !mIsRefreshing
399398
&& nestedScrollAxes and ViewCompat.SCROLL_AXIS_VERTICAL != 0)
400399
else -> (isEnabled
401-
&& canChildScrollUp(mTarget)
402400
&& nestedScrollAxes and ViewCompat.SCROLL_AXIS_VERTICAL != 0)
403401
}
404402
}
@@ -632,11 +630,11 @@ class SSPullToRefreshLayout(context: Context?, attrs: AttributeSet? = null) :
632630
return false
633631
}
634632
when (mRefreshStyle) {
635-
RefreshStyle.FLOAT -> if ((!isEnabled || canChildScrollUp(mTarget) || mIsRefreshing || mNestedScrollInProgress)) {
633+
RefreshStyle.FLOAT -> if ((!isEnabled || mIsRefreshing || mNestedScrollInProgress)) {
636634
// Fail fast if we're not in a state where a swipe is possible
637635
return false
638636
}
639-
else -> if ((!isEnabled || (canChildScrollUp(mTarget) && !mDispatchTargetTouchDown))) {
637+
else -> if ((!isEnabled || (!mDispatchTargetTouchDown))) {
640638
return false
641639
}
642640
}
@@ -684,15 +682,15 @@ class SSPullToRefreshLayout(context: Context?, attrs: AttributeSet? = null) :
684682
return false
685683
}
686684
when (mRefreshStyle) {
687-
RefreshStyle.FLOAT -> if (!isEnabled || canChildScrollUp(mTarget) || mNestedScrollInProgress) {
685+
RefreshStyle.FLOAT -> if (!isEnabled || mNestedScrollInProgress) {
688686
// Fail fast if we're not in a state where a swipe is possible
689687
return false
690688
}
691-
else -> if ((!isEnabled || (canChildScrollUp(mTarget) && !mDispatchTargetTouchDown))) {
689+
else -> if ((!isEnabled || (!mDispatchTargetTouchDown))) {
692690
return false
693691
}
694692
}
695-
if (mRefreshStyle == RefreshStyle.FLOAT && (canChildScrollUp(mTarget) || mNestedScrollInProgress)) {
693+
if (mRefreshStyle == RefreshStyle.FLOAT && (mNestedScrollInProgress)) {
696694
return false
697695
}
698696
when (ev.action) {
@@ -1016,22 +1014,6 @@ class SSPullToRefreshLayout(context: Context?, attrs: AttributeSet? = null) :
10161014
} else ev.getY(index)
10171015
}
10181016

1019-
private fun canChildScrollUp(mTarget: View?): Boolean {
1020-
if (mTarget == null) {
1021-
return false
1022-
}
1023-
if (mTarget is ViewGroup) {
1024-
val childCount = mTarget.childCount
1025-
for (i in 0 until childCount) {
1026-
val child = mTarget.getChildAt(i)
1027-
if (canChildScrollUp(child)) {
1028-
return true
1029-
}
1030-
}
1031-
}
1032-
return ViewCompat.canScrollVertically(mTarget, -1)
1033-
}
1034-
10351017
private fun ensureTarget() {
10361018
if (!isTargetValid) {
10371019
for (i in 0 until childCount) {
@@ -1076,7 +1058,7 @@ class SSPullToRefreshLayout(context: Context?, attrs: AttributeSet? = null) :
10761058
mOnRefreshListener = listener
10771059
}
10781060

1079-
interface OnRefreshListener {
1061+
fun interface OnRefreshListener {
10801062
fun onRefresh()
10811063
}
10821064

0 commit comments

Comments
 (0)