I am developing an application for connecting to a multisensor based on bluetooth ( SensorDrone ). It contains about 15 sensors, all of which can interact with an Android device using a third-party library with closed source code created by chip manufacturers.
A third-party library requires me to implement my own Java EventListener, which contains a function for each sensor that launches when its data is ready for use:
DroneEventListener droneEventListener = new DroneEventListener() { @Override public void temperatureMeasured(EventObject arg0) { readTemperatureFromDrone(); } @Override public void pressureMeasured(EventObject arg0) { }
However, I want to work with another library called funf to get information from Android's built-in sensors. This library is ideal for collecting data for both Android's built-in sensors and external sensors. This allows you to create a custom implementation of Probe . But, it is understood that the Probe (as suggested by the library and convention) is used for only one sensor at a time.
The original question:
So my question is this; Is it possible to somehow subdivide the DroneEventListener () class into specific sensors? After that, I could easily create my own probe for each sensor on the multisensor.
I understand that it can be bad practice to try and subdivide an abstract class, because it is conceptually a contract for the developer. However, I feel that soft hacking this code, working with an already existing, reliable and well-kept library ( funf ) is worth it.
Alternatively, are there any other creative solutions that would allow me to use the manufacturer library with funf?
Edit (June 24, 2013):
I decided that my use of the subdivide wording was clear to me. I essentially meant that I did not want to implement 20 empty methods when all that I used was one. The selected answer explains how to do this.
Clarified Question:
Is it possible to implement only one function from EventListener (with several functions) without having to execute messy empty methods?
codepringle
source share