capacitor-microphone 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,6 +40,7 @@ private boolean isDestroyed = false;
40
40
  private long lastStopTime = 0;
41
41
  private static final long RESTART_COOLDOWN_MS = 400;
42
42
  private Runnable delayedStartRunnable;
43
+ private boolean ignoreNextResult = false;
43
44
 
44
45
 
45
46
  @PluginMethod
@@ -172,7 +173,7 @@ private void startListeningInternal(PluginCall call, String lang) {
172
173
  "partialResult",
173
174
  new JSObject()
174
175
  .put("text", "")
175
- .put("isFinal", true)
176
+ .put("isFinal", false)
176
177
  );
177
178
 
178
179
  this.currentCall = call;
@@ -209,6 +210,12 @@ private void startListeningInternal(PluginCall call, String lang) {
209
210
 
210
211
  @Override
211
212
  public void onResults(Bundle results) {
213
+
214
+ if (ignoreNextResult) {
215
+ ignoreNextResult = false;
216
+ return;
217
+ }
218
+
212
219
  if (!isListening) return;
213
220
 
214
221
  ArrayList<String> matches =
@@ -232,6 +239,12 @@ private void startListeningInternal(PluginCall call, String lang) {
232
239
 
233
240
  @Override
234
241
  public void onPartialResults(Bundle partialResults) {
242
+
243
+ if (ignoreNextResult) {
244
+ ignoreNextResult = false;
245
+ return;
246
+ }
247
+
235
248
  if (!isListening || isDestroyed) return;
236
249
 
237
250
  ArrayList<String> matches =
@@ -322,7 +335,7 @@ public void restartListening(PluginCall call) {
322
335
  }
323
336
 
324
337
  stopSpeech();
325
-
338
+ ignoreNextResult = true;
326
339
  getActivity().runOnUiThread(() -> {
327
340
  getActivity()
328
341
  .getWindow()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-microphone",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "plugin to use the microphone",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",