use of com.android.tools.idea.uibuilder.api.ScrollHandler in project android by JetBrains.
the class ScrollInteraction method createScrollInteraction.
/**
* Creates a new {@link ScrollInteraction} if any of the components in the component hierarchy can handle scrolling.
* @return the {@link ScrollInteraction} or null if none of the components handle the scrolling
*/
@Nullable
public static ScrollInteraction createScrollInteraction(@NonNull ScreenView screenView, @NonNull NlComponent component) {
NlComponent currentComponent = component;
ScrollHandler scrollHandler = null;
ViewEditor editor = new ViewEditorImpl(screenView);
// Find the component that is the lowest in the hierarchy and can take the scrolling events
while (currentComponent != null) {
ViewGroupHandler viewGroupHandler = currentComponent.getViewGroupHandler();
scrollHandler = viewGroupHandler != null ? viewGroupHandler.createScrollHandler(editor, currentComponent) : null;
if (scrollHandler != null) {
break;
}
currentComponent = currentComponent.getParent();
}
if (scrollHandler == null) {
return null;
}
return new ScrollInteraction(screenView, scrollHandler);
}
Aggregations