* commit 'a0d3d003c858012f9c4af2b1f84227baacec49ce': Consider RTL layout in DPAD navigation in Gallery
This commit is contained in:
@@ -1210,13 +1210,13 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList
|
|||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||||
if (movePrevious()) {
|
if (moveDirection(-1)) {
|
||||||
playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT);
|
playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||||
if (moveNext()) {
|
if (moveDirection(1)) {
|
||||||
playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT);
|
playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1256,18 +1256,12 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList
|
|||||||
return super.onKeyUp(keyCode, event);
|
return super.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean movePrevious() {
|
boolean moveDirection(int direction) {
|
||||||
if (mItemCount > 0 && mSelectedPosition > 0) {
|
direction = isLayoutRtl() ? -direction : direction;
|
||||||
scrollToChild(mSelectedPosition - mFirstPosition - 1);
|
int targetPosition = mSelectedPosition + direction;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean moveNext() {
|
if (mItemCount > 0 && targetPosition >= 0 && targetPosition < mItemCount) {
|
||||||
if (mItemCount > 0 && mSelectedPosition < mItemCount - 1) {
|
scrollToChild(targetPosition - mFirstPosition);
|
||||||
scrollToChild(mSelectedPosition - mFirstPosition + 1);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user