120 |
121 |
122 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/java,macos,gradle,kotlin,android,jetbrains,androidstudio
3 | # Edit at https://www.gitignore.io/?templates=java,macos,gradle,kotlin,android,jetbrains,androidstudio
4 |
5 | ### Android ###
6 | # Built application files
7 | *.apk
8 | *.ap_
9 | *.aab
10 |
11 | # Files for the ART/Dalvik VM
12 | *.dex
13 |
14 | # Java class files
15 | *.class
16 |
17 | # Generated files
18 | bin/
19 | gen/
20 | out/
21 | release/
22 |
23 | # Gradle files
24 | .gradle/
25 | build/
26 |
27 | # Local configuration file (sdk path, etc)
28 | local.properties
29 |
30 | # Proguard folder generated by Eclipse
31 | proguard/
32 |
33 | # Log Files
34 | *.log
35 |
36 | # Android Studio Navigation editor temp files
37 | .navigation/
38 |
39 | # Android Studio captures folder
40 | captures/
41 |
42 | # IntelliJ
43 | *.iml
44 | .idea/workspace.xml
45 | .idea/tasks.xml
46 | .idea/gradle.xml
47 | .idea/assetWizardSettings.xml
48 | .idea/dictionaries
49 | .idea/libraries
50 | # Android Studio 3 in .gitignore file.
51 | .idea/caches
52 | .idea/modules.xml
53 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you
54 | .idea/navEditor.xml
55 |
56 | # Keystore files
57 | # Uncomment the following lines if you do not want to check your keystore files in.
58 | #*.jks
59 | #*.keystore
60 |
61 | # External native build folder generated in Android Studio 2.2 and later
62 | .externalNativeBuild
63 |
64 | # Google Services (e.g. APIs or Firebase)
65 | # google-services.json
66 |
67 | # Freeline
68 | freeline.py
69 | freeline/
70 | freeline_project_description.json
71 |
72 | # fastlane
73 | fastlane/report.xml
74 | fastlane/Preview.html
75 | fastlane/screenshots
76 | fastlane/test_output
77 | fastlane/readme.md
78 |
79 | # Version control
80 | vcs.xml
81 |
82 | # lint
83 | lint/intermediates/
84 | lint/generated/
85 | lint/outputs/
86 | lint/tmp/
87 | # lint/reports/
88 |
89 | ### Android Patch ###
90 | gen-external-apklibs
91 | output.json
92 |
93 | # Replacement of .externalNativeBuild directories introduced
94 | # with Android Studio 3.5.
95 | .cxx/
96 |
97 | ### Java ###
98 | # Compiled class file
99 |
100 | # Log file
101 |
102 | # BlueJ files
103 | *.ctxt
104 |
105 | # Mobile Tools for Java (J2ME)
106 | .mtj.tmp/
107 |
108 | # Package Files #
109 | *.jar
110 | *.war
111 | *.nar
112 | *.ear
113 | *.zip
114 | *.tar.gz
115 | *.rar
116 |
117 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
118 | hs_err_pid*
119 |
120 | ### JetBrains ###
121 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
122 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
123 |
124 | # User-specific stuff
125 | .idea/**/workspace.xml
126 | .idea/**/tasks.xml
127 | .idea/**/usage.statistics.xml
128 | .idea/**/dictionaries
129 | .idea/**/shelf
130 |
131 | # Generated files
132 | .idea/**/contentModel.xml
133 |
134 | # Sensitive or high-churn files
135 | .idea/**/dataSources/
136 | .idea/**/dataSources.ids
137 | .idea/**/dataSources.local.xml
138 | .idea/**/sqlDataSources.xml
139 | .idea/**/dynamic.xml
140 | .idea/**/uiDesigner.xml
141 | .idea/**/dbnavigator.xml
142 |
143 | # Gradle
144 | .idea/**/gradle.xml
145 | .idea/**/libraries
146 |
147 | # Gradle and Maven with auto-import
148 | # When using Gradle or Maven with auto-import, you should exclude module files,
149 | # since they will be recreated, and may cause churn. Uncomment if using
150 | # auto-import.
151 | # .idea/modules.xml
152 | # .idea/*.iml
153 | # .idea/modules
154 | # *.iml
155 | # *.ipr
156 |
157 | # CMake
158 | cmake-build-*/
159 |
160 | # Mongo Explorer plugin
161 | .idea/**/mongoSettings.xml
162 |
163 | # File-based project format
164 | *.iws
165 |
166 | # IntelliJ
167 |
168 | # mpeltonen/sbt-idea plugin
169 | .idea_modules/
170 |
171 | # JIRA plugin
172 | atlassian-ide-plugin.xml
173 |
174 | # Cursive Clojure plugin
175 | .idea/replstate.xml
176 |
177 | # Crashlytics plugin (for Android Studio and IntelliJ)
178 | com_crashlytics_export_strings.xml
179 | crashlytics.properties
180 | crashlytics-build.properties
181 | fabric.properties
182 |
183 | # Editor-based Rest Client
184 | .idea/httpRequests
185 |
186 | # Android studio 3.1+ serialized cache file
187 | .idea/caches/build_file_checksums.ser
188 |
189 | ### JetBrains Patch ###
190 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
191 |
192 | # *.iml
193 | # modules.xml
194 | # .idea/misc.xml
195 | # *.ipr
196 |
197 | # Sonarlint plugin
198 | .idea/**/sonarlint/
199 |
200 | # SonarQube Plugin
201 | .idea/**/sonarIssues.xml
202 |
203 | # Markdown Navigator plugin
204 | .idea/**/markdown-navigator.xml
205 | .idea/**/markdown-navigator/
206 |
207 | ### Kotlin ###
208 | # Compiled class file
209 |
210 | # Log file
211 |
212 | # BlueJ files
213 |
214 | # Mobile Tools for Java (J2ME)
215 |
216 | # Package Files #
217 |
218 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
219 |
220 | ### macOS ###
221 | # General
222 | .DS_Store
223 | .AppleDouble
224 | .LSOverride
225 |
226 | # Icon must end with two \r
227 | Icon
228 |
229 | # Thumbnails
230 | ._*
231 |
232 | # Files that might appear in the root of a volume
233 | .DocumentRevisions-V100
234 | .fseventsd
235 | .Spotlight-V100
236 | .TemporaryItems
237 | .Trashes
238 | .VolumeIcon.icns
239 | .com.apple.timemachine.donotpresent
240 |
241 | # Directories potentially created on remote AFP share
242 | .AppleDB
243 | .AppleDesktop
244 | Network Trash Folder
245 | Temporary Items
246 | .apdisk
247 |
248 | ### Gradle ###
249 | .gradle
250 |
251 | # Ignore Gradle GUI config
252 | gradle-app.setting
253 |
254 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
255 | !gradle-wrapper.jar
256 |
257 | # Cache of project
258 | .gradletasknamecache
259 |
260 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
261 | # gradle/wrapper/gradle-wrapper.properties
262 |
263 | ### Gradle Patch ###
264 | **/build/
265 |
266 | ### AndroidStudio ###
267 | # Covers files to be ignored for android development using Android Studio.
268 |
269 | # Built application files
270 |
271 | # Files for the ART/Dalvik VM
272 |
273 | # Java class files
274 |
275 | # Generated files
276 |
277 | # Gradle files
278 |
279 | # Signing files
280 | .signing/
281 |
282 | # Local configuration file (sdk path, etc)
283 |
284 | # Proguard folder generated by Eclipse
285 |
286 | # Log Files
287 |
288 | # Android Studio
289 | /*/build/
290 | /*/local.properties
291 | /*/out
292 | /*/*/build
293 | /*/*/production
294 | *.ipr
295 | *~
296 | *.swp
297 |
298 | # Android Patch
299 |
300 | # External native build folder generated in Android Studio 2.2 and later
301 |
302 | # NDK
303 | obj/
304 |
305 | # IntelliJ IDEA
306 | /out/
307 |
308 | # User-specific configurations
309 | .idea/caches/
310 | .idea/libraries/
311 | .idea/shelf/
312 | .idea/.name
313 | .idea/compiler.xml
314 | .idea/copyright/profiles_settings.xml
315 | .idea/encodings.xml
316 | .idea/misc.xml
317 | .idea/scopes/scope_settings.xml
318 | .idea/vcs.xml
319 | .idea/jsLibraryMappings.xml
320 | .idea/datasources.xml
321 | .idea/dataSources.ids
322 | .idea/sqlDataSources.xml
323 | .idea/dynamic.xml
324 | .idea/uiDesigner.xml
325 |
326 | # OS-specific files
327 | .DS_Store?
328 | ehthumbs.db
329 | Thumbs.db
330 |
331 | # Legacy Eclipse project files
332 | .classpath
333 | .project
334 | .cproject
335 | .settings/
336 |
337 | # Mobile Tools for Java (J2ME)
338 |
339 | # Package Files #
340 |
341 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
342 |
343 | ## Plugin-specific files:
344 |
345 | # mpeltonen/sbt-idea plugin
346 |
347 | # JIRA plugin
348 |
349 | # Mongo Explorer plugin
350 | .idea/mongoSettings.xml
351 |
352 | # Crashlytics plugin (for Android Studio and IntelliJ)
353 |
354 | ### AndroidStudio Patch ###
355 |
356 | !/gradle/wrapper/gradle-wrapper.jar
357 |
358 | # End of https://www.gitignore.io/api/java,macos,gradle,kotlin,android,jetbrains,androidstudio
359 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
DividerSeekBar
2 |
3 |
📐 customizable seekbar with separator.
4 |
5 |
6 |
7 |
8 |
9 | ## 🚀 how to include to your project?
10 |
11 |    [](https://jitpack.io/#hongbeomi/DividerSeekBar)
12 |
13 | ### Gradle
14 |
15 | Add it in your **root** build.gradle at the end of repositories:
16 |
17 | ```groovy
18 | allprojects {
19 | repositories {
20 | ...
21 | maven { url 'https://jitpack.io' }
22 | }
23 | }
24 | ```
25 |
26 | And add a this code to your **module**'s `build.gradle` file.
27 |
28 | ```groovy
29 | dependencies {
30 | implementation 'com.github.hongbeomi:DividerSeekBar:v1.0.3'
31 | }
32 | ```
33 |
34 |
35 |
36 | ## 👀 Usage
37 |
38 | ### Basic Example for Kotlin
39 |
40 | ```kotlin
41 | val dividerSeekBar = DividerSeekBar(this).apply {
42 | max = 100
43 | setTextLocationMode(DividerSeekBar.TEXT_LOCATION_BOTTOM)
44 | setTextInterval(10)
45 | setTextColor(R.color.black)
46 | setTextSize(R.dimen.sp_12)
47 | setSeaLineColor(R.color.light_blue_600)
48 | setSeaLineStrokeWidth(R.dimen.dp_1)
49 | setDividerInterval(10)
50 | setDividerColor(R.color.light_blue_600)
51 | setDividerStrokeWidth(R.dimen.dp_1)
52 | setThumbDefaultDrawable(R.drawable.bg_thumb_default)
53 | setThumbActivatedDrawable(R.drawable.bg_thumb_activated)
54 | setActiveMode(DividerSeekBar.ACTIVE_MODE_TARGET)
55 | setActivateTargetValue(3)
56 | setOnDividerSeekBarChangeStateListener(
57 | object : DividerSeekBar.OnDividerSeekBarChangeStateListener {
58 | override fun onProgressEnabled(dividerSeekBar: DividerSeekBar, progress: Int) {
59 | // do something
60 | }
61 | override fun onProgressDisabled(dividerSeekBar: DividerSeekBar, progress: Int) {
62 | // do something
63 | }
64 | })
65 | }
66 | ```
67 |
68 |
69 |
70 | ### Text Location, Interval
71 |
72 | We can set text location mode and interval. Default interval value is 1
73 |
74 | ```kotlin
75 | dividerSeekBar.setTextLocationMode(DividerSeekBar.TEXT_LOCATION_BOTTOM) // set text location
76 | dividerSeekBar.setTextInterval(10) // set text interval of divider
77 | ```
78 |
79 |
80 |
81 | | Location: BOTTOM TEXT_LOCATION_BOTTOM | Location: TOP TEXT_LOCATION_TOP |
82 | | :----------------------------------------------------------: | :----------------------------------------------------------: |
83 | | | |
84 |
85 |
86 |
87 | ### SeaLine Color, Stroke Width
88 |
89 | We can change SeaLine color and stroke width
90 |
91 | ```kotlin
92 | dividerSeekBar.setSeaLineColor(R.color.light_blue_600) // set color light_blue_600
93 | dividerSeekBar.setSeaLineStrokeWidth(R.dimen.dp_1) // set width 1dp
94 | ```
95 |
96 |
97 |
98 | ### Divider Color, Stroke Width, Interval
99 |
100 | We can change the color and stroke width, interval of the divider. default divider interval value is 1
101 |
102 | ```kotlin
103 | dividerSeekBar.setDividerInterval(10) // set divider interval 10
104 | dividerSeekBar.setDividerColor(R.color.light_blue_600) // set color light_blue_600
105 | dividerSeekBar.setDividerStrokeWidth(R.dimen.dp_1) // set width 1dp
106 | ```
107 |
108 |
109 |
110 | ### Thumb Drawable
111 |
112 | We can change Thumb when Activated and when Default (Not Activated).
113 |
114 | ```kotlin
115 | dividerSeekBar.setThumbDefaultDrawable(R.drawable.bg_thumb_default) // set default thumb
116 | dividerSeekBar.setThumbActivatedDrawable(R.drawable.bg_thumb_activated) // set activated thumb
117 | ```
118 |
119 |
120 |
121 | ### Activated Mode & Target Value
122 |
123 | We can set activated mode, target value. default mode is ACTIVE_MODE_MINIMUM, default target value is 0
124 |
125 | ```kotlin
126 | dividerSeekBar.setActiveMode(DividerSeekBar.ACTIVE_MODE_TARGET) // set target mode
127 | dividerSeekBar.setActivateTargetValue(3) // set target value
128 | ```
129 |
130 | | Mode : ACTIVE_MODE_TARGET TargetValue : 3 | Mode : ACTIVE_MODE_MINIMUM TargetValue : 3 | Mode : ACTIVE_MODE_MAXIMUM TargetValue : 3 |
131 | | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
132 | | | | |
133 |
134 |
135 |
136 | ### onProgressEnabled, onProgressDisabled
137 |
138 | We can hear DividerSeekBar when it is active and when it is not active, and we can listen it using the listener.
139 |
140 | ```kotlin
141 | dividerSeekBar.setOnDividerSeekBarChangeStateListener(
142 | object : DividerSeekBar.OnDividerSeekBarChangeStateListener {
143 | override fun onProgressEnabled(dividerSeekBar: DividerSeekBar, progress: Int) {
144 | // do something
145 | }
146 | override fun onProgressDisabled(dividerSeekBar: DividerSeekBar, progress: Int) {
147 | // do something
148 | }
149 | }
150 | )
151 | ```
152 |
153 |
154 |
155 | ### Activate Mode Switch
156 |
157 | We can Activate mode turn it on and off. default is on status
158 |
159 | ```kotlin
160 | dividerSeekBar.setOffActivatedEvent() // set off
161 | dividerSeekBar.setOnActivatedEvent() // set on
162 | ```
163 |
164 |
165 |
166 | ### XML Attribute
167 |
168 | We can set all value in xml
169 |
170 | ```xml
171 |
188 |
189 | ```
190 |
191 |
192 |
193 | ## 🌟 Find this project useful?
194 |
195 | Support it by joining [stargazers](https://github.com/hongbeomi/DividerSeekBar/stargazers) for this repository
196 |
197 |
198 |
199 | ## 📝 License
200 |
201 | ```
202 | Copyright 2020 Hongbeom Ahn
203 |
204 | Licensed under the Apache License, Version 2.0 (the "License");
205 | you may not use this file except in compliance with the License.
206 | You may obtain a copy of the License at
207 |
208 | http://www.apache.org/licenses/LICENSE-2.0
209 |
210 | Unless required by applicable law or agreed to in writing, software
211 | distributed under the License is distributed on an "AS IS" BASIS,
212 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
213 | See the License for the specific language governing permissions and
214 | limitations under the License.
215 | ```
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/DividerSeekBar/src/main/java/github/hongbeomi/dividerseekbar/DividerSeekBar.kt:
--------------------------------------------------------------------------------
1 | package github.hongbeomi.dividerseekbar
2 |
3 | import android.content.Context
4 | import android.content.res.TypedArray
5 | import android.graphics.Canvas
6 | import android.graphics.Paint
7 | import android.graphics.Rect
8 | import android.graphics.drawable.Drawable
9 | import android.util.AttributeSet
10 | import android.widget.SeekBar
11 | import androidx.annotation.*
12 |
13 | class DividerSeekBar
14 | @JvmOverloads constructor(
15 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
16 | ) : androidx.appcompat.widget.AppCompatSeekBar(context, attrs, defStyleAttr) {
17 |
18 | private val mMinHeight = resources.getDimensionPixelSize(R.dimen.dp_48)
19 | private val mMinWidth = resources.getDimensionPixelSize(R.dimen.dp_16)
20 | private var mWidth: Int? = null
21 | private var mHeight: Int? = null
22 |
23 | companion object {
24 |
25 | @IntDef(ACTIVE_MODE_TARGET, ACTIVE_MODE_MINIMUM, ACTIVE_MODE_MAXIMUM)
26 | @Retention(AnnotationRetention.SOURCE)
27 | annotation class ActiveMode
28 |
29 | const val ACTIVE_MODE_TARGET = 0
30 | const val ACTIVE_MODE_MINIMUM = 1
31 | const val ACTIVE_MODE_MAXIMUM = 2
32 |
33 | @IntDef(TEXT_LOCATION_TOP, TEXT_LOCATION_BOTTOM)
34 | @Retention(AnnotationRetention.SOURCE)
35 | annotation class TextLocation
36 |
37 | const val TEXT_LOCATION_BOTTOM = 0
38 | const val TEXT_LOCATION_TOP = 1
39 |
40 | }
41 |
42 | private var mTextPaint: Paint? = null
43 | private var mTextRect: Rect? = null
44 | private var mTextLocationMode = TEXT_LOCATION_BOTTOM
45 | private var mTextInterval: Int = 1
46 | set(value) {
47 | if (value == 0) {
48 | throw IntervalZeroException()
49 | } else {
50 | field = value
51 | }
52 | }
53 | @ColorInt
54 | private var mTextColor: Int = resources.getColor(R.color.gray_400)
55 | private var mTextSize: Float = resources.getDimension(R.dimen.sp_12)
56 |
57 | private var mSeaLinePaint: Paint? = null
58 | @ColorInt
59 | private var mSeaLineColor: Int = resources.getColor(R.color.gray_400)
60 | private var mSeaLineStokeWidth: Float = resources.getDimension(R.dimen.dp_2)
61 |
62 | private var mDividerPaint: Paint? = null
63 | private var mDividerInterval: Int = 1
64 | set(value) {
65 | if (value == 0) {
66 | throw IntervalZeroException()
67 | } else {
68 | field = value
69 | }
70 | }
71 | @ColorInt
72 | private var mDividerColor: Int = resources.getColor(R.color.gray_400)
73 | private var mDividerStrokeWidth: Float = resources.getDimension(R.dimen.dp_2)
74 | private var mThumbDefaultDrawable: Drawable =
75 | resources.getDrawable(R.drawable.bg_thumb_default)
76 | private var mThumbActivatedDrawable: Drawable =
77 | resources.getDrawable(R.drawable.bg_thumb_activated)
78 |
79 | private var mActiveMode = ACTIVE_MODE_MINIMUM
80 | private var mActivateTargetValue: Int = 0
81 | private var mActivatedEventSwitch: Boolean = true
82 | private var mIsActivated: Boolean = false
83 | set(value) {
84 | if (mActivatedEventSwitch) {
85 | field = value
86 | thumb = if (value) {
87 | mOnDividerSeekBarChangeStateListener?.onProgressEnabled(this, progress)
88 | mThumbDefaultDrawable
89 | } else {
90 | mOnDividerSeekBarChangeStateListener?.onProgressDisabled(this, progress)
91 | mThumbActivatedDrawable
92 | }
93 | invalidate()
94 | }
95 | }
96 |
97 | private var mOnDividerSeekBarChangeStateListener: OnDividerSeekBarChangeStateListener? = null
98 |
99 | init {
100 | setPadding(
101 | resources.getDimensionPixelSize(R.dimen.dp_16),
102 | 0,
103 | resources.getDimensionPixelSize(R.dimen.dp_16),
104 | 0
105 | )
106 | val typedArray = context.obtainStyledAttributes(attrs, R.styleable.DividerSeekBar)
107 | try {
108 | setTypeArray(typedArray)
109 | } finally {
110 | typedArray.recycle()
111 | }
112 | mIsActivated = getIsActivatedByActiveMode(progress)
113 | backgroundTintList = null
114 | background = null
115 | progressDrawable = null
116 | setOnDividerSeekBarChangeListener()
117 | }
118 |
119 | override fun setProgress(progress: Int) {
120 | super.setProgress(progress)
121 | mIsActivated = getIsActivatedByActiveMode(progress)
122 | }
123 |
124 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
125 | val widthMode = MeasureSpec.getMode(widthMeasureSpec)
126 | val widthSize = MeasureSpec.getSize(widthMeasureSpec)
127 | val heightMode = MeasureSpec.getMode(heightMeasureSpec)
128 | val heightSize = MeasureSpec.getSize(heightMeasureSpec)
129 | mHeight = when (heightMode) {
130 | MeasureSpec.EXACTLY -> heightSize
131 | MeasureSpec.AT_MOST -> mMinHeight.coerceAtMost(heightSize)
132 | else -> mMinHeight
133 | }
134 | mWidth = when (widthMode) {
135 | MeasureSpec.EXACTLY -> widthSize
136 | MeasureSpec.AT_MOST -> mMinWidth.coerceAtMost(widthSize)
137 | else -> mMinWidth
138 | }
139 | super.onMeasure(widthMeasureSpec, heightMeasureSpec)
140 | setMeasuredDimension(mWidth ?: mMinWidth, mHeight ?: mMinHeight)
141 | }
142 |
143 | override fun onDraw(canvas: Canvas) {
144 | setSeaLinePaint()
145 | setDividerPaint()
146 | setTextPaint()
147 | val halfHeight = height / 2
148 | var position: Float
149 | val div = (width - paddingRight - paddingLeft) / max.toFloat()
150 | for (index in 0..max) {
151 | if (index % mDividerInterval == 0) {
152 | position = ((div * index).toInt() + paddingLeft).toFloat()
153 | setDrawText(canvas, index, position)
154 | mDividerPaint?.let {
155 | canvas.drawLine(
156 | position,
157 | halfHeight / 4.0f * 3.0f,
158 | position,
159 | halfHeight / 4.0f * 5.0f,
160 | it
161 | )
162 | }
163 | }
164 | }
165 | mSeaLinePaint?.let {
166 | canvas.drawLine(
167 | paddingLeft.toFloat(),
168 | halfHeight.toFloat(),
169 | (width - paddingRight).toFloat(),
170 | halfHeight.toFloat(),
171 | it
172 | )
173 | }
174 | super.onDraw(canvas)
175 | }
176 |
177 | private fun setTypeArray(a: TypedArray) {
178 | a.apply {
179 | mActivatedEventSwitch = getBoolean(
180 | R.styleable.DividerSeekBar_dividerSetActivatedEvent,
181 | mActivatedEventSwitch
182 | )
183 | mActivateTargetValue =
184 | getInt(
185 | R.styleable.DividerSeekBar_dividerActivatedTargetValue,
186 | mActivateTargetValue
187 | )
188 | mActiveMode = getInt(R.styleable.DividerSeekBar_dividerActiveMode, mActiveMode)
189 |
190 | mTextLocationMode = getInt(R.styleable.DividerSeekBar_dividerTextLocationMode, mTextLocationMode)
191 | mTextInterval = getInt(R.styleable.DividerSeekBar_dividerTextInterval, mTextInterval)
192 |
193 | mTextSize = getDimension(
194 | R.styleable.DividerSeekBar_dividerTextSize,
195 | mTextSize
196 | )
197 | mTextColor = getColor(
198 | R.styleable.DividerSeekBar_dividerTextColor,
199 | mTextColor
200 | )
201 |
202 | mDividerColor = getColor(
203 | R.styleable.DividerSeekBar_dividerColor,
204 | mDividerColor
205 | )
206 | mDividerStrokeWidth = getDimension(
207 | R.styleable.DividerSeekBar_dividerStrokeWidth,
208 | mDividerStrokeWidth
209 | )
210 |
211 | mSeaLineColor = getColor(
212 | R.styleable.DividerSeekBar_dividerSeaLineColor,
213 | mSeaLineColor
214 | )
215 | mSeaLineStokeWidth = getDimension(
216 | R.styleable.DividerSeekBar_dividerSeaLineStrokeWidth,
217 | mSeaLineStokeWidth
218 | )
219 |
220 | mThumbDefaultDrawable =
221 | getDrawable(R.styleable.DividerSeekBar_dividerThumbDefaultDrawable)
222 | ?: mThumbDefaultDrawable
223 | mThumbActivatedDrawable =
224 | getDrawable(R.styleable.DividerSeekBar_dividerThumbActivatedDrawable)
225 | ?: mThumbActivatedDrawable
226 | }
227 | }
228 |
229 | private fun setOnDividerSeekBarChangeListener() {
230 | setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
231 | override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
232 | if (fromUser) {
233 | mIsActivated = getIsActivatedByActiveMode(progress)
234 | }
235 | }
236 | override fun onStartTrackingTouch(seekBar: SeekBar?) {}
237 | override fun onStopTrackingTouch(seekBar: SeekBar?) {}
238 | })
239 | }
240 |
241 | private fun initIsActivated() {
242 | mIsActivated = false
243 | }
244 |
245 | /**
246 | * set paint
247 | */
248 | private fun setSeaLinePaint() {
249 | mSeaLinePaint = Paint().apply {
250 | style = Paint.Style.FILL_AND_STROKE
251 | color = mSeaLineColor
252 | strokeWidth = mSeaLineStokeWidth
253 | }
254 | }
255 |
256 | private fun setDividerPaint() {
257 | mDividerPaint = Paint().apply {
258 | style = Paint.Style.FILL_AND_STROKE
259 | color = mDividerColor
260 | strokeWidth = mDividerStrokeWidth
261 | }
262 | }
263 |
264 | private fun setTextPaint() {
265 | mTextRect = Rect()
266 | mTextPaint = Paint().apply {
267 | color = mTextColor
268 | textSize = mTextSize
269 | isAntiAlias = true
270 | }
271 | }
272 |
273 | private fun setDrawText(canvas: Canvas, index: Int, position: Float) {
274 | if (index % mTextInterval == 0) {
275 | val stringIndex = index.toString()
276 | mTextPaint?.apply {
277 | textAlign = Paint.Align.CENTER
278 | getTextBounds(stringIndex, 0, stringIndex.length, mTextRect)
279 | }
280 | mTextPaint?.let {
281 | canvas.drawText(
282 | stringIndex,
283 | position,
284 | getTextLocationY(mTextLocationMode),
285 | it
286 | )
287 | }
288 | }
289 | }
290 |
291 | private fun getTextLocationY(@TextLocation mode: Int): Float {
292 | return when(mode) {
293 | TEXT_LOCATION_BOTTOM -> height.toFloat() - resources.getDimension(R.dimen.dp_1)
294 | TEXT_LOCATION_TOP -> height.toFloat() - (height / 5 * 4).toFloat()
295 | // when other integer, set text location bottom mode
296 | else -> height.toFloat() - resources.getDimension(R.dimen.dp_1)
297 | }
298 | }
299 |
300 | private fun getIsActivatedByActiveMode(progress: Int): Boolean {
301 | return when(mActiveMode) {
302 | ACTIVE_MODE_TARGET -> progress == mActivateTargetValue
303 | ACTIVE_MODE_MAXIMUM -> progress <= mActivateTargetValue
304 | else -> progress >= mActivateTargetValue
305 | }
306 | }
307 |
308 | /**
309 | * text setting
310 | */
311 | fun setTextLocationMode(@TextLocation mode: Int) {
312 | mTextLocationMode = mode
313 | invalidate()
314 | }
315 |
316 | fun setTextInterval(interval: Int) {
317 | mTextInterval = interval
318 | invalidate()
319 | }
320 |
321 | fun setTextColor(@ColorRes textColorId: Int) {
322 | mTextColor = resources.getColor(textColorId)
323 | invalidate()
324 | }
325 |
326 | fun setTextSize(@DimenRes textSizeId: Int) {
327 | mTextSize = resources.getDimension(textSizeId)
328 | }
329 |
330 | fun setTextSize(textSize: Float) {
331 | mTextSize = textSize
332 | }
333 |
334 | /**
335 | * seaLine setting
336 | */
337 | fun setSeaLineColor(@ColorRes seaLineColorId: Int) {
338 | mSeaLineColor = resources.getColor(seaLineColorId)
339 | invalidate()
340 | }
341 |
342 | fun setSeaLineStrokeWidth(@DimenRes seaLineStrokeWidthId: Int) {
343 | mSeaLineStokeWidth = resources.getDimension(seaLineStrokeWidthId)
344 | }
345 |
346 | fun setSeaLineStrokeWidth(seaLineStrokeWidth: Float) {
347 | mSeaLineStokeWidth = seaLineStrokeWidth
348 | }
349 |
350 | /**
351 | * divider setting
352 | */
353 |
354 | fun setDividerInterval(interval: Int) {
355 | mDividerInterval = interval
356 | invalidate()
357 | }
358 |
359 | fun setDividerColor(@ColorRes dividerColorId: Int) {
360 | mDividerColor = resources.getColor(dividerColorId)
361 | invalidate()
362 | }
363 |
364 | fun setDividerStrokeWidth(@DimenRes dividerStrokeWidthId: Int) {
365 | mDividerStrokeWidth = resources.getDimension(dividerStrokeWidthId)
366 | invalidate()
367 | }
368 |
369 | fun setDividerStrokeWidth(dividerStrokeWidth: Float) {
370 | mDividerStrokeWidth = dividerStrokeWidth
371 | invalidate()
372 | }
373 |
374 | /**
375 | * thumb setting
376 | */
377 | fun setThumbDefaultDrawable(@DrawableRes thumbDefaultDrawableId: Int) {
378 | mThumbDefaultDrawable = resources.getDrawable(thumbDefaultDrawableId)
379 | initIsActivated()
380 | }
381 |
382 | fun setThumbDefaultDrawable(thumbDefaultDrawable: Drawable) {
383 | mThumbDefaultDrawable = thumbDefaultDrawable
384 | }
385 |
386 | fun setThumbActivatedDrawable(@DrawableRes thumbActivatedDrawableId: Int) {
387 | mThumbActivatedDrawable = resources.getDrawable(thumbActivatedDrawableId)
388 | initIsActivated()
389 | }
390 |
391 | fun setThumbActivatedDrawable(thumbActivatedDrawable: Drawable) {
392 | mThumbActivatedDrawable = thumbActivatedDrawable
393 | }
394 |
395 | /**
396 | * set active target & mode
397 | */
398 | fun setActivateTargetValue(targetValue: Int) {
399 | mActivateTargetValue = targetValue
400 | }
401 |
402 | fun setActiveMode(@ActiveMode mode: Int) {
403 | mActiveMode = mode
404 | }
405 |
406 | fun setOffActivatedEvent() {
407 | mActivatedEventSwitch = false
408 | }
409 |
410 | fun setOnActivatedEvent() {
411 | mActivatedEventSwitch = true
412 | }
413 |
414 | interface OnDividerSeekBarChangeStateListener {
415 |
416 | fun onProgressEnabled(dividerSeekBar: DividerSeekBar, progress: Int)
417 |
418 | fun onProgressDisabled(dividerSeekBar: DividerSeekBar, progress: Int)
419 |
420 | }
421 |
422 | fun setOnDividerSeekBarChangeStateListener(listener: OnDividerSeekBarChangeStateListener) {
423 | mOnDividerSeekBarChangeStateListener = listener
424 | }
425 |
426 | }
427 |
--------------------------------------------------------------------------------