diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2010-06-14 11:06:33 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2010-06-14 11:06:33 -0700 |
commit | 51a9839ec69aab2800718c069bb76b480ac3c133 (patch) | |
tree | dd17e25460275607f7d1ae1ee08d89abb9317f4d | |
parent | 0d4dc714f9cb1b7f4df21e16892276b10d862635 (diff) | |
parent | 5978bcc32b1c3e05bd44600d1c5b0a18122487ea (diff) | |
download | frameworks_base-51a9839ec69aab2800718c069bb76b480ac3c133.zip frameworks_base-51a9839ec69aab2800718c069bb76b480ac3c133.tar.gz frameworks_base-51a9839ec69aab2800718c069bb76b480ac3c133.tar.bz2 |
merge from open-source master
Change-Id: I7a9f23192372fc6973d9f3eb399f895f4765f6b2
-rw-r--r-- | api/current.xml | 26 | ||||
-rw-r--r-- | core/java/android/widget/ArrayAdapter.java | 43 |
2 files changed, 67 insertions, 2 deletions
diff --git a/api/current.xml b/api/current.xml index 28d417c..e0380e7 100644 --- a/api/current.xml +++ b/api/current.xml @@ -197895,6 +197895,32 @@ <parameter name="object" type="T"> </parameter> </method> +<method name="addAll" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="collection" type="java.util.Collection<? extends T>"> +</parameter> +</method> +<method name="addAll" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="items" type="T..."> +</parameter> +</method> <method name="clear" return="void" abstract="false" diff --git a/core/java/android/widget/ArrayAdapter.java b/core/java/android/widget/ArrayAdapter.java index 32e5504..03ada94 100644 --- a/core/java/android/widget/ArrayAdapter.java +++ b/core/java/android/widget/ArrayAdapter.java @@ -24,6 +24,7 @@ import android.view.ViewGroup; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Comparator; import java.util.Collections; @@ -83,7 +84,7 @@ public class ArrayAdapter<T> extends BaseAdapter implements Filterable { */ private boolean mNotifyOnChange = true; - private Context mContext; + private Context mContext; private ArrayList<T> mOriginalValues; private ArrayFilter mFilter; @@ -181,6 +182,44 @@ public class ArrayAdapter<T> extends BaseAdapter implements Filterable { } /** + * Adds the specified Collection at the end of the array. + * + * @param collection The Collection to add at the end of the array. + */ + public void addAll(Collection<? extends T> collection) { + if (mOriginalValues != null) { + synchronized (mLock) { + mOriginalValues.addAll(collection); + if (mNotifyOnChange) notifyDataSetChanged(); + } + } else { + mObjects.addAll(collection); + if (mNotifyOnChange) notifyDataSetChanged(); + } + } + + /** + * Adds the specified items at the end of the array. + * + * @param items The items to add at the end of the array. + */ + public void addAll(T ... items) { + if (mOriginalValues != null) { + synchronized (mLock) { + for (T item : items) { + mOriginalValues.add(item); + } + if (mNotifyOnChange) notifyDataSetChanged(); + } + } else { + for (T item : items) { + mObjects.add(item); + } + if (mNotifyOnChange) notifyDataSetChanged(); + } + } + + /** * Inserts the specified object at the specified index in the array. * * @param object The object to insert into the array. @@ -236,7 +275,7 @@ public class ArrayAdapter<T> extends BaseAdapter implements Filterable { */ public void sort(Comparator<? super T> comparator) { Collections.sort(mObjects, comparator); - if (mNotifyOnChange) notifyDataSetChanged(); + if (mNotifyOnChange) notifyDataSetChanged(); } /** |