Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onCompltion Listener added #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Completion-Listener name changed
  • Loading branch information
MudssirAhmed committed Feb 6, 2023
commit b7f11f02baac509fa7b816f2bf2f4180a16b4199
8 changes: 4 additions & 4 deletions app/src/main/java/com/masoudss/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.masoudss.R
import com.masoudss.databinding.ActivityMainBinding
import com.masoudss.lib.CompletionListener
import com.masoudss.lib.DrawCompletionListener
import com.masoudss.lib.SeekBarOnProgressChanged
import com.masoudss.lib.WaveformSeekBar
import com.masoudss.lib.utils.Utils
Expand Down Expand Up @@ -55,9 +55,9 @@ class MainActivity : AppCompatActivity() {
binding.waveProgress.progress = progress.toInt()
}
}
onCompletionListener = object : CompletionListener {
override fun onComplete() {
Toast.makeText(this@MainActivity, "onComplete", Toast.LENGTH_SHORT).show()
onCompletionListener = object : DrawCompletionListener {
override fun onDrawComplete() {
Toast.makeText(this@MainActivity, "onDrawComplete", Toast.LENGTH_SHORT).show()
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions lib/src/main/java/com/masoudss/lib/CompletionListener.kt

This file was deleted.

5 changes: 5 additions & 0 deletions lib/src/main/java/com/masoudss/lib/DrawCompletionListener.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.masoudss.lib

interface DrawCompletionListener {
fun onDrawComplete()
}
6 changes: 3 additions & 3 deletions lib/src/main/java/com/masoudss/lib/WaveformSeekBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ open class WaveformSeekBar @JvmOverloads constructor(
private lateinit var progressShader: Shader

var onProgressChanged: SeekBarOnProgressChanged? = null
var onCompletionListener: CompletionListener? = null
var onCompletionListener: DrawCompletionListener? = null

var sample: IntArray? = null
set(value) {
Expand Down Expand Up @@ -249,8 +249,6 @@ open class WaveformSeekBar @JvmOverloads constructor(
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
sample?.let { waveSample ->
onCompletionListener?.onComplete()

if (waveSample.isEmpty())
return

Expand Down Expand Up @@ -370,6 +368,8 @@ open class WaveformSeekBar @JvmOverloads constructor(
canvas.drawText(it.value, markerTextDistance, markerTextXPosition, mMarkerPaint)
canvas.rotate(-90f)
}

onCompletionListener?.onDrawComplete()
}
}

Expand Down