コード例 #1
0
 private void a(View paramView, CoordinatorLayout paramCoordinatorLayout)
 {
   g = paramCoordinatorLayout.findViewById(f);
   if (g != null)
   {
     View localView = g;
     for (ViewParent localViewParent = g.getParent(); (localViewParent != paramCoordinatorLayout) && (localViewParent != null); localViewParent = localViewParent.getParent())
     {
       if (localViewParent == paramView)
       {
         if (paramCoordinatorLayout.isInEditMode())
         {
           h = null;
           g = null;
           return;
         }
         throw new IllegalStateException("Anchor must not be a descendant of the anchored view");
       }
       if ((localViewParent instanceof View)) {
         localView = (View)localViewParent;
       }
     }
     h = localView;
     return;
   }
   if (paramCoordinatorLayout.isInEditMode())
   {
     h = null;
     g = null;
     return;
   }
   throw new IllegalStateException("Could not find CoordinatorLayout descendant view with id " + paramCoordinatorLayout.getResources().getResourceName(f) + " to anchor view " + paramView);
 }
コード例 #2
0
  public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed) {
    ViewParent p = this.getParent().getParent();

    if (p instanceof CoordinatorLayout) {
      CoordinatorLayout cl = ((CoordinatorLayout) p);
      AppBarLayout apl = (AppBarLayout) cl.findViewById(R.id.app_bar_layout);
      CoordinatorLayout.LayoutParams lp = (LayoutParams) apl.getLayoutParams();
      final Behavior viewBehavior = lp.getBehavior();
      if (viewBehavior != null) {
        viewBehavior.onNestedFling(this, apl, target, velocityX, velocityY, consumed);
      }
    }

    return super.onNestedFling(target, velocityX, velocityY, consumed);
  }
  private void initBottomView() {
    CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.cl_activity_scroll);
    assert coordinatorLayout != null;
    View view = coordinatorLayout.findViewById(R.id.ns_content_scroll);
    behavior = BottomSheetBehavior.from(view);

    behavior.setBottomSheetCallback(
        new BottomSheetBehavior.BottomSheetCallback() {
          boolean first = true;

          @Override
          public void onStateChanged(@NonNull View bottomSheet, int newState) {
            state = newState;
          }

          @Override
          public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            if (first) {
              first = false;
              bottomSheet.setTranslationY(0);
            }
          }
        });
  }