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;
for(int i = 0; i < list.length; i++) int length = 0;
newList[i] = list[i]; if (list != null) {
for(int i = 0; i < newItems.length; i++) originalListLength = list.length;
newList[list.length + i] = newItems[i]; 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++)
newList[i] = list[i];
}
if (newItems != null) {
for(int i = 0; i < newItems.length; i++)
newList[originalListLength + i] = newItems[i];
}
return newList; return newList;
} }

Loading…
Cancel
Save