Interface LocationSharedListener


public interface LocationSharedListener

Receives the location a LocationButton obtained.

A single method, so it can be written as a lambda:

LocationButton b = new LocationButton();
b.addLocationSharedListener(loc -> {
    if (loc == null) {
        status.setText("Location not shared");
    } else {
        status.setText(loc.getLatitude() + ", " + loc.getLongitude());
    }
    status.getParent().revalidate();
});
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Invoked on the EDT once the user has answered, whether or not that produced a location.
  • Method Details

    • locationShared

      void locationShared(Location location)

      Invoked on the EDT once the user has answered, whether or not that produced a location.

      Only a user's answer reaches here. A platform control that fails to open does NOT: the component replaces it with an ordinary button and the user is asked again there, which is a recovery rather than a result. Reporting it as a null location would announce a decline for a request nobody made -- the platform opens its session when the control is attached, so the failure usually arrives before anyone has touched anything. Nothing is left hanging by the silence either, because a tap on the system's control is not observable to the application in the first place, so there is no pending request to resolve. LocationButton#isSystemRendered() is how to see which control is on screen.

      Parameters
      • location: the location the user shared, or null when they declined or no fix arrived before the button's timeout