Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Slow and excess load on the UI thread #19

Closed
abbasnaqdi opened this issue Oct 10, 2018 · 2 comments
Closed

Slow and excess load on the UI thread #19

abbasnaqdi opened this issue Oct 10, 2018 · 2 comments

Comments

@abbasnaqdi
Copy link

Hello . I used WaveView inside the RecyclerView and found it to be extremely slow and adds extra load on the UI thread.

Please fix this problem. Thank .

setData :

   if (itemView.wave_voice.scaledData.isEmpty()) {
            Observable.fromCallable { fileHelper.getFileByte(voice.file) }
                    .newThread()
                    .subscribe {
                        itemView.wave_voice.scaledData = it
                        itemView.wave_voice.setRawData(it)
                    }
        }

func :

 fun getFileByte(filename: String): ByteArray {
        val file = getFilePath(filename)
        return if (file.exists())
            file.readBytes()
        else byteArrayOf(0)
    }
@alxrm
Copy link
Owner

alxrm commented Oct 10, 2018

You're doing it wrong, take a closer look to the readme and l check out sample app

In short, you have to turn off the the expansion animation of the wave(it's in the readme).

And also consider not reading the whole file every time you bind your item, it also produces ridiculously high amount of redundant work, to avoid it, you can store a collection of scaled byte arrays(using Sampler.downSampleAsync or Sampler.downSample which fits perfectly in your Rx pipeline BTW) and bind them synchronously, which is way more efficient

@alxrm alxrm closed this as completed Oct 10, 2018
@alxrm
Copy link
Owner

alxrm commented Oct 10, 2018

You might as well consider using another library, since this one produces waves that are not very accurate

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants