summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2011-04-29 15:09:28 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2011-04-29 15:09:28 -0700
commit887e1a17eb9b12448f5929791b564565b2665aab (patch)
tree50680fd7bace81a65b4dabcf5a24df75e989f763
parent13dfabde8475d567618b386d14e0f809f96901da (diff)
downloadframeworks_base-887e1a17eb9b12448f5929791b564565b2665aab.zip
frameworks_base-887e1a17eb9b12448f5929791b564565b2665aab.tar.gz
frameworks_base-887e1a17eb9b12448f5929791b564565b2665aab.tar.bz2
Touch exploration - nits
Change-Id: Ie49558e0a81218dbad70c02f81dd7a59b3213d5c
-rw-r--r--core/java/android/view/accessibility/AccessibilityEvent.java10
-rw-r--r--core/java/android/view/accessibility/AccessibilityRecord.java10
-rw-r--r--core/java/android/widget/AdapterView.java2
-rw-r--r--core/java/android/widget/ListView.java14
-rw-r--r--core/java/android/widget/TextView.java2
5 files changed, 21 insertions, 17 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java
index 11c9392..5e18f55 100644
--- a/core/java/android/view/accessibility/AccessibilityEvent.java
+++ b/core/java/android/view/accessibility/AccessibilityEvent.java
@@ -253,7 +253,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
public static final int TYPES_ALL_MASK = 0xFFFFFFFF;
private static final int MAX_POOL_SIZE = 10;
- private static final Object mPoolLock = new Object();
+ private static final Object sPoolLock = new Object();
private static AccessibilityEvent sPool;
private static int sPoolSize;
@@ -375,7 +375,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
* @return An instance.
*/
public static AccessibilityEvent obtain() {
- synchronized (mPoolLock) {
+ synchronized (sPoolLock) {
if (sPool != null) {
AccessibilityEvent event = sPool;
sPool = sPool.mNext;
@@ -392,14 +392,16 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
* Return an instance back to be reused.
* <p>
* <b>Note: You must not touch the object after calling this function.</b>
+ *
+ * @throws IllegalStateException If the event is already recycled.
*/
@Override
public void recycle() {
if (mIsInPool) {
- return;
+ throw new IllegalStateException("Event already recycled!");
}
clear();
- synchronized (mPoolLock) {
+ synchronized (sPoolLock) {
if (sPoolSize <= MAX_POOL_SIZE) {
mNext = sPool;
sPool = this;
diff --git a/core/java/android/view/accessibility/AccessibilityRecord.java b/core/java/android/view/accessibility/AccessibilityRecord.java
index e095f43..fecf9df 100644
--- a/core/java/android/view/accessibility/AccessibilityRecord.java
+++ b/core/java/android/view/accessibility/AccessibilityRecord.java
@@ -39,7 +39,7 @@ public class AccessibilityRecord {
private static final int PROPERTY_FULL_SCREEN = 0x00000080;
private static final int MAX_POOL_SIZE = 10;
- private static final Object mPoolLock = new Object();
+ private static final Object sPoolLock = new Object();
private static AccessibilityRecord sPool;
private static int sPoolSize;
@@ -342,7 +342,7 @@ public class AccessibilityRecord {
* @return An instance.
*/
protected static AccessibilityRecord obtain() {
- synchronized (mPoolLock) {
+ synchronized (sPoolLock) {
if (sPool != null) {
AccessibilityRecord record = sPool;
sPool = sPool.mNext;
@@ -359,13 +359,15 @@ public class AccessibilityRecord {
* Return an instance back to be reused.
* <p>
* <b>Note: You must not touch the object after calling this function.</b>
+ *
+ * @throws IllegalStateException If the record is already recycled.
*/
public void recycle() {
if (mIsInPool) {
- return;
+ throw new IllegalStateException("Record already recycled!");
}
clear();
- synchronized (mPoolLock) {
+ synchronized (sPoolLock) {
if (sPoolSize <= MAX_POOL_SIZE) {
mNext = sPool;
sPool = this;
diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java
index 060f1a9..7fbfcbb 100644
--- a/core/java/android/widget/AdapterView.java
+++ b/core/java/android/widget/AdapterView.java
@@ -899,6 +899,8 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
+ super.onPopulateAccessibilityEvent(event);
+
View selectedView = getSelectedView();
if (selectedView != null) {
event.setEnabled(selectedView.isEnabled());
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 5618dbe..d115364 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -2009,16 +2009,12 @@ public class ListView extends AbsListView {
ListAdapter adapter = getAdapter();
if (adapter != null) {
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--;
- }
+ for (int i = 0; i < count; i++) {
+ if (adapter.isEnabled(i)) {
+ itemCount++;
+ } else if (i <= currentItemIndex) {
+ currentItemIndex--;
}
- } else {
- itemCount = count;
}
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 4d3aa68..4127f72 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -7897,6 +7897,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
+ super.onPopulateAccessibilityEvent(event);
+
if (!isShown()) {
return;
}