Skip to content

Commit 59fef9a

Browse files
rocboronatSloy
authored andcommitted
Avoid registering the sensor if it is null (#12)
1 parent 085cbb2 commit 59fef9a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

library/src/main/java/com/schibsted/spain/parallaxlayerlayout/SensorTranslationUpdater.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ public void unSubscribe() {
4444

4545
public void registerSensorManager() {
4646
if (sensorManager != null) {
47-
sensorManager.registerListener(this,
48-
sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR), DEFAULT_SAMPLING_PERIOD);
47+
Sensor rotationVectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
48+
if (rotationVectorSensor != null) {
49+
sensorManager.registerListener(this, rotationVectorSensor, DEFAULT_SAMPLING_PERIOD);
50+
}
4951
}
5052
}
5153

@@ -192,4 +194,4 @@ public void setTiltSensitivity(float tiltSensitivity) {
192194

193195
mTiltSensitivity = tiltSensitivity;
194196
}
195-
}
197+
}

0 commit comments

Comments
 (0)