Assigned
Status Update
Comments
sh...@google.com <sh...@google.com>
ap...@google.com <ap...@google.com> #2
Definitely want to support this. Currently investigating moving the Callbacks to interfaces so that wrapping/conversion can be done:
private abstract class WrapperDataSource<in A, B>(private val source: PositionalDataSource<A>)
: PositionalDataSource<B>() {
override fun loadInitial(params: LoadInitialParams, callback: LoadInitialCallback<B>) {
source.loadInitial(params, object: LoadInitialCallback<A> {
override fun onResult(data: List<A>, position: Int, totalCount: Int) {
callback.onResult(convert(data), position, totalCount)
}
override fun onResult(data: List<A>, position: Int) {
callback.onResult(convert(data), position)
}
})
}
override fun loadRange(params: LoadRangeParams, callback: LoadRangeCallback<B>) {
source.loadRange(params) { data -> callback.onResult(convert(data)) }
}
protected abstract fun convert(source: List<A>): List<B>
}
Making them interfaces makes it easy to wrap/test. Downside is that external callers can't use some of the guts of the callback impl (like validating non-negative positions), but this should make it much more reasonable to wrap, decorate, or otherwise post-process data loaded from e.g. Room. In the network case, the equivalent might be post-processing a network request in a way that's awkward to inject into network loading code.
private abstract class WrapperDataSource<in A, B>(private val source: PositionalDataSource<A>)
: PositionalDataSource<B>() {
override fun loadInitial(params: LoadInitialParams, callback: LoadInitialCallback<B>) {
source.loadInitial(params, object: LoadInitialCallback<A> {
override fun onResult(data: List<A>, position: Int, totalCount: Int) {
callback.onResult(convert(data), position, totalCount)
}
override fun onResult(data: List<A>, position: Int) {
callback.onResult(convert(data), position)
}
})
}
override fun loadRange(params: LoadRangeParams, callback: LoadRangeCallback<B>) {
source.loadRange(params) { data -> callback.onResult(convert(data)) }
}
protected abstract fun convert(source: List<A>): List<B>
}
Making them interfaces makes it easy to wrap/test. Downside is that external callers can't use some of the guts of the callback impl (like validating non-negative positions), but this should make it much more reasonable to wrap, decorate, or otherwise post-process data loaded from e.g. Room. In the network case, the equivalent might be post-processing a network request in a way that's awkward to inject into network loading code.
ap...@google.com <ap...@google.com> #3
Fixed internally by making Params constructors public, and Callbacks abstract. Will go out with next alpha release.
We're also investigating making it easier to wrap and do decoration/type conversions, since the example in #2 mostly works, but is incomplete - it needs to handle invalidates.
We're also investigating making it easier to wrap and do decoration/type conversions, since the example in #2 mostly works, but is incomplete - it needs to handle invalidates.
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
commit 01142ddd5b14eb33e5145c4e72e6619a5c100fe4
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Thu Dec 21 12:34:00 2023
Introduce Overscroll in AnchoredDraggable
Adding overscroll support to AnchoredDraggable by giving the ability to pass a customized overscrollEffect object to AnchoredDraggable.
Bug: 288084801
Relnote: An OverscrollEffect has been introduced to allow for custom overscroll effects in anchoredDraggable. To retrieve the consumed velocity after animation, the consumed velocity is returned from the settle function.
Test: Added tests to verify behavior
Change-Id: I100683fe7473b1e5ff317ab22245a2b0a25bd549
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/AnchoredDraggableDemo.kt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/AnchoredDraggableSample.kt
A compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableOverscrollTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
https://android-review.googlesource.com/2888106
Branch: androidx-main
commit 01142ddd5b14eb33e5145c4e72e6619a5c100fe4
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Thu Dec 21 12:34:00 2023
Introduce Overscroll in AnchoredDraggable
Adding overscroll support to AnchoredDraggable by giving the ability to pass a customized overscrollEffect object to AnchoredDraggable.
Bug: 288084801
Relnote: An OverscrollEffect has been introduced to allow for custom overscroll effects in anchoredDraggable. To retrieve the consumed velocity after animation, the consumed velocity is returned from the settle function.
Test: Added tests to verify behavior
Change-Id: I100683fe7473b1e5ff317ab22245a2b0a25bd549
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/AnchoredDraggableDemo.kt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/AnchoredDraggableSample.kt
A compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableOverscrollTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit 0f071d797bccf7eff2a23e408928ca76640af782
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Wed Nov 29 18:34:09 2023
Migrates AnchoredDraggable to Modifier.Node
Migrates AnchoredDraggable to Modifier.Node. This helps in adding Overscroll effect in AnchoredDraggable.
Bug: 288084801
Test: Added tests to verify behavior
Change-Id: I3f3338cd71763972c4b70f2e06c97e85285b0035
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableGestureTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable2D.kt
https://android-review.googlesource.com/2852691
Branch: androidx-main
commit 0f071d797bccf7eff2a23e408928ca76640af782
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Wed Nov 29 18:34:09 2023
Migrates AnchoredDraggable to Modifier.Node
Migrates AnchoredDraggable to Modifier.Node. This helps in adding Overscroll effect in AnchoredDraggable.
Bug: 288084801
Test: Added tests to verify behavior
Change-Id: I3f3338cd71763972c4b70f2e06c97e85285b0035
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableGestureTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable2D.kt
sh...@google.com <sh...@google.com>
da...@gmail.com <da...@gmail.com> #7
This issue is marked as fixed, but there is still no replacement for ResistanceConfig
.
How should we properly migrate it?
lp...@google.com <lp...@google.com> #8
Can we document this / update the migration guide?
Description