Skip to content
Snippets Groups Projects
Unverified Commit 7831ee8c authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

chore: remove unneeded helpers

parent bc305cfc
No related branches found
No related tags found
No related merge requests found
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2020 Janne Mareike Koschinski
* Copyright (c) 2020 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package de.kuschku.malheur.util
import android.util.DisplayMetrics
import android.view.Display
fun Display.getMetrics(): DisplayMetrics {
val metrics = DisplayMetrics()
getRealMetrics(metrics)
return metrics
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2020 Janne Mareike Koschinski
* Copyright (c) 2020 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package de.kuschku.malheur.util
fun <T> reflectionCollectGetters(klass: Class<T>?) = klass?.declaredMethods
?.filter { it.parameterTypes.isEmpty() && it.returnType != Void::class.java }
?.filter { it.name != "getClass" }
?.filter { it.name.startsWith("get") || it.name.startsWith("is") }
?.mapNotNull {
var result: Pair<String, Any?>? = null
try {
result = it.name to it.invoke(it)
} catch (e: IllegalAccessException) {
} catch (e: IllegalArgumentException) {
}
result
}?.toMap()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment