Skip to content

Commit 42dcf6e

Browse files
committed
Fix accidental rendering of swipe refresh indicator.
1 parent 2c0e31c commit 42dcf6e

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Replaced checkboxes with switches
1313

14+
### Fixed
15+
16+
- Fixed accidental rendering of swipe refresh indicator.
17+
1418
## [1.0.1] - 2024-03-17
1519

1620
### Changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.fossify.filemanager.views
2+
3+
import android.content.Context
4+
import android.util.AttributeSet
5+
import android.view.MotionEvent
6+
import android.view.View
7+
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
8+
9+
class MySwipeRefreshLayout @JvmOverloads constructor(
10+
context: Context,
11+
attrs: AttributeSet? = null,
12+
) : SwipeRefreshLayout(context, attrs) {
13+
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
14+
// Setting "isEnabled = false" is recommended for users of this ViewGroup
15+
// who who are not interested in the pull to refresh functionality
16+
// Setting this easily avoids executing code unneededsly before the check for "canChildScrollUp".
17+
if (!isEnabled) {
18+
return false
19+
}
20+
return super.onInterceptTouchEvent(ev)
21+
}
22+
23+
override fun onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int): Boolean {
24+
// Ignoring nested scrolls from descendants.
25+
// Allowing descendants to trigger nested scrolls would defeat the purpose of this class
26+
// and result in pull to refresh to happen for all movements on the Y axis
27+
// (even as part of scale/quick scale gestures) while also doubling the throbber with the overscroll shadow.
28+
return if (isEnabled) {
29+
return false
30+
} else {
31+
super.onStartNestedScroll(child, target, nestedScrollAxes)
32+
}
33+
}
34+
}

app/src/main/res/layout/items_fragment.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
android:textStyle="italic"
6969
android:visibility="gone" />
7070

71-
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
71+
<org.fossify.filemanager.views.MySwipeRefreshLayout
7272
android:id="@+id/items_swipe_refresh"
7373
android:layout_width="match_parent"
7474
android:layout_height="wrap_content"
@@ -90,7 +90,7 @@
9090
app:layoutManager="org.fossify.commons.views.MyGridLayoutManager" />
9191

9292
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
93-
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
93+
</org.fossify.filemanager.views.MySwipeRefreshLayout>
9494
</RelativeLayout>
9595

9696
<org.fossify.commons.views.MyFloatingActionButton

app/src/main/res/layout/recents_fragment.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
android:visibility="gone"
2323
tools:visibility="visible" />
2424

25-
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
25+
<org.fossify.filemanager.views.MySwipeRefreshLayout
2626
android:id="@+id/recents_swipe_refresh"
2727
android:layout_width="match_parent"
2828
android:layout_height="wrap_content">
@@ -37,5 +37,5 @@
3737
android:scrollbars="none"
3838
app:layoutManager="org.fossify.commons.views.MyGridLayoutManager" />
3939

40-
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
40+
</org.fossify.filemanager.views.MySwipeRefreshLayout>
4141
</org.fossify.filemanager.fragments.RecentsFragment>

0 commit comments

Comments
 (0)