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
Next Next commit
onCompltion Listener added
  • Loading branch information
MudssirAhmed committed Feb 5, 2023
commit 2dff6309b05c29e4e6e2e7964a5daf7305fc571d
6 changes: 6 additions & 0 deletions app/src/main/java/com/masoudss/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +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.SeekBarOnProgressChanged
import com.masoudss.lib.WaveformSeekBar
import com.masoudss.lib.utils.Utils
Expand Down Expand Up @@ -54,6 +55,11 @@ class MainActivity : AppCompatActivity() {
binding.waveProgress.progress = progress.toInt()
}
}
onCompletionListener = object : CompletionListener {
override fun onComplete() {
Toast.makeText(this@MainActivity, "onComplete", Toast.LENGTH_SHORT).show()
}
}
}

binding.waveWidth.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
Expand Down
5 changes: 5 additions & 0 deletions lib/src/main/java/com/masoudss/lib/CompletionListener.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.masoudss.lib

interface CompletionListener {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to rename this interface to DrawCompletionListener

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

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this call to end of onDraw method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure


if (waveSample.isEmpty())
return

Expand Down