Skip to content

Commit

Permalink
Added support for expandPanel,collapsePanel,hidePanel and showPanel b…
Browse files Browse the repository at this point in the history
…efore first layout
  • Loading branch information
tokudu committed Jul 8, 2014
1 parent 5b6238a commit 1157c93
Showing 1 changed file with 41 additions and 11 deletions.
52 changes: 41 additions & 11 deletions library/src/com/sothree/slidinguppanel/SlidingUpPanelLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,14 @@ private float computeSlideOffset(int topPosition) {
* @return true if the pane was slideable and is now collapsed/in the process of collapsing
*/
public boolean collapsePanel() {
if (mSlideState == SlideState.HIDDEN || mSlideState == SlideState.COLLAPSED) return false;
return collapsePanel(mSlideableView, 0);
if (mFirstLayout) {
mSlideState = SlideState.COLLAPSED;
return true;
} else {
if (mSlideState == SlideState.HIDDEN || mSlideState == SlideState.COLLAPSED)
return false;
return collapsePanel(mSlideableView, 0);
}
}

/**
Expand All @@ -852,7 +858,12 @@ public boolean collapsePanel() {
* @return true if the pane was slideable and is now expanded/in the process of expading
*/
public boolean expandPanel() {
return expandPanel(1.0f);
if (mFirstLayout) {
mSlideState = SlideState.EXPANDED;
return true;
} else {
return expandPanel(1.0f);
}
}

/**
Expand All @@ -861,7 +872,12 @@ public boolean expandPanel() {
* @return true if the pane was slideable and is now expanded/in the process of expading
*/
public boolean anchorPanel() {
return expandPanel(mAnchorPoint);
if (mFirstLayout) {
mSlideState = SlideState.ANCHORED;
return true;
} else {
return expandPanel(mAnchorPoint);
}
}

/**
Expand Down Expand Up @@ -903,17 +919,31 @@ public boolean isPanelHidden() {
return mSlideState == SlideState.HIDDEN;
}

/**
* Shows the panel from the hidden state
*/
public void showPanel() {
if (mSlideableView == null || mSlideState != SlideState.HIDDEN) return;
mSlideableView.setVisibility(View.VISIBLE);
requestLayout();
smoothSlideTo(0, 0);
if (mFirstLayout) {
mSlideState = SlideState.COLLAPSED;
} else {
if (mSlideableView == null || mSlideState != SlideState.HIDDEN) return;
mSlideableView.setVisibility(View.VISIBLE);
requestLayout();
smoothSlideTo(0, 0);
}
}

/**
* Hides the sliding panel entirely.
*/
public void hidePanel() {
if (mSlideState == SlideState.DRAGGING || mSlideState == SlideState.HIDDEN) return;
int newTop = computePanelTopPosition(0.0f) + (mIsSlidingUp ? +mPanelHeight : -mPanelHeight);
smoothSlideTo(computeSlideOffset(newTop), 0);
if (mFirstLayout) {
mSlideState = SlideState.HIDDEN;
} else {
if (mSlideState == SlideState.DRAGGING || mSlideState == SlideState.HIDDEN) return;
int newTop = computePanelTopPosition(0.0f) + (mIsSlidingUp ? +mPanelHeight : -mPanelHeight);
smoothSlideTo(computeSlideOffset(newTop), 0);
}
}

@SuppressLint("NewApi")
Expand Down

0 comments on commit 1157c93

Please sign in to comment.