summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2009-06-04 12:11:25 -0700
committerAmith Yamasani <yamasani@google.com>2009-06-04 14:00:20 -0700
commitd296fafab597a6597d9eb276abe6f6eb049e9f12 (patch)
treef65bd59646917e34ca4ed9b071d8930abcd9f38a /core
parent85dfec8c35d4e3216591bd2e534bbebd6338b969 (diff)
downloadframeworks_base-d296fafab597a6597d9eb276abe6f6eb049e9f12.zip
frameworks_base-d296fafab597a6597d9eb276abe6f6eb049e9f12.tar.gz
frameworks_base-d296fafab597a6597d9eb276abe6f6eb049e9f12.tar.bz2
Avoid touching all adapter items when building accessibility event.
Only check for enabled items if the list is less than 15 items.
Diffstat (limited to 'core')
-rw-r--r--core/java/android/widget/ListView.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 99cf6f8..a195ac7 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -1852,18 +1852,25 @@ public class ListView extends AbsListView {
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
boolean populated = super.dispatchPopulateAccessibilityEvent(event);
+ // If the item count is less than 15 then subtract disabled items from the count and
+ // position. Otherwise ignore disabled items.
if (!populated) {
int itemCount = 0;
int currentItemIndex = getSelectedItemPosition();
ListAdapter adapter = getAdapter();
if (adapter != null) {
- for (int i = 0, count = adapter.getCount(); i < count; i++) {
- if (adapter.isEnabled(i)) {
- itemCount++;
- } else if (i <= currentItemIndex) {
- currentItemIndex--;
+ final int count = adapter.getCount();
+ if (count < 15) {
+ for (int i = 0; i < count; i++) {
+ if (adapter.isEnabled(i)) {
+ itemCount++;
+ } else if (i <= currentItemIndex) {
+ currentItemIndex--;
+ }
}
+ } else {
+ itemCount = count;
}
}