This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
/
AestheticSlideActionView.kt
52 lines (43 loc) · 1.69 KB
/
AestheticSlideActionView.kt
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
package me.jfenn.alarmio.views
import android.content.Context
import android.util.AttributeSet
import com.afollestad.aesthetic.Aesthetic
import io.reactivex.disposables.Disposable
import me.jfenn.alarmio.interfaces.Subscribblable
import me.jfenn.slideactionview.SlideActionView
/**
* A SlideActionView extension class that implements
* Aesthetic theming.
*/
class AestheticSlideActionView : SlideActionView, Subscribblable {
private var textColorPrimarySubscription: Disposable? = null
private var textColorPrimaryInverseSubscription: Disposable? = null
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun subscribe() {
textColorPrimarySubscription = Aesthetic.get()
.textColorPrimary()
.subscribe { integer ->
touchHandleColor = integer
outlineColor = integer
iconColor = integer
postInvalidate()
}
textColorPrimaryInverseSubscription = Aesthetic.get()
.textColorPrimaryInverse()
.subscribe { integer -> setBackgroundColor((100 shl 24) or (integer and 0x00ffffff)) }
}
override fun unsubscribe() {
textColorPrimarySubscription?.dispose()
textColorPrimaryInverseSubscription?.dispose()
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
subscribe()
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
unsubscribe()
}
}