Closed andreazaffanella closed 2 years ago
Hi @andreazaffanella, you should call Utils.INSTANCE.
in the Java code.
Fix for your Java code:
waveform.setWaveWidth(Utils.INSTANCE.dp(this, 10));
@massoudss please mark Utils.dp() as @JvmStatic (in the future version) to prevent the use of INSTANCE in the Java code
Hi Will be done on next release.
I'm trying to use waveformSeekBar for a Java Android project. I already set up the dependencies and included all the classes.
I'm starting off from the example in the README, which is the following:
WaveformSeekBar waveformSeekBar = new WaveformSeekBar(yourContext); waveformSeekBar.setProgress(33); waveformSeekBar.setMaxProgress(100); waveformSeekBar.setWaveWidth(Utils.dp(this,5)); waveformSeekBar.setWaveGap(Utils.dp(this,2)); waveformSeekBar.setWaveMinHeight(Utils.dp(this,5)); waveformSeekBar.setWaveCornerRadius(Utils.dp(this,2)); waveformSeekBar.setWaveGravity(WaveGravity.CENTER); waveformSeekBar.setWaveBackgroundColor(ContextCompat.getColor(this,R.color.white)); waveformSeekBar.setWaveProgressColor(ContextCompat.getColor(this,R.color.blue));
The issue happens when trying to execute
waveformSeekBar.setWaveWidth(Utils.dp(...))
. It throws an error: "non-static method dp(Context,int) cannot be referenced from a static context waveformSeekBar.setWaveWidth(Utils.dp(this,5));" However, it is not possible to create an instance of the class Util either, because there is no available constructor, it says: "Utils() has private access in Utils".I'm not practical with Kotlin. Maybe I'm missing something obvious... What can I do?