diff options
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/extensions')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/extensions/ListViewExtensions.kt (renamed from app/src/main/java/org/pacien/tincapp/extensions/Android.kt) | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/extensions/Android.kt b/app/src/main/java/org/pacien/tincapp/extensions/ListViewExtensions.kt index 24a9c38..3957fa5 100644 --- a/app/src/main/java/org/pacien/tincapp/extensions/Android.kt +++ b/app/src/main/java/org/pacien/tincapp/extensions/ListViewExtensions.kt | |||
@@ -18,13 +18,18 @@ | |||
18 | 18 | ||
19 | package org.pacien.tincapp.extensions | 19 | package org.pacien.tincapp.extensions |
20 | 20 | ||
21 | import android.view.View | ||
21 | import android.widget.ArrayAdapter | 22 | import android.widget.ArrayAdapter |
23 | import android.widget.ListView | ||
22 | 24 | ||
23 | /** | 25 | /** |
24 | * @author pacien | 26 | * @author pacien |
25 | */ | 27 | */ |
26 | object Android { | 28 | |
27 | fun <T> ArrayAdapter<T>.setElements(elements: Collection<T>) { | 29 | fun <T> ArrayAdapter<T>.setElements(elements: Collection<T>?) { |
30 | if (elements == null) return | ||
31 | |||
32 | synchronized(this) { | ||
28 | setNotifyOnChange(false) | 33 | setNotifyOnChange(false) |
29 | clear() | 34 | clear() |
30 | addAll(elements) | 35 | addAll(elements) |
@@ -32,3 +37,11 @@ object Android { | |||
32 | setNotifyOnChange(true) | 37 | setNotifyOnChange(true) |
33 | } | 38 | } |
34 | } | 39 | } |
40 | |||
41 | fun ListView.hideTopSeparator() { | ||
42 | addHeaderView(View(context), null, false) | ||
43 | } | ||
44 | |||
45 | fun ListView.hideBottomSeparator() { | ||
46 | addFooterView(View(context), null, false) | ||
47 | } | ||