8000 Create AnyThreadResult.java · radiocom/flutter-webrtc@dc819f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit dc819f4

Browse files
authored
Create AnyThreadResult.java
1 parent 649c2e2 commit dc819f4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.cloudwebrtc.webrtc.utils;
2+
3+
import android.os.Looper;
4+
import android.os.Handler;
5+
6+
import io.flutter.plugin.common.MethodChannel;
7+
8+
public final class AnyThreadResult implements MethodChannel.Result {
9+
final private MethodChannel.Result result;
10+
11+
public AnyThreadResult(MethodChannel.Result result) {
12+
this.result = result;
13+
}
14+
15+
@Override
16+
public void success(Object o) {
17+
final Handler handler = new Handler(Looper.getMainLooper());
18+
handler.post(()->result.success(o));
19+
}
20+
21+
@Override
22+
public void error(String s, String s1, Object o) {
23+
final Handler handler = new Handler(Looper.getMainLooper());
24+
handler.post(()->result.error(s, s1, o));
25+
}
26+
27+
@Override
28+
public void notImplemented() {
29+
final Handler handler = new Handler(Looper.getMainLooper());
30+
handler.post(result::notImplemented);
31+
}
32+
}

0 commit comments

Comments
 (0)
0