Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Pull-to-refresh setting is now applied as expected ([#136])
- Fixed accidental rendering of swipe refresh indicator.

## [1.0.1] - 2024-03-17

Expand Down
Original file line number Diff line number Diff line change
@@ -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 unneededsly 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()
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/items_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/recents_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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>
Loading