Possibly fixed multiple listener addition
This commit is contained in:
parent
f27f7e4c81
commit
b94b33ecf1
11 changed files with 24 additions and 12 deletions
|
|
@ -60,6 +60,7 @@ public interface HalAbstractController {
|
|||
|
||||
/**
|
||||
* Add a listener to the controller that will receive all device reports from registered devices.
|
||||
* Multiple calls with the same listener should only add register the listener once any subsequent calls should be ignored.
|
||||
*/
|
||||
void addListener(HalDeviceReportListener listener);
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ public abstract class HalAbstractControllerManager<T extends HalAbstractControll
|
|||
|
||||
/**
|
||||
* Will return a singleton controller instance of the given class.
|
||||
* If a instance does not exist yet the a new instance will be allocated
|
||||
* If a instance does not exist yet then a new instance will be allocated
|
||||
* depending on if the controller is ready thorough the {@link HalAbstractController#isAvailable()} method.
|
||||
*
|
||||
* @param clazz is the class of the wanted object instance wanted
|
||||
|
|
@ -167,8 +167,10 @@ public abstract class HalAbstractControllerManager<T extends HalAbstractControll
|
|||
}
|
||||
}
|
||||
|
||||
// Assign the manager as a listener
|
||||
|
||||
// Assign the manager as a listener, This needs to be done every time as the controllerMap is a
|
||||
// shared static for all HalControllerManagers and as we do not know if the current manager is
|
||||
// added as listener or not we need to add it and let the implementation of addListener method
|
||||
// handle duplicate calls.
|
||||
if (this instanceof HalDeviceReportListener)
|
||||
controller.addListener((HalDeviceReportListener) this);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue