Skip to content

Commit 686e73d

Browse files
committed
Capability to pass color and drawables as resourceIds
1 parent ea05d5d commit 686e73d

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

bubbleshowcase/src/main/java/com/elconfidencial/bubbleshowcase/BubbleShowCaseBuilder.kt

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.elconfidencial.bubbleshowcase
22

33
import android.app.Activity
44
import android.graphics.drawable.Drawable
5+
import android.support.v4.content.ContextCompat
56
import android.view.View
67
import android.view.ViewTreeObserver
78
import java.lang.ref.WeakReference
@@ -59,13 +60,22 @@ class BubbleShowCaseBuilder{
5960

6061
/**
6162
* Image drawable to inserted as main image in the BubbleShowCase
62-
* - If this param is not inserted, the BubbleShowCase will not have main image
63+
* - If this param is not passed, the BubbleShowCase will not have main image
6364
*/
6465
fun image(image: Drawable): BubbleShowCaseBuilder {
6566
mImage = image
6667
return this
6768
}
6869

70+
/**
71+
* Image resource id to insert the corresponding drawable as main image in the BubbleShowCase
72+
* - If this param is not passed, the BubbleShowCase will not have main image
73+
*/
74+
fun imageResourceId(resId: Int): BubbleShowCaseBuilder {
75+
mImage = ContextCompat.getDrawable(mActivity!!.get(), resId)
76+
return this
77+
}
78+
6979
/**
7080
* Image drawable to be inserted as close icon in the BubbleShowCase.
7181
* - If this param is not defined, a default close icon is displayed
@@ -75,6 +85,16 @@ class BubbleShowCaseBuilder{
7585
return this
7686
}
7787

88+
/**
89+
* Image resource id to insert the corresponding drawable as close icon in the BubbleShowCase.
90+
* - If this param is not defined, a default close icon is displayed
91+
*/
92+
fun closeActionImageResourceId(resId: Int): BubbleShowCaseBuilder {
93+
mCloseAction = ContextCompat.getDrawable(mActivity!!.get(), resId)
94+
return this
95+
}
96+
97+
7898
/**
7999
* Background color of the BubbleShowCase.
80100
* - #3F51B5 color will be set if this param is not defined
@@ -84,6 +104,15 @@ class BubbleShowCaseBuilder{
84104
return this
85105
}
86106

107+
/**
108+
* Background color of the BubbleShowCase.
109+
* - #3F51B5 color will be set if this param is not defined
110+
*/
111+
fun backgroundColorResourceId(colorResId: Int): BubbleShowCaseBuilder {
112+
mBackgroundColor = ContextCompat.getColor(mActivity!!.get(), colorResId)
113+
return this
114+
}
115+
87116
/**
88117
* Text color of the BubbleShowCase.
89118
* - White color will be set if this param is not defined
@@ -93,6 +122,15 @@ class BubbleShowCaseBuilder{
93122
return this
94123
}
95124

125+
/**
126+
* Text color of the BubbleShowCase.
127+
* - White color will be set if this param is not defined
128+
*/
129+
fun textColorResourceId(colorResId: Int): BubbleShowCaseBuilder {
130+
mTextColor = ContextCompat.getColor(mActivity!!.get(), colorResId)
131+
return this
132+
}
133+
96134
/**
97135
* Title text size in SP.
98136
* - Default value -> 16 sp

0 commit comments

Comments
 (0)