1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 18 package androidx.core.view; 19 20 import android.view.View; 21 22 import org.jspecify.annotations.NonNull; 23 24 /** 25 * This interface should be implemented by {@link android.view.ViewGroup ViewGroup} subclasses 26 * that wish to support scrolling operations delegated by a nested child view. 27 * 28 * <p>Classes implementing this interface should create a final instance of a 29 * {@link NestedScrollingParentHelper} as a field and delegate any View or ViewGroup methods 30 * to the <code>NestedScrollingParentHelper</code> methods of the same signature.</p> 31 * 32 * <p>Views invoking nested scrolling functionality should always do so from the relevant 33 * {@link ViewCompat}, {@link ViewGroupCompat} or {@link ViewParentCompat} compatibility 34 * shim static methods. This ensures interoperability with nested scrolling views on all versions 35 * of Android.</p> 36 */ 37 public interface NestedScrollingParent3 extends NestedScrollingParent2 { 38 39 /** 40 * React to a nested scroll in progress. 41 * 42 * <p>This method will be called when the ViewParent's current nested scrolling child view 43 * dispatches a nested scroll event. To receive calls to this method the ViewParent must have 44 * previously returned <code>true</code> for a call to 45 * {@link #onStartNestedScroll(View, View, int, int)}. 46 * 47 * <p>Both the consumed and unconsumed portions of the scroll distance are reported to the 48 * ViewParent. An implementation may choose to use the consumed portion to match or chase scroll 49 * position of multiple child elements, for example. The unconsumed portion may be used to 50 * allow continuous dragging of multiple scrolling or draggable elements, such as scrolling 51 * a list within a vertical drawer where the drawer begins dragging once the edge of inner 52 * scrolling content is reached. 53 * 54 * <p>This method is called when a nested scrolling child invokes 55 * {@link NestedScrollingChild3#dispatchNestedScroll(int, int, int, int, int[], int, int[])}} or 56 * one of methods it overloads. 57 * 58 * <p>An implementation must report how many pixels of the the x and y scroll distances were 59 * consumed by this nested scrolling parent by adding the consumed distances to the 60 * <code>consumed</code> parameter. If this View also implements {@link NestedScrollingChild3}, 61 * <code>consumed</code> should also be passed up to it's nested scrolling parent so that the 62 * parent may also add any scroll distance it consumes. Index 0 corresponds to dx and index 1 63 * corresponds to dy. 64 * 65 * @param target The descendant view controlling the nested scroll 66 * @param dxConsumed Horizontal scroll distance in pixels already consumed by target 67 * @param dyConsumed Vertical scroll distance in pixels already consumed by target 68 * @param dxUnconsumed Horizontal scroll distance in pixels not consumed by target 69 * @param dyUnconsumed Vertical scroll distance in pixels not consumed by target 70 * @param type the type of input which cause this scroll event 71 * @param consumed Output. Upon this method returning, will contain the scroll 72 * distances consumed by this nested scrolling parent and the scroll distances 73 * consumed by any other parent up the view hierarchy 74 * 75 * @see NestedScrollingChild3#dispatchNestedScroll(int, int, int, int, int[], int, int[]) 76 */ onNestedScroll(@onNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @ViewCompat.NestedScrollType int type, int @NonNull [] consumed)77 void onNestedScroll(@NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, 78 int dyUnconsumed, @ViewCompat.NestedScrollType int type, int @NonNull [] consumed); 79 80 } 81