aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien/tincapp/extensions/Android.kt
blob: 84dcfde39f400ff471b2f85db5149857d7bc0492 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package org.pacien.tincapp.extensions

import android.widget.ArrayAdapter
import android.widget.TextView
import org.pacien.tincapp.R
import org.pacien.tincapp.context.App

/**
 * @author pacien
 */
object Android {

    fun <T> ArrayAdapter<T>.setElements(elems: Collection<T>) {
        setNotifyOnChange(false)
        clear()
        addAll(elems)
        notifyDataSetChanged()
        setNotifyOnChange(true)
    }

    fun TextView.setText(list: List<String>) {
        text = if (list.isNotEmpty()) list.joinToString("\n") else App.getContext().getString(R.string.value_none)
    }

}