예제 #1
0
  private void enableSlidingUpPanel(Drone api) {
    if (mSlidingPanel == null || api == null) {
      return;
    }

    final boolean isEnabled = flightActions != null && flightActions.isSlidingUpPanelEnabled(api);

    if (isEnabled) {
      mSlidingPanel.setSlidingEnabled(true);
    } else {
      if (!mSlidingPanelCollapsing.get()) {
        if (mSlidingPanel.isPanelExpanded()) {
          mSlidingPanel.setPanelSlideListener(mDisablePanelSliding);
          mSlidingPanel.collapsePanel();
          mSlidingPanelCollapsing.set(true);
        } else {
          mSlidingPanel.setSlidingEnabled(false);
          mSlidingPanelCollapsing.set(false);
        }
      }
    }
  }
예제 #2
0
  private void enableSlidingUpPanel(Drone api) {
    if (mSlidingPanel == null || api == null) {
      return;
    }

    final boolean isEnabled = flightActions != null && flightActions.isSlidingUpPanelEnabled(api);

    if (isEnabled) {
      mSlidingPanel.setEnabled(true);
      mSlidingPanel
          .getViewTreeObserver()
          .addOnGlobalLayoutListener(
              new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                  SlidingUpPanelLayout.PanelState panelState = mSlidingPanel.getPanelState();
                  slidingPanelListenerMgr.onPanelStateChanged(
                      mSlidingPanel, panelState, panelState);
                  mSlidingPanel.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                }
              });

    } else {
      if (!mSlidingPanelCollapsing.get()) {
        SlidingUpPanelLayout.PanelState panelState = mSlidingPanel.getPanelState();
        if (panelState == SlidingUpPanelLayout.PanelState.EXPANDED) {
          slidingPanelListenerMgr.addPanelSlideListener(
              disablePanelSlidingLabel, mDisablePanelSliding);
          mSlidingPanel.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
          mSlidingPanelCollapsing.set(true);
        } else {
          mSlidingPanel.setEnabled(false);
          mSlidingPanelCollapsing.set(false);
        }
      }
    }
  }