[Android] Util methods to remove/add item from arrays
Geoffrey Métais
git at videolan.org
Mon Dec 12 16:15:08 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Dec 12 15:37:38 2016 +0100| [edabff22dcd4d79a25ed43c84c9565c24943c5b6] | committer: Geoffrey Métais
Util methods to remove/add item from arrays
> https://code.videolan.org/videolan/vlc-android/commit/edabff22dcd4d79a25ed43c84c9565c24943c5b6
---
vlc-android/src/org/videolan/vlc/util/Util.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index 7550b7c..482d75b 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -82,4 +82,24 @@ public class Util {
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
+
+ public static void removePositionInArray(Object[] array, int position, Object[] destArray) {
+ int offset = 0, count = destArray.length;
+ for (int i = 0; i<count; ++i) {
+ if (i == position)
+ ++offset;
+ destArray[i] = array[i+offset];
+ }
+ }
+
+ public static void addItemInArray(Object[] array, int position, Object item, Object[] destArray) {
+ int offset = 0, count = destArray.length;
+ for (int i = 0; i < count; ++i) {
+ if (i == position) {
+ ++offset;
+ destArray[i] = item;
+ } else
+ destArray[i] = array[i-offset];
+ }
+ }
}
More information about the Android
mailing list