Skip to content

Commit e0f96bc

Browse files
committed
Fixed #2 : Handled multi-touch case for SmoothSeekBar
1 parent 0bebc2f commit e0f96bc

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1818
buildscript {
19-
ext.kotlin_version = "1.4.10"
19+
ext.kotlin_version = "1.4.21"
2020
repositories {
2121
google()
2222
jcenter()
2323
}
2424
dependencies {
25-
classpath "com.android.tools.build:gradle:4.1.0"
25+
classpath "com.android.tools.build:gradle:4.1.1"
2626
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2727

2828
// NOTE: Do not place your application dependencies here; they belong

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

widgetslib/build.gradle

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
apply plugin: 'com.android.library'
1818
apply plugin: 'kotlin-android'
1919
apply plugin: 'kotlin-kapt'
20-
apply plugin: 'kotlin-android-extensions'
20+
apply plugin: 'kotlin-parcelize'
2121

2222
android {
2323
compileSdkVersion 30
@@ -34,6 +34,10 @@ android {
3434
main.java.srcDirs += "src/main/kotlin"
3535
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
3636
}
37+
buildFeatures {
38+
viewBinding = true
39+
dataBinding = true
40+
}
3741
compileOptions {
3842
sourceCompatibility = JavaVersion.VERSION_1_8
3943
targetCompatibility = JavaVersion.VERSION_1_8

widgetslib/src/main/kotlin/com/litekite/widget/SmoothSeekBar.kt

+10
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class SmoothSeekBar @JvmOverloads constructor(
3636
) : AppCompatSeekBar(context, attrs, defStyleAttr) {
3737

3838
private var callback: OnSeekBarChangeListener? = null
39+
private var lastPointerId: Int = 0
3940
private var lastProgress = 0
4041

4142
@SuppressLint("ClickableViewAccessibility")
@@ -47,9 +48,18 @@ class SmoothSeekBar @JvmOverloads constructor(
4748
MotionEvent.ACTION_DOWN -> {
4849
lastProgress = calculateProgress(event)
4950
callback?.onStartTrackingTouch(this)
51+
lastPointerId = event.getPointerId(event.actionIndex)
5052
}
5153
MotionEvent.ACTION_MOVE -> {
5254
isPressed = true
55+
// Updates last known progress based on the active pointer id
56+
// in-case of any multi-touch event.
57+
val currentPointerId = event.getPointerId(event.actionIndex)
58+
if (lastPointerId != currentPointerId) {
59+
lastProgress = calculateProgress(event)
60+
lastPointerId = currentPointerId
61+
return true
62+
}
5363
val newProgress = calculateProgress(event)
5464
makeProgress(newProgress)
5565
callback?.onProgressChanged(this, progress, true)

0 commit comments

Comments
 (0)