|
33 | 33 | import android.widget.FrameLayout;
|
34 | 34 | import android.widget.ImageView;
|
35 | 35 | import androidx.annotation.ColorInt;
|
| 36 | +import androidx.annotation.ColorRes; |
| 37 | +import androidx.annotation.DimenRes; |
| 38 | +import androidx.annotation.DrawableRes; |
36 | 39 | import androidx.annotation.FloatRange;
|
| 40 | +import androidx.core.content.ContextCompat; |
| 41 | +import androidx.core.content.res.ResourcesCompat; |
37 | 42 | import com.skydoves.colorpickerview.ActionMode;
|
38 | 43 | import com.skydoves.colorpickerview.ColorPickerView;
|
39 | 44 |
|
40 | 45 | /** AbstractSlider is the abstract class for implementing sliders. */
|
| 46 | +@SuppressWarnings("unused") |
41 | 47 | public abstract class AbstractSlider extends FrameLayout {
|
42 | 48 |
|
43 | 49 | public ColorPickerView colorPickerView;
|
@@ -219,6 +225,68 @@ public void onGlobalLayout() {
|
219 | 225 | });
|
220 | 226 | }
|
221 | 227 |
|
| 228 | + /** |
| 229 | + * sets a drawable of the selector. |
| 230 | + * |
| 231 | + * @param drawable drawable of the selector. |
| 232 | + */ |
| 233 | + public void setSelectorDrawable(Drawable drawable) { |
| 234 | + this.selectorDrawable = drawable; |
| 235 | + this.selector.setImageDrawable(drawable); |
| 236 | + } |
| 237 | + |
| 238 | + /** |
| 239 | + * sets a drawable resource of the selector. |
| 240 | + * |
| 241 | + * @param resource a drawable resource of the selector. |
| 242 | + */ |
| 243 | + public void setSelectorDrawableRes(@DrawableRes int resource) { |
| 244 | + Drawable drawable = ResourcesCompat.getDrawable(getContext().getResources(), resource, null); |
| 245 | + setSelectorDrawable(drawable); |
| 246 | + } |
| 247 | + |
| 248 | + /** |
| 249 | + * sets a color of the slider border. |
| 250 | + * |
| 251 | + * @param color color of the slider border. |
| 252 | + */ |
| 253 | + public void setBorderColor(@ColorInt int color) { |
| 254 | + this.borderColor = color; |
| 255 | + this.borderPaint.setColor(color); |
| 256 | + invalidate(); |
| 257 | + } |
| 258 | + |
| 259 | + /** |
| 260 | + * sets a color resource of the slider border. |
| 261 | + * |
| 262 | + * @param resource color resource of the slider border. |
| 263 | + */ |
| 264 | + public void setBorderColorRes(@ColorRes int resource) { |
| 265 | + int color = ContextCompat.getColor(getContext(), resource); |
| 266 | + setBorderColor(color); |
| 267 | + } |
| 268 | + |
| 269 | + /** |
| 270 | + * sets a size of the slide border. |
| 271 | + * |
| 272 | + * @param borderSize ize of the slide border. |
| 273 | + */ |
| 274 | + public void setBorderSize(int borderSize) { |
| 275 | + this.borderSize = borderSize; |
| 276 | + this.borderPaint.setStrokeWidth(borderSize); |
| 277 | + invalidate(); |
| 278 | + } |
| 279 | + |
| 280 | + /** |
| 281 | + * sets a size of the slide border using dimension resource. |
| 282 | + * |
| 283 | + * @param resource a size of the slide border. |
| 284 | + */ |
| 285 | + public void setBorderSizeRes(@DimenRes int resource) { |
| 286 | + int borderSize = (int) getContext().getResources().getDimension(resource); |
| 287 | + setBorderSize(borderSize); |
| 288 | + } |
| 289 | + |
222 | 290 | /** called when the inflating finished. */
|
223 | 291 | public abstract void onInflateFinished();
|
224 | 292 |
|
|
0 commit comments