@@ -76,6 +76,8 @@ public class SuperSaiyanScrollView extends FrameLayout
76
76
private int mListOffset ;
77
77
private int mOverlayTextColor ;
78
78
private int mOverlayDrawableResId ;
79
+ private Drawable mThumbDrawableResource ;
80
+ private Drawable mThumbPressedDrawableResource ;
79
81
80
82
private Object [] mSections ;
81
83
private String mSectionText ;
@@ -126,6 +128,7 @@ private void useThumbDrawable(Drawable drawable) {
126
128
127
129
private void init (Context context , AttributeSet attrs ) {
128
130
131
+ final Resources res = context .getResources ();
129
132
// set all attributes from xml
130
133
if (attrs != null ) {
131
134
TypedArray typedArray = context .obtainStyledAttributes (attrs ,
@@ -139,9 +142,12 @@ private void init(Context context, AttributeSet attrs) {
139
142
mOverlayTextSize = typedArray .getDimensionPixelSize (
140
143
R .styleable .SuperSaiyanScrollView_ssjn_overlayTextSize ,
141
144
context .getResources ().getDimensionPixelSize (R .dimen .ssjn__overlay_text_size_normal ));
142
- mOverlayTextColor = typedArray .getColor (R .styleable .SuperSaiyanScrollView_ssjn_overlayTextColor ,
145
+ mOverlayTextColor = typedArray .getColor (R .styleable .SuperSaiyanScrollView_ssjn_overlayTextColor ,
143
146
context .getResources ().getColor (R .color .ssjn__emphasis ));
144
147
148
+ mThumbDrawableResource = typedArray .getDrawable (R .styleable .SuperSaiyanScrollView_ssjn_thumbDrawable );
149
+ mThumbPressedDrawableResource = typedArray .getDrawable (R .styleable .SuperSaiyanScrollView_ssjn_thumbPressedDrawable );
150
+
145
151
int overlayTheme = typedArray .getInt (R .styleable .SuperSaiyanScrollView_ssjn_overlayTheme , 1 );
146
152
147
153
if (overlayTheme == 0 ) {
@@ -170,19 +176,22 @@ private void init(Context context, AttributeSet attrs) {
170
176
mOverlayTextColor = context .getResources ().getColor (R .color .ssjn__emphasis );
171
177
mOverlayDrawableResId = R .drawable .popup_full_bright ;
172
178
}
179
+ if (mThumbDrawableResource == null )
180
+ mThumbDrawableResource = res .getDrawable (THUMB_DRAWABLE );
181
+ if (mThumbPressedDrawableResource == null )
182
+ mThumbPressedDrawableResource = res .getDrawable (THUMB_DRAWABLE_PRESSED );
173
183
174
184
log .d ("Initialized with mOverlayHeight: %s, mOverlayWidth: %s, mOverlayTextSize: %s, mOverlayTextColor: %s" ,
175
185
mOverlayHeight , mOverlayWidth , mOverlayTextSize , mOverlayTextColor );
176
186
177
187
// Get both the scrollbar states drawables
178
- final Resources res = context .getResources ();
179
188
StateListDrawable thumbDrawable = new StateListDrawable ();
180
189
//This for pressed true
181
190
thumbDrawable .addState (STATE_PRESSED ,
182
- res .getDrawable (THUMB_DRAWABLE_PRESSED ));
191
+ res .getDrawable (mThumbPressedDrawableResource ));
183
192
//This for pressed false
184
193
thumbDrawable .addState (STATE_UNPRESSED ,
185
- res . getDrawable ( THUMB_DRAWABLE ) );
194
+ mThumbDrawableResource );
186
195
useThumbDrawable (thumbDrawable );
187
196
188
197
mOverlayDrawable = res .getDrawable (mOverlayDrawableResId );
0 commit comments