use a different axis to determing if we are in landscape

This commit is contained in:
tibbi
2016-06-12 23:34:37 +02:00
parent 00835946c6
commit cd3697863e

View File

@ -213,14 +213,14 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
@Override @Override
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
if (event.values[1] < 6.5 && event.values[1] > -6.5) { if (event.values[0] < 6.5 && event.values[0] > -6.5) {
orientation = Constants.ORIENT_PORTRAIT;
} else {
if (event.values[0] > 0) { if (event.values[0] > 0) {
orientation = Constants.ORIENT_LANDSCAPE_LEFT; orientation = Constants.ORIENT_LANDSCAPE_LEFT;
} else { } else {
orientation = Constants.ORIENT_LANDSCAPE_RIGHT; orientation = Constants.ORIENT_LANDSCAPE_RIGHT;
} }
} else {
orientation = Constants.ORIENT_PORTRAIT;
} }
} }