aboutsummaryrefslogtreecommitdiff
path: root/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt
blob: ada60cad4ea61fe0b9c0a9cbd05a58ff6a4202f0 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package ca.allanwang.kau.sample

import android.os.Bundle
import ca.allanwang.kau.adapters.fastAdapter
import ca.allanwang.kau.iitems.CardIItem
import ca.allanwang.kau.ui.activities.ElasticRecyclerActivity
import ca.allanwang.kau.utils.toast
import com.mikepenz.fastadapter.IItem
import com.mikepenz.fastadapter.adapters.ItemAdapter
import com.mikepenz.google_material_typeface_library.GoogleMaterial

/**
 * Created by Allan Wang on 2017-07-17.
 */
class AdapterActivity : ElasticRecyclerActivity() {

    override fun onCreate(savedInstanceState: Bundle?, configs: Configs): Boolean {
        val adapter = ItemAdapter<IItem<*, *>>()
        recycler.adapter = fastAdapter(adapter)
        adapter.add(listOf(
                CardIItem {
                    titleRes = R.string.kau_text_copied
                    descRes = R.string.kau_lorem_ipsum
                    imageIIcon = GoogleMaterial.Icon.gmd_file_download
                },
                CardIItem {
                    titleRes = R.string.kau_text_copied
                    descRes = R.string.kau_lorem_ipsum
                },
                CardIItem {
                    titleRes = R.string.kau_text_copied
                    imageIIcon = GoogleMaterial.Icon.gmd_file_download
                    cardClick = { toast("Card click") }
                },
                CardIItem {
                    titleRes = R.string.kau_text_copied
                    descRes = R.string.kau_lorem_ipsum
                    imageIIcon = GoogleMaterial.Icon.gmd_file_download
                    button = "Test"
                    buttonClick = { toast("T") }
                },
                CardIItem {
                    titleRes = R.string.kau_text_copied
                    button = "Test"
                    buttonClick = { toast("HI") }
                }))
        setOutsideTapListener { finishAfterTransition() }
        return true
    }
}