Closed sirkyven closed 5 years ago
I found that I had an issue with calling setPanelHeight() if calling it quickly and repeatedly with different values. I have a ViewPager that changes the panel height and if the user quickly drags back and forth between the two views, the PanelState erroneously gets set to either HIDDEN or ANCHORED. I fixed this by creating the following function in SlidingUpPanelLayout and I'm curious if it solves your issue as well...
public void setPanelHeight(int val, PanelState panelState) { mSlideState = panelState; setPanelHeight(val); }
Ty jgrife:-) But It didn't work, actually when I let android to take care of rotation, it's taking appropriate values from land directory. When I tried to pass the same values in onConfigurationChanged method, It's not drawing the second child of umanoSlidingPanelLayout.
Is there any alternative way to change the panel height, instead of changing through setPanelHeight in OnConfigurationChanged method.
sorry if this sounds obtuse, but you say that android is taking the appropriate values from the land directory... do you mean that you have tried creating a /layout-land/ layout directory and in your layout there you have your SlidingUpPanelLayout view and are able to set the umanoPanelHeight and everything works just fine? If so, what is the issue with setting the height via the layout?
I'm also having issues with the sliding panel hiding itself when I change the panel from HIDDEN to COLLAPSED state and call setPanelHeight()
to change from a smaller height (106dp
) to a larger height (146dp
). A full rundown of the issue w/ screenshots is here on the OneBusAway project:
https://github.com/OneBusAway/onebusaway-android/issues/294
It seems like the resize drops the panel beneath the bottom of the screen temporarily, which can trigger the panel to hide itself - onPanelHidden()
gets called when this occurs. I've also noticed that I get a negative slide offset when this occurs in onPanelSlide()
:
09-18 17:01:39.891 12220-12220/com.joulespersecond.seattlebusbot D/BubblePopupHelper﹕ isShowingBubblePopup : false
09-18 17:01:39.891 12220-12220/com.joulespersecond.seattlebusbot D/HomeActivity﹕ onPanelSlide, offset -0.00729927
09-18 17:01:39.901 12220-12220/com.joulespersecond.seattlebusbot D/HomeActivity﹕ onPanelSlide, offset -0.00486618
09-18 17:01:39.921 12220-12220/com.joulespersecond.seattlebusbot D/HomeActivity﹕ onPanelSlide, offset -0.0030413626
09-18 17:01:39.941 12220-12220/com.joulespersecond.seattlebusbot D/HomeActivity﹕ onPanelSlide, offset -0.001216545
09-18 17:01:39.951 12220-12220/com.joulespersecond.seattlebusbot D/HomeActivity﹕ onPanelSlide, offset -6.082725E-4
09-18 17:01:39.981 12220-12220/com.joulespersecond.seattlebusbot D/HomeActivity﹕ onPanelSlide, offset 0.0
Maybe this code in onViewDragStateChanged()
is causing it, triggered by the negative offset?
@Override
public void onViewDragStateChanged(int state) {
if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
mSlideOffset = computeSlideOffset(mSlideableView.getTop());
applyParallaxForCurrentSlideOffset();
if (mSlideOffset == 1) {
if (mSlideState != PanelState.EXPANDED) {
updateObscuredViewVisibility();
mSlideState = PanelState.EXPANDED;
dispatchOnPanelExpanded(mSlideableView);
}
} else if (mSlideOffset == 0) {
if (mSlideState != PanelState.COLLAPSED) {
mSlideState = PanelState.COLLAPSED;
dispatchOnPanelCollapsed(mSlideableView);
}
} else if (mSlideOffset < 0) { // <---Could this be hiding the panel?
mSlideState = PanelState.HIDDEN;
mSlideableView.setVisibility(View.INVISIBLE);
dispatchOnPanelHidden(mSlideableView);
} else if (mSlideState != PanelState.ANCHORED) {
updateObscuredViewVisibility();
mSlideState = PanelState.ANCHORED;
dispatchOnPanelAnchored(mSlideableView);
}
}
}
I don't recall seeing this prior to v3.0.0 of the library, but I could be wrong. The above happens intermittently in the app, so its been hard to pin down.
Recently I noticed that a similar (same?) problem seems to be triggered when opening the soft keyboard and calling setPanelHeight()
to change from a larger to smaller value. This is easier to consistently reproduce in the app - here's a video:
https://youtu.be/0Q7osS8SQuE
The following steps work as expected, which you see from 0:00 to 0:12 - I repeat these steps twice to open the keyboard twice and still see the header without problems:
setPanelHeight()
with a smaller valuesetPanelHeight()
with a larger valueAs long as I return to the HIDDEN state between opening the keyboard, everything is fine. But, if I do the following, without returning to the HIDDEN state (from 0:12 on):
setPanelHeight()
with a smaller valuesetPanelHeight()
with a larger valuesetPanelHeight()
with a smaller value <-- Header disappears, onPanelHidden()
gets called...the header disappears. It seems like the sliding panel loses track of its vertical state, and thinks its lower on the screen than it actually is, which causes it to hide itself.
@vgangisetti just curious why you closed this? Did you find a fix?
When I tried to set panel height in onConfigChanged callback of a fragment, Second child view of SlidingPanelLayout hasn't been rendered. I could trace it out that, the problem is with setPanleHeight(). Help please..!!