Calling getLocationOnScreen() before the View is attached to a window can throw an NPE. This change simply guards against the exception.
Calling getLocationOnScreen() before the View is attached to a window can throw an NPE. This change simply guards against the exception.