blob: f9f9064b5a152cf3060479b648a279e1f45a2ef8 (
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
69
70
71
|
/*
* Copyright 2018 Allan Wang
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.pitchedapps.frost.iitems
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import ca.allanwang.kau.iitems.KauIItem
import ca.allanwang.kau.utils.bindView
import ca.allanwang.kau.utils.invisible
import ca.allanwang.kau.utils.setIcon
import ca.allanwang.kau.utils.visible
import ca.allanwang.kau.utils.withAlpha
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.drag.IDraggable
import com.pitchedapps.frost.R
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.injectors.ThemeProvider
/**
* Created by Allan Wang on 26/11/17.
*/
class TabIItem(val item: FbItem, private val themeProvider: ThemeProvider) :
KauIItem<TabIItem.ViewHolder>(
R.layout.iitem_tab_preview,
{ ViewHolder(it, themeProvider) }
),
IDraggable {
override val isDraggable: Boolean = true
class ViewHolder(
itemView: View,
private val themeProvider: ThemeProvider
) : FastAdapter.ViewHolder<TabIItem>(itemView) {
val image: ImageView by bindView(R.id.image)
val text: TextView by bindView(R.id.text)
override fun bindView(item: TabIItem, payloads: List<Any>) {
val isInToolbar = adapterPosition < 4
val color = if (isInToolbar) themeProvider.iconColor else themeProvider.textColor
image.setIcon(item.item.icon, 20, color)
if (isInToolbar)
text.invisible()
else {
text.visible().setText(item.item.titleId)
text.setTextColor(color.withAlpha(200))
}
}
override fun unbindView(item: TabIItem) {
image.setImageDrawable(null)
text.visible().text = null
}
}
}
|