BoomMenu icon indicating copy to clipboard operation
BoomMenu copied to clipboard

Layout problem after screen rotation (configuration changed)

Open nicomazz opened this issue 7 years ago • 9 comments

When app start in portait (all ok): device-2017-08-28-143714

After activity rotation (with android:configChanges="keyboardHidden|orientation|screenSize" and onConfigurationChanged overrided): device-2017-08-28-143741

I can't recreate the entire activity. How can I manage this problem? Any way to "re-layout" the view?

nicomazz avatar Aug 28 '17 12:08 nicomazz

Since version 2.1.1, you can set the orientation-adaptable property for BMB to deal with this problem. For more details, check orientation-example-activity.

Nightonke avatar Sep 11 '17 16:09 Nightonke

After setting orientationAdaptable to true I always receive this every time the orientation changes:

FATAL EXCEPTION: main
Process: com.-----.----, PID: 9015
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams com.nightonke.boommenu.BackgroundView.getLayoutParams()' on a null object reference
    at com.nightonke.boommenu.BoomMenuButton.calculateEndPositions(BoomMenuButton.java:907)
    at com.nightonke.boommenu.BoomMenuButton.access$2100(BoomMenuButton.java:66)
    at com.nightonke.boommenu.BoomMenuButton$9.run(BoomMenuButton.java:1108)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)

                                                                               at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

nicomazz avatar Sep 12 '17 12:09 nicomazz

I got the same problem and same error with your orientation-adaptable solution. Do you have any other solution for this @Nightonke ?

WrathChaos avatar Sep 14 '17 14:09 WrathChaos

Hello again, I solve the problem but it is not a cool solution. Before use bmb.setOrientationAdaptable(true) , BoomMenu simply needs to bmb.boomImmediately(). So it never crush but I do not want to boom each time when orientation changes. We need a cooler solution @Nightonke

WrathChaos avatar Sep 15 '17 09:09 WrathChaos

I have a similar problem. For me it doesn't crash, and boomImmediately() works fine. But when using just boom() the buttons are still misaligned (the background however is correct). When rebooming they jump to the correct place in the center and then reboom from there. So there must be something wrong still with the boom animation.

See the gif: First I call the menu before any rotation, then I rotate the screen 90 degrees and call the menu again.

(I call the menu from a background service. It is in its own FrameLayout.)

bmb-issue

sikaiser avatar Sep 24 '17 16:09 sikaiser

I called boomImmediately() before bmb.setOrientationAdaptable(true) , but still I got the same problem.

The background variable was null when the function calculateEndPositions() has been called

please any solution? @Nightonke

Rahaf-ah avatar Nov 08 '17 08:11 Rahaf-ah

bmb.setOnBoomListener( new OnBoomListenerAdapter() { @Override public void onBoomWillShow() { super.onBoomWillShow(); bmb.setOrientationAdaptable(true); } @Override public void onBoomDidHide() { super.onBoomDidHide(); bmb.setOrientationAdaptable(false); } });

AidanTheonas avatar Mar 15 '18 09:03 AidanTheonas

+1

uestccokey avatar Apr 14 '19 09:04 uestccokey

bmb.setOnBoomListener(
new OnBoomListenerAdapter() {
@Override
public void onBoomWillShow() {
super.onBoomWillShow();
bmb.setOrientationAdaptable(true);
}
@Override
public void onBoomDidHide() {
super.onBoomDidHide();
bmb.setOrientationAdaptable(false);
}
});

@AidanTheonas code worked for me but make sure that you only use setOrientationAdaptable inside these listeners only.

i don't understand the reasoning behind it, but would still love to see a neat fix for this issue. @Nightonke

Mohamed-Effat avatar Feb 18 '20 14:02 Mohamed-Effat