File tree Expand file tree Collapse file tree 5 files changed +15
-14
lines changed
src/main/java/tech/oom/idealrecorderdemo
library/src/main/java/tech/oom/idealrecorder Expand file tree Collapse file tree 5 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ an ideal WAV PCM recorder library for Android
21
21
22
22
## 初始化
23
23
24
- Application中的onCreate ()方法中,传入全局context
24
+ 在Application或Activity的onCreate ()方法中,传入context
25
25
26
26
``` java
27
- IdealRecorder . init(this );
27
+ IdealRecorder . getInstance() . init(this );
28
28
```
29
29
30
30
@@ -93,9 +93,10 @@ statusListener为回调是的listener 重写需要用到的回调即可
93
93
2 . Add the dependency
94
94
```
95
95
dependencies {
96
- implementation 'com.github.ideastudios:AndroidPcmResample:v1.1 .1'
96
+ implementation'com.github.ideastudios:IdealRecorder:2.0 .1'
97
97
}
98
98
99
+
99
100
```
100
101
101
102
Original file line number Diff line number Diff line change @@ -29,5 +29,5 @@ dependencies {
29
29
testCompile ' junit:junit:4.12'
30
30
compile ' com.yanzhenjie:permission:1.1.0'
31
31
compile ' com.github.Jay-Goo:WaveLineView:v1.0.3'
32
- compile ' com.github.ideastudios:IdealRecorder:1 .0.3 '
32
+ compile ' com.github.ideastudios:IdealRecorder:2 .0.1 '
33
33
}
Original file line number Diff line number Diff line change @@ -9,6 +9,6 @@ public class MyApplication extends Application {
9
9
@ Override
10
10
public void onCreate () {
11
11
super .onCreate ();
12
- IdealRecorder .init (this );
12
+ IdealRecorder .getInstance (). init (this );
13
13
}
14
14
}
Original file line number Diff line number Diff line change 25
25
26
26
public class IdealRecorder implements RecorderCallback , AudioFileListener {
27
27
private static final String TAG = "IdealRecorder" ;
28
- private static Context context ;
28
+ private Context context ;
29
29
private Handler idealHandler ;
30
30
private RecordConfig config ;
31
31
@@ -45,12 +45,16 @@ private IdealRecorder() {
45
45
audioFileHelper = new AudioFileHelper (this );
46
46
}
47
47
48
+ public static IdealRecorder getInstance () {
49
+ return IdealRecorderHolder .instance ;
50
+ }
51
+
48
52
/**
49
53
* 初始化当前实例
50
54
*
51
55
* @param mContext 当前应用的application context
52
56
*/
53
- public static void init (Context mContext ) {
57
+ public void init (Context mContext ) {
54
58
context = mContext ;
55
59
56
60
}
@@ -60,16 +64,12 @@ public static void init(Context mContext) {
60
64
*
61
65
* @return 当前应用的context
62
66
*/
63
- public static Context getContext () {
67
+ public Context getContext () {
64
68
if (context == null )
65
- throw new IllegalStateException ("请先在全局Application中调用 IdealRecorder.init() 初始化!" );
69
+ throw new IllegalStateException ("请先在Application或Activity中调用 IdealRecorder.getInstance .init() 初始化!" );
66
70
return context ;
67
71
}
68
72
69
- public static IdealRecorder getInstance () {
70
- return IdealRecorderHolder .instance ;
71
- }
72
-
73
73
public IdealRecorder setRecordConfig (RecordConfig config ) {
74
74
this .config = config ;
75
75
audioFileHelper .setRecorderConfig (config );
You can’t perform that action at this time.
0 commit comments