content: /*
   * Copyright (C) 2018 The Android Open Source Project
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package com.google.androidstudio.motionlayoutexample.utils;
  
  import android.content.Context;
  import android.util.AttributeSet;
  import android.view.View;
  import android.widget.FrameLayout;
  
  import androidx.annotation.NonNull;
  import androidx.annotation.Nullable;
  import androidx.core.view.NestedScrollingParent2;
  
  public class TouchFrameLayout extends FrameLayout implements NestedScrollingParent2 {
  
  
      public TouchFrameLayout(@NonNull Context context) {
          super(context);
      }
  
      public TouchFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
          super(context, attrs);
      }
  
      public TouchFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
      }
  
      public NestedScrollingParent2 getMotionLayout() {
          return (NestedScrollingParent2) getParent();
      }
  
      @Override
      public boolean onStartNestedScroll(@NonNull View child, @NonNull View target, int axes, int type) {
          return getMotionLayout().onStartNestedScroll(child, target, axes, type);
      }
  
      @Override
      public void onNestedScrollAccepted(@NonNull View child, @NonNull View target, int axes, int type) {
          getMotionLayout().onNestedScrollAccepted(child, target, axes, type);
      }
  
      @Override
      public void onStopNestedScroll(@NonNull View target, int type) {
          getMotionLayout().onStopNestedScroll(target, type);
      }
  
      @Override
      public void onNestedScroll(@NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
          getMotionLayout().onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
      }
  
      @Override
      public void onNestedPreScroll(@NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) {
          getMotionLayout().onNestedPreScroll(target, dx, dy, consumed, type);
      }
  }
  