mirror of
https://github.com/FossifyOrg/File-Manager.git
synced 2026-04-15 20:08:32 -04:00
fix(ui): prevent SwipeRefreshLayout from intercepting child touch events (#173)
* Fix accidental rendering of swipe refresh indicator. * Fix scroll up in Files tab. * Update app/src/main/kotlin/org/fossify/filemanager/views/MySwipeRefreshLayout.kt Fix grammar after copy paste. Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com> * docs(changelog): add links --------- Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com> Co-authored-by: Naveen Singh <snaveen935@gmail.com>
This commit is contained in:
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed accidental rendering of pull-to-refresh indicator ([#27])
|
||||
- Pull-to-refresh setting is now applied as expected ([#136])
|
||||
|
||||
## [1.0.1] - 2024-03-17
|
||||
@@ -40,4 +41,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
[1.0.1]: https://github.com/FossifyOrg/File-Manager/compare/1.0.0...1.0.1
|
||||
[1.0.0]: https://github.com/FossifyOrg/File-Manager/releases/tag/1.0.0
|
||||
|
||||
[#27]: https://github.com/FossifyOrg/File-Manager/issues/27
|
||||
[#136]: https://github.com/FossifyOrg/File-Manager/issues/136
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.fossify.filemanager.views
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
|
||||
class MySwipeRefreshLayout @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
) : SwipeRefreshLayout(context, attrs) {
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
|
||||
// Setting "isEnabled = false" is recommended for users of this ViewGroup
|
||||
// who who are not interested in the pull to refresh functionality
|
||||
// Setting this easily avoids executing code needlessly before the check for "canChildScrollUp".
|
||||
if (!isEnabled) {
|
||||
return false
|
||||
}
|
||||
return super.onInterceptTouchEvent(ev)
|
||||
}
|
||||
|
||||
override fun onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int): Boolean {
|
||||
// Ignoring nested scrolls from descendants.
|
||||
// Allowing descendants to trigger nested scrolls would defeat the purpose of this class
|
||||
// and result in pull to refresh to happen for all movements on the Y axis
|
||||
// (even as part of scale/quick scale gestures) while also doubling the throbber with the overscroll shadow.
|
||||
return if (isEnabled) {
|
||||
return false
|
||||
} else {
|
||||
super.onStartNestedScroll(child, target, nestedScrollAxes)
|
||||
}
|
||||
}
|
||||
|
||||
override fun canChildScrollUp(): Boolean {
|
||||
val directChild = getChildAt(0)
|
||||
return when (directChild) {
|
||||
is RecyclerViewFastScroller -> {
|
||||
val innerRecyclerView = directChild.getChildAt(0)
|
||||
innerRecyclerView?.canScrollVertically(-1) == true
|
||||
}
|
||||
else -> super.canChildScrollUp()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@
|
||||
android:textStyle="italic"
|
||||
android:visibility="gone" />
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
<org.fossify.filemanager.views.MySwipeRefreshLayout
|
||||
android:id="@+id/items_swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -90,7 +90,7 @@
|
||||
app:layoutManager="org.fossify.commons.views.MyGridLayoutManager" />
|
||||
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</org.fossify.filemanager.views.MySwipeRefreshLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<org.fossify.commons.views.MyFloatingActionButton
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
<org.fossify.filemanager.views.MySwipeRefreshLayout
|
||||
android:id="@+id/recents_swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
@@ -37,5 +37,5 @@
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="org.fossify.commons.views.MyGridLayoutManager" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</org.fossify.filemanager.views.MySwipeRefreshLayout>
|
||||
</org.fossify.filemanager.fragments.RecentsFragment>
|
||||
|
||||
Reference in New Issue
Block a user