forked from firebase/flutterfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap chanel result logic in LatchResult
- Loading branch information
Showing
2 changed files
with
36 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ase_messaging/android/src/main/java/io/flutter/plugins/firebasemessaging/LatchResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.flutter.plugins.firebasemessaging; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
|
||
import io.flutter.plugin.common.MethodChannel; | ||
|
||
public class LatchResult { | ||
|
||
private MethodChannel.Result result; | ||
|
||
public LatchResult(final CountDownLatch latch) { | ||
result = new MethodChannel.Result() { | ||
@Override | ||
public void success(Object result) { | ||
latch.countDown(); | ||
} | ||
|
||
@Override | ||
public void error(String errorCode, String errorMessage, Object errorDetails) { | ||
latch.countDown(); | ||
} | ||
|
||
@Override | ||
public void notImplemented() { | ||
latch.countDown(); | ||
} | ||
}; | ||
} | ||
|
||
public MethodChannel.Result getResult() { | ||
return result; | ||
} | ||
|
||
|
||
} |