Skip to content

Commit

Permalink
Use cached orientation in OrientationHelper (natario1#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
aartikov authored and natario1 committed Oct 19, 2018
1 parent 1458107 commit ee1d397
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,10 @@ public void testRotation() {
helper.mListener.onOrientationChanged(270);
assertEquals(helper.getDeviceOrientation(), 270);
verify(callback, times(1)).onDeviceOrientationChanged(270);

// It is still 270 after ORIENTATION_UNKNOWN
helper.mListener.onOrientationChanged(OrientationEventListener.ORIENTATION_UNKNOWN);
assertEquals(helper.getDeviceOrientation(), 270);
verify(callback, times(1)).onDeviceOrientationChanged(270);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface Callback {
public void onOrientationChanged(int orientation) {
int or = 0;
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
or = 0;
or = mDeviceOrientation != -1 ? mDeviceOrientation : 0;
} else if (orientation >= 315 || orientation < 45) {
or = 0;
} else if (orientation >= 45 && orientation < 135) {
Expand Down

0 comments on commit ee1d397

Please sign in to comment.