aboutsummaryrefslogtreecommitdiff
path: root/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt
blob: cb38f2937d6a071174f704877776f3c9aea8e042 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Copyright 2018 Allan Wang
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
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.GenericItem
import com.mikepenz.fastadapter.adapters.ItemAdapter
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial

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

    override fun onCreate(savedInstanceState: Bundle?, configs: Configs): Boolean {
        val adapter = ItemAdapter<GenericItem>()
        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
    }
}