diff options
author | Alan Viverette <alanv@google.com> | 2015-03-25 20:25:19 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-03-25 20:25:19 +0000 |
commit | 3a79e434a6e840f47a47387743385a2cd5faab54 (patch) | |
tree | 38ca62920c9ca67b9a99835a5a68f1c810141ffa /core | |
parent | b8d872fbde849150083836f0d5be3f6fe1c03fb9 (diff) | |
parent | a0d3d003c858012f9c4af2b1f84227baacec49ce (diff) | |
download | frameworks_base-3a79e434a6e840f47a47387743385a2cd5faab54.zip frameworks_base-3a79e434a6e840f47a47387743385a2cd5faab54.tar.gz frameworks_base-3a79e434a6e840f47a47387743385a2cd5faab54.tar.bz2 |
am a0d3d003: am 5fc9b336: Merge "Consider RTL layout in DPAD navigation in Gallery"
* commit 'a0d3d003c858012f9c4af2b1f84227baacec49ce':
Consider RTL layout in DPAD navigation in Gallery
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/widget/Gallery.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java index f7c839f..b4a003a 100644 --- a/core/java/android/widget/Gallery.java +++ b/core/java/android/widget/Gallery.java @@ -1210,13 +1210,13 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: - if (movePrevious()) { + if (moveDirection(-1)) { playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT); return true; } break; case KeyEvent.KEYCODE_DPAD_RIGHT: - if (moveNext()) { + if (moveDirection(1)) { playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT); return true; } @@ -1256,18 +1256,12 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList return super.onKeyUp(keyCode, event); } - boolean movePrevious() { - if (mItemCount > 0 && mSelectedPosition > 0) { - scrollToChild(mSelectedPosition - mFirstPosition - 1); - return true; - } else { - return false; - } - } + boolean moveDirection(int direction) { + direction = isLayoutRtl() ? -direction : direction; + int targetPosition = mSelectedPosition + direction; - boolean moveNext() { - if (mItemCount > 0 && mSelectedPosition < mItemCount - 1) { - scrollToChild(mSelectedPosition - mFirstPosition + 1); + if (mItemCount > 0 && targetPosition >= 0 && targetPosition < mItemCount) { + scrollToChild(targetPosition - mFirstPosition); return true; } else { return false; |