Methods Summary |
---|
public boolean | add(TListener listener)
Preconditions.checkNotNull(listener);
synchronized (mListeners) {
// we need to register with the service first, because we need to find out if the
// service will actually support the request before we attempt anything
if (mListeners.isEmpty()) {
boolean registeredWithService;
try {
registeredWithService = registerWithServer();
} catch (RemoteException e) {
Log.e(mTag, "Error handling first listener.", e);
return false;
}
if (!registeredWithService) {
Log.e(mTag, "Unable to register listener transport.");
return false;
}
}
if (mListeners.contains(listener)) {
return true;
}
return mListeners.add(listener);
}
|
protected void | foreach(android.location.LocalListenerHelper$ListenerOperation operation)
Collection<TListener> listeners;
synchronized (mListeners) {
listeners = new ArrayList<>(mListeners);
}
for (TListener listener : listeners) {
try {
operation.execute(listener);
} catch (RemoteException e) {
Log.e(mTag, "Error in monitored listener.", e);
// don't return, give a fair chance to all listeners to receive the event
}
}
|
protected android.content.Context | getContext()
return mContext;
|
protected abstract boolean | registerWithServer()
|
public void | remove(TListener listener)
Preconditions.checkNotNull(listener);
synchronized (mListeners) {
boolean removed = mListeners.remove(listener);
boolean isLastRemoved = removed && mListeners.isEmpty();
if (isLastRemoved) {
try {
unregisterFromServer();
} catch (RemoteException e) {
Log.v(mTag, "Error handling last listener removal", e);
}
}
}
|
protected abstract void | unregisterFromServer()
|