Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,26 @@
public class MethodResultWrapper implements MethodChannel.Result {
private final MethodChannel.Result methodResult;
private final Handler handler;
private boolean called;

MethodResultWrapper(MethodChannel.Result result) {
methodResult = result;
handler = new Handler(Looper.getMainLooper());
}

private synchronized boolean checkNotCalled() {
if (called) {
return false;
}
called = true;
return true;
}

@Override
public void success(final Object result) {
if (!checkNotCalled()) {
return;
}
handler.post(
new Runnable() {
@Override
Expand All @@ -33,6 +45,9 @@ public void run() {
@Override
public void error(
final String errorCode, final String errorMessage, final Object errorDetails) {
if (!checkNotCalled()) {
return;
}
handler.post(
new Runnable() {
@Override
Expand All @@ -48,6 +63,9 @@ public void run() {

@Override
public void notImplemented() {
if (!checkNotCalled()) {
return;
}
handler.post(
new Runnable() {
@Override
Expand Down
Loading