mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-23 01:06:23 +08:00
Implement ReturnValue() for each plugin.
This commit is contained in:
parent
2b015164f4
commit
a13b8fc124
@ -133,6 +133,17 @@ public class AccelListener implements SensorEventListener, Plugin{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies if action to be executed returns a value.
|
||||||
|
*
|
||||||
|
* @param action The action to execute
|
||||||
|
* @return T=returns value
|
||||||
|
*/
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
// TODO
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*/
|
*/
|
||||||
|
@ -101,6 +101,22 @@ public class AudioHandler implements Plugin {
|
|||||||
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies if action to be executed returns a value.
|
||||||
|
*
|
||||||
|
* @param action The action to execute
|
||||||
|
* @return T=returns value
|
||||||
|
*/
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
if (action.equals("getCurrentPositionAudio")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (action.equals("getDurationAudio")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
|
@ -88,6 +88,16 @@ public class CameraLauncher implements Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies if action to be executed returns a value.
|
||||||
|
*
|
||||||
|
* @param action The action to execute
|
||||||
|
* @return T=returns value
|
||||||
|
*/
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*/
|
*/
|
||||||
|
@ -44,7 +44,7 @@ public class CompassListener implements SensorEventListener, Plugin{
|
|||||||
*/
|
*/
|
||||||
public CompassListener() {
|
public CompassListener() {
|
||||||
this.timeStamp = 0;
|
this.timeStamp = 0;
|
||||||
this.status = CompassListener.STOPPED;
|
this.setStatus(CompassListener.STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,6 +91,21 @@ public class CompassListener implements SensorEventListener, Plugin{
|
|||||||
return new PluginResult(status, i);
|
return new PluginResult(status, i);
|
||||||
}
|
}
|
||||||
else if (action.equals("getHeading")) {
|
else if (action.equals("getHeading")) {
|
||||||
|
// If not running, then this is an async call, so don't worry about waiting
|
||||||
|
if (this.status != RUNNING) {
|
||||||
|
int r = this.start();
|
||||||
|
if (r == ERROR_FAILED_TO_START) {
|
||||||
|
return new PluginResult(PluginResult.Status.IO_EXCEPTION, ERROR_FAILED_TO_START);
|
||||||
|
}
|
||||||
|
// Wait until running
|
||||||
|
while (this.status == STARTING) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
float f = this.getHeading();
|
float f = this.getHeading();
|
||||||
return new PluginResult(status, f);
|
return new PluginResult(status, f);
|
||||||
}
|
}
|
||||||
@ -108,6 +123,28 @@ public class CompassListener implements SensorEventListener, Plugin{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies if action to be executed returns a value.
|
||||||
|
*
|
||||||
|
* @param action The action to execute
|
||||||
|
* @return T=returns value
|
||||||
|
*/
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
if (action.equals("getStatus")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (action.equals("getHeading")) {
|
||||||
|
// Can only return value if RUNNING
|
||||||
|
if (this.status == RUNNING) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (action.equals("getTimeout")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*/
|
*/
|
||||||
@ -162,13 +199,13 @@ public class CompassListener implements SensorEventListener, Plugin{
|
|||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
this.mSensor = list.get(0);
|
this.mSensor = list.get(0);
|
||||||
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||||
this.status = CompassListener.STARTING;
|
|
||||||
this.lastAccessTime = System.currentTimeMillis();
|
this.lastAccessTime = System.currentTimeMillis();
|
||||||
|
this.setStatus(CompassListener.STARTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If error, then set status to error
|
// If error, then set status to error
|
||||||
else {
|
else {
|
||||||
this.status = CompassListener.ERROR_FAILED_TO_START;
|
this.setStatus(CompassListener.ERROR_FAILED_TO_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.status;
|
return this.status;
|
||||||
@ -181,7 +218,7 @@ public class CompassListener implements SensorEventListener, Plugin{
|
|||||||
if (this.status != CompassListener.STOPPED) {
|
if (this.status != CompassListener.STOPPED) {
|
||||||
this.sensorManager.unregisterListener(this);
|
this.sensorManager.unregisterListener(this);
|
||||||
}
|
}
|
||||||
this.status = CompassListener.STOPPED;
|
this.setStatus(CompassListener.STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -202,7 +239,7 @@ public class CompassListener implements SensorEventListener, Plugin{
|
|||||||
// Save heading
|
// Save heading
|
||||||
this.timeStamp = System.currentTimeMillis();
|
this.timeStamp = System.currentTimeMillis();
|
||||||
this.heading = heading;
|
this.heading = heading;
|
||||||
this.status = CompassListener.RUNNING;
|
this.setStatus(CompassListener.RUNNING);
|
||||||
|
|
||||||
// If heading hasn't been read for TIMEOUT time, then turn off compass sensor to save power
|
// If heading hasn't been read for TIMEOUT time, then turn off compass sensor to save power
|
||||||
if ((this.timeStamp - this.lastAccessTime) > this.TIMEOUT) {
|
if ((this.timeStamp - this.lastAccessTime) > this.TIMEOUT) {
|
||||||
@ -246,4 +283,13 @@ public class CompassListener implements SensorEventListener, Plugin{
|
|||||||
public long getTimeout() {
|
public long getTimeout() {
|
||||||
return this.TIMEOUT;
|
return this.TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the status and send it to JavaScript.
|
||||||
|
* @param status
|
||||||
|
*/
|
||||||
|
private void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,16 @@ public class ContactManager implements Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies if action to be executed returns a value.
|
||||||
|
*
|
||||||
|
* @param action The action to execute
|
||||||
|
* @return T=returns value
|
||||||
|
*/
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*/
|
*/
|
||||||
|
@ -64,6 +64,16 @@ public class CryptoHandler implements Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies if action to be executed returns a value.
|
||||||
|
*
|
||||||
|
* @param action The action to execute
|
||||||
|
* @return T=returns value
|
||||||
|
*/
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*/
|
*/
|
||||||
|
@ -80,6 +80,16 @@ public class GeoBroker implements Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies if action to be executed returns a value.
|
||||||
|
*
|
||||||
|
* @param action The action to execute
|
||||||
|
* @return T=returns value
|
||||||
|
*/
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*/
|
*/
|
||||||
|
@ -76,6 +76,10 @@ public class NetworkManager implements Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*/
|
*/
|
||||||
|
@ -82,6 +82,16 @@ public class Storage implements Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies if action to be executed returns a value.
|
||||||
|
*
|
||||||
|
* @param action The action to execute
|
||||||
|
* @return T=returns value
|
||||||
|
*/
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*/
|
*/
|
||||||
|
@ -70,6 +70,16 @@ public class TempListener implements SensorEventListener, Plugin {
|
|||||||
return new PluginResult(status, result);
|
return new PluginResult(status, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies if action to be executed returns a value.
|
||||||
|
*
|
||||||
|
* @param action The action to execute
|
||||||
|
* @return T=returns value
|
||||||
|
*/
|
||||||
|
public boolean hasReturnValue(String action) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user