From b5884b3ad4964d6bdbbb92c160bed84cdbb059a1 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 20 Aug 2018 00:53:22 +0200 Subject: Split status activity into tabs Refactoring the underlying code to use lifecycle-aware classes --- .../java/org/pacien/tincapp/extensions/Android.kt | 34 ---------------- .../tincapp/extensions/ListViewExtensions.kt | 47 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 34 deletions(-) delete mode 100644 app/src/main/java/org/pacien/tincapp/extensions/Android.kt create mode 100644 app/src/main/java/org/pacien/tincapp/extensions/ListViewExtensions.kt (limited to 'app/src/main/java/org/pacien/tincapp/extensions') diff --git a/app/src/main/java/org/pacien/tincapp/extensions/Android.kt b/app/src/main/java/org/pacien/tincapp/extensions/Android.kt deleted file mode 100644 index 24a9c38..0000000 --- a/app/src/main/java/org/pacien/tincapp/extensions/Android.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon - * Copyright (C) 2017-2018 Pacien TRAN-GIRARD - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.pacien.tincapp.extensions - -import android.widget.ArrayAdapter - -/** - * @author pacien - */ -object Android { - fun ArrayAdapter.setElements(elements: Collection) { - setNotifyOnChange(false) - clear() - addAll(elements) - notifyDataSetChanged() - setNotifyOnChange(true) - } -} diff --git a/app/src/main/java/org/pacien/tincapp/extensions/ListViewExtensions.kt b/app/src/main/java/org/pacien/tincapp/extensions/ListViewExtensions.kt new file mode 100644 index 0000000..3957fa5 --- /dev/null +++ b/app/src/main/java/org/pacien/tincapp/extensions/ListViewExtensions.kt @@ -0,0 +1,47 @@ +/* + * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon + * Copyright (C) 2017-2018 Pacien TRAN-GIRARD + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.pacien.tincapp.extensions + +import android.view.View +import android.widget.ArrayAdapter +import android.widget.ListView + +/** + * @author pacien + */ + +fun ArrayAdapter.setElements(elements: Collection?) { + if (elements == null) return + + synchronized(this) { + setNotifyOnChange(false) + clear() + addAll(elements) + notifyDataSetChanged() + setNotifyOnChange(true) + } +} + +fun ListView.hideTopSeparator() { + addHeaderView(View(context), null, false) +} + +fun ListView.hideBottomSeparator() { + addFooterView(View(context), null, false) +} -- cgit v1.2.3