Skip to content

Commit

Permalink
add callback on worker thread
Browse files Browse the repository at this point in the history
  • Loading branch information
ideastudios committed Feb 26, 2019
1 parent 46ed563 commit c6b57a4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ an ideal WAV PCM recorder library for Android

## 初始化

Application中的onCreate()方法中,传入全局context
在Application或Activity的onCreate()方法中,传入context

```java
IdealRecorder.init(this);
IdealRecorder.getInstance().init(this);
```


Expand Down Expand Up @@ -93,9 +93,10 @@ statusListener为回调是的listener 重写需要用到的回调即可
2. Add the dependency
```
dependencies {
implementation 'com.github.ideastudios:AndroidPcmResample:v1.1.1'
implementation'com.github.ideastudios:IdealRecorder:2.0.1'
}
```


Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.yanzhenjie:permission:1.1.0'
compile 'com.github.Jay-Goo:WaveLineView:v1.0.3'
compile 'com.github.ideastudios:IdealRecorder:1.0.3'
compile 'com.github.ideastudios:IdealRecorder:2.0.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
IdealRecorder.init(this);
IdealRecorder.getInstance().init(this);
}
}
16 changes: 8 additions & 8 deletions library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class IdealRecorder implements RecorderCallback, AudioFileListener {
private static final String TAG = "IdealRecorder";
private static Context context;
private Context context;
private Handler idealHandler;
private RecordConfig config;

Expand All @@ -45,12 +45,16 @@ private IdealRecorder() {
audioFileHelper = new AudioFileHelper(this);
}

public static IdealRecorder getInstance() {
return IdealRecorderHolder.instance;
}

/**
* 初始化当前实例
*
* @param mContext 当前应用的application context
*/
public static void init(Context mContext) {
public void init(Context mContext) {
context = mContext;

}
Expand All @@ -60,16 +64,12 @@ public static void init(Context mContext) {
*
* @return 当前应用的context
*/
public static Context getContext() {
public Context getContext() {
if (context == null)
throw new IllegalStateException("请先在全局Application中调用 IdealRecorder.init() 初始化!");
throw new IllegalStateException("请先在Application或Activity中调用 IdealRecorder.getInstance.init() 初始化!");
return context;
}

public static IdealRecorder getInstance() {
return IdealRecorderHolder.instance;
}

public IdealRecorder setRecordConfig(RecordConfig config) {
this.config = config;
audioFileHelper.setRecorderConfig(config);
Expand Down

0 comments on commit c6b57a4

Please sign in to comment.