Made addToArray method able to handle null arguments

pull/14/head
Sam Bosley 12 years ago
parent 52f1631049
commit fa1b0d3fb2

@ -776,11 +776,24 @@ public class AndroidUtilities {
* @return * @return
*/ */
public static Property<?>[] addToArray(Property<?>[] list, Property<?>... newItems) { public static Property<?>[] addToArray(Property<?>[] list, Property<?>... newItems) {
Property<?>[] newList = new Property<?>[list.length + newItems.length]; int originalListLength = 0;
int length = 0;
if (list != null) {
originalListLength = list.length;
length += list.length;
}
if (newItems != null)
length += newItems.length;
Property<?>[] newList = new Property<?>[length];
if (list != null) {
for(int i = 0; i < list.length; i++) for(int i = 0; i < list.length; i++)
newList[i] = list[i]; newList[i] = list[i];
}
if (newItems != null) {
for(int i = 0; i < newItems.length; i++) for(int i = 0; i < newItems.length; i++)
newList[list.length + i] = newItems[i]; newList[originalListLength + i] = newItems[i];
}
return newList; return newList;
} }

Loading…
Cancel
Save