Skip to content
This repository has been archived by the owner on Dec 19, 2021. It is now read-only.

Android layout-issue after calling application.off(application.orientationChangedEvent); #41

Closed
felixkrautschuk opened this issue Mar 21, 2020 · 1 comment

Comments

@felixkrautschuk
Copy link

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

In our real app, I need to react to the orientation-change of the device on one specific page, so when navigating to that page I call
application.on(application.orientationChangedEvent, function() { ... });
and when leavig the page I call
application.off(application.orientationChangedEvent);.

But after that, when you change the orientation of the device and then show the loading indicator, then the loading indicator and its dimmed background appear with a wrong layout, like this:
Bildschirmfoto 2020-03-21 um 20 05 59
Bildschirmfoto 2020-03-21 um 20 05 31

Just to see the single steps to recreate this issue, have a look at the GIF.
android_orientation_loadingindicator_1

Or when you start in landscape mode and then call application.off(orienationEvent); then it will look like this:
android_orientation_loadingindicator_2

Which platform(s) does your issue occur on?

  • Android
  • tested on Android 10, 7.1.1 and 5.1
  • emulator and device

Please, provide the following version numbers that your issue occurs with:

  • CLI: 6.5.0
  • Cross-platform modules: 6.5.0
  • Runtime(s): tns-android 6.5.0
  • Plugin(s): nativescript-loading-indicator 3.0.3

I also tested back to NS 6.1 and nativescript-loading-indicator 1.0.0 and the issue occurs the same way.

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.

  • start the app
  • tap the second button
  • change the device orientation
  • tap the first button to show the loading indicator -> wrong layout

Is there any code involved?

LoadingIndicatorAndroidIssue.zip

In this sample app, I ommited the application.on(orientationChanged); call as it is not important for recreating this issue.

By the way, when you just show the loading indicator (wthout registering/unregistering any event handlers) and change the orientation of the device while the indicator is showing, the layout is also not correct, but at least it will be correct again for the next show() call.

@felixkrautschuk
Copy link
Author

We figured out what is causing this issue.

Seems that application.off(application.orientationChangedEvent); without passing the event-handler function is removing "too much". Maybe there are some internal NativeScript event-handlers that are also removed this way.

function orientationChangedCallback(args) {
    console.log("orientationChanged: " + args.newValue);
}

application.on(application.orientationChangedEvent, orientationChangedCallback);

//...

application.off(application.orientationChangedEvent, orientationChangedCallback);

So passing the event-handler to application.off(...) as well like it is done in application.on(...) fixes this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant