This repository was archived by the owner on Sep 22, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +21
-3
lines changed Expand file tree Collapse file tree 7 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ dependencies {
2828 implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version "
2929 implementation " com.android.support:recyclerview-v7:27.1.1"
3030 implementation ' com.android.support:appcompat-v7:27.1.1'
31- implementation ' com.github.alxrm:audiowave-progressbar:0.9.1 '
31+ implementation ' com.github.alxrm:audiowave-progressbar:0.9.2 '
3232
3333 implementation " com.jakewharton:butterknife:8.8.1"
3434 annotationProcessor " com.jakewharton:butterknife-compiler:8.8.1"
3535
36- // compile project(':audiowave')
36+ // implementation project(':audiowave')
3737}
3838repositories {
3939 mavenCentral()
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package rm.com.audiogram
33import android.animation.ObjectAnimator
44import android.content.Intent
55import android.os.Bundle
6+ import android.support.v4.content.ContextCompat
67import android.support.v7.app.AppCompatActivity
78import android.util.Log
89import android.view.animation.LinearInterpolator
@@ -41,6 +42,11 @@ class MainActivity : AppCompatActivity() {
4142
4243 wave.onProgressChanged = { progress, byUser ->
4344 Log .e(" wave" , " Progress set: $progress , and it's $byUser that user did this" )
45+
46+ if (progress == 100F && ! byUser) {
47+ wave.waveColor = ContextCompat .getColor(this , R .color.colorAccent)
48+ wave.isTouchable = true
49+ }
4450 }
4551
4652 wave.onStartTracking = {
Original file line number Diff line number Diff line change 2323 app : chunkRadius =" 1dp"
2424 app : chunkSpacing =" 1dp"
2525 app : chunkWidth =" 3dp"
26+ app : touchable =" true"
2627 app : minChunkHeight =" 2dp"
2728 app : progress =" 0.0"
2829 app : waveColor =" @android:color/black"
Original file line number Diff line number Diff line change 1919 android : layout_margin =" 16dp"
2020 app : chunkHeight =" 24dp"
2121 app : chunkRadius =" 1dp"
22+ app : touchable =" false"
2223 app : chunkSpacing =" 1dp"
2324 app : chunkWidth =" 3dp"
2425 app : minChunkHeight =" 2dp"
Original file line number Diff line number Diff line change 3131 app : animateExpansion =" false"
3232 app : chunkHeight =" 16dp"
3333 app : chunkRadius =" 1dp"
34+ app : touchable =" true"
3435 app : chunkSpacing =" 1dp"
3536 app : chunkWidth =" 3dp"
3637 app : minChunkHeight =" 2dp"
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ class AudioWaveView : View {
7171 set(value) {
7272 wavePaint = smoothPaint(value.withAlpha(0xAA ))
7373 waveFilledPaint = filterPaint(value)
74- postInvalidate ()
74+ redrawData ()
7575 }
7676
7777 var progress: Float = 0F
@@ -105,6 +105,8 @@ class AudioWaveView : View {
105105
106106 var isExpansionAnimated: Boolean = true
107107
108+ var isTouchable = true
109+
108110 var isTouched = false
109111 private set
110112
@@ -175,9 +177,14 @@ class AudioWaveView : View {
175177 }
176178 }
177179
180+ @SuppressLint(" ClickableViewAccessibility" )
178181 override fun onTouchEvent (event : MotionEvent ? ): Boolean {
179182 event ? : return super .onTouchEvent(event)
180183
184+ if (! isTouchable || ! isEnabled) {
185+ return false
186+ }
187+
181188 when (event.action) {
182189 MotionEvent .ACTION_DOWN -> {
183190 isTouched = true
@@ -275,6 +282,7 @@ class AudioWaveView : View {
275282 minChunkHeight = getDimensionPixelSize(R .styleable.AudioWaveView_minChunkHeight ,
276283 minChunkHeight)
277284 chunkRadius = getDimensionPixelSize(R .styleable.AudioWaveView_chunkRadius , chunkRadius)
285+ isTouchable = getBoolean(R .styleable.AudioWaveView_touchable , isTouchable)
278286 waveColor = getColor(R .styleable.AudioWaveView_waveColor , waveColor)
279287 progress = getFloat(R .styleable.AudioWaveView_progress , progress)
280288 isExpansionAnimated = getBoolean(R .styleable.AudioWaveView_animateExpansion ,
Original file line number Diff line number Diff line change 99 <attr format =" dimension" name =" chunkSpacing" />
1010 <attr format =" float" name =" progress" />
1111 <attr format =" boolean" name =" animateExpansion" />
12+ <attr format =" boolean" name =" touchable" />
1213 </declare-styleable >
1314</resources >
You can’t perform that action at this time.
0 commit comments