mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
Small spacing fixes
This commit is contained in:
parent
2d5dcf24da
commit
6b24f2d547
@ -136,7 +136,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
|
|||||||
private int start() {
|
private int start() {
|
||||||
// If already starting or running, then just return
|
// If already starting or running, then just return
|
||||||
if ((this.status == AccelListener.RUNNING) || (this.status == AccelListener.STARTING)) {
|
if ((this.status == AccelListener.RUNNING) || (this.status == AccelListener.STARTING)) {
|
||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setStatus(AccelListener.STARTING);
|
this.setStatus(AccelListener.STARTING);
|
||||||
@ -146,28 +146,28 @@ public class AccelListener extends Plugin implements SensorEventListener {
|
|||||||
|
|
||||||
// If found, then register as listener
|
// If found, then register as listener
|
||||||
if ((list != null) && (list.size() > 0)) {
|
if ((list != null) && (list.size() > 0)) {
|
||||||
this.mSensor = list.get(0);
|
this.mSensor = list.get(0);
|
||||||
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_UI);
|
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_UI);
|
||||||
this.setStatus(AccelListener.STARTING);
|
this.setStatus(AccelListener.STARTING);
|
||||||
} else {
|
} else {
|
||||||
this.setStatus(AccelListener.ERROR_FAILED_TO_START);
|
this.setStatus(AccelListener.ERROR_FAILED_TO_START);
|
||||||
this.fail(AccelListener.ERROR_FAILED_TO_START, "No sensors found to register accelerometer listening to.");
|
this.fail(AccelListener.ERROR_FAILED_TO_START, "No sensors found to register accelerometer listening to.");
|
||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait until running
|
// Wait until running
|
||||||
long timeout = 2000;
|
long timeout = 2000;
|
||||||
while ((this.status == STARTING) && (timeout > 0)) {
|
while ((this.status == STARTING) && (timeout > 0)) {
|
||||||
timeout = timeout - 100;
|
timeout = timeout - 100;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timeout == 0) {
|
if (timeout == 0) {
|
||||||
this.setStatus(AccelListener.ERROR_FAILED_TO_START);
|
this.setStatus(AccelListener.ERROR_FAILED_TO_START);
|
||||||
this.fail(AccelListener.ERROR_FAILED_TO_START, "Accelerometer could not be started.");
|
this.fail(AccelListener.ERROR_FAILED_TO_START, "Accelerometer could not be started.");
|
||||||
}
|
}
|
||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
@ -222,13 +222,13 @@ public class AccelListener extends Plugin implements SensorEventListener {
|
|||||||
|
|
||||||
if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {
|
if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {
|
||||||
|
|
||||||
// Save time that event was received
|
// Save time that event was received
|
||||||
this.timestamp = System.currentTimeMillis();
|
this.timestamp = System.currentTimeMillis();
|
||||||
this.x = event.values[0];
|
this.x = event.values[0];
|
||||||
this.y = event.values[1];
|
this.y = event.values[1];
|
||||||
this.z = event.values[2];
|
this.z = event.values[2];
|
||||||
|
|
||||||
this.win();
|
this.win();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user