Skip to content

Commit

Permalink
Merge pull request #14 from lincollincol/master
Browse files Browse the repository at this point in the history
FIxed bugs from Issues #10, #11, #12. Reduce library size.
  • Loading branch information
massoudss committed Jan 8, 2021
2 parents a779800 + 91d8776 commit 5e56cd1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ you can customize WaveformSeekBar, all of this attributes can change via xml or
|wave_progress_color|Color|`waveProgressColor`|Reached Waves color, default color is `Color.WHITE`|
| - |IntArray|`sample`|Sample data for drawing waves, default is `null`|

# Reduce size
Add ``` android:extractNativeLibs="false" ``` to application in the Manifest.xml

``` xml
<application
. . .
android:extractNativeLibs="false"
. . . >
<activity . . ./>
</application>
```

# License
```
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
android:label="@string/app_name"
android:supportsRtl="false"
android:theme="@style/AppTheme"
android:extractNativeLibs="false">
android:extractNativeLibs="false"
android:requestLegacyExternalStorage="true">
<activity
android:name=".activity.SelectAudioActivity">
</activity>
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/masoudss/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ class MainActivity : AppCompatActivity() {

var waves: IntArray = intArrayOf()

WaveformOptions.getSampleFrom(path) {
WaveformOptions.init(this@MainActivity)

WaveformOptions.getSampleFrom(path!!) {
waves = it
}

Expand Down
2 changes: 1 addition & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.2.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.github.lincollincol:Amplituda:1.3'
implementation 'com.github.lincollincol:Amplituda:1.4'
}
repositories {
mavenCentral()
Expand Down
14 changes: 11 additions & 3 deletions lib/src/main/java/com/masoudss/lib/WaveformOptions.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
package com.masoudss.lib

import android.content.Context
import linc.com.amplituda.Amplituda
import java.io.File

object WaveformOptions {

private val amplituda by lazy { Amplituda() }
private var amplituda: Amplituda? = null

@JvmStatic
fun init(context: Context) {
if(amplituda == null) {
amplituda = Amplituda(context)
}
}

@JvmStatic
fun getSampleFrom(file: File, onSuccess:(samples: IntArray) -> Unit) {
amplituda.fromFile(file)
amplituda!!.fromFile(file)
.amplitudesAsList {
onSuccess(it.toIntArray())
}
}

@JvmStatic
fun getSampleFrom(path: String, onSuccess: (IntArray) -> Unit) {
amplituda.fromPath(path)
amplituda!!.fromPath(path)
.amplitudesAsList {
onSuccess(it.toIntArray())
}
Expand Down

0 comments on commit 5e56cd1

Please sign in to comment.