capacitor-microphone 0.1.8 → 0.1.10
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.
|
@@ -319,42 +319,33 @@ private void startListeningInternal(PluginCall call, String lang) {
|
|
|
319
319
|
|
|
320
320
|
@PluginMethod
|
|
321
321
|
public void restartListening(PluginCall call) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (delayedStartRunnable != null) {
|
|
327
|
-
getActivity().runOnUiThread(() -> {
|
|
328
|
-
getActivity()
|
|
329
|
-
.getWindow()
|
|
330
|
-
.getDecorView()
|
|
331
|
-
.removeCallbacks(delayedStartRunnable);
|
|
332
|
-
});
|
|
333
|
-
delayedStartRunnable = null;
|
|
322
|
+
if (!isListening || currentCall == null) {
|
|
323
|
+
call.reject("Cannot restart - not currently listening");
|
|
324
|
+
return;
|
|
334
325
|
}
|
|
335
326
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
getActivity().runOnUiThread(() -> {
|
|
339
|
-
try {
|
|
340
|
-
if (speechRecognizer != null) {
|
|
341
|
-
speechRecognizer.cancel();
|
|
342
|
-
speechRecognizer.setRecognitionListener(null);
|
|
343
|
-
speechRecognizer.destroy();
|
|
344
|
-
speechRecognizer = null;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
speechIntent = null;
|
|
327
|
+
// Guardar parámetros antes de detener
|
|
328
|
+
final String lang = currentCall.getString("lang", "es-MX");
|
|
349
329
|
|
|
330
|
+
// Crear un call temporal para el restart
|
|
331
|
+
final PluginCall restartCall = currentCall;
|
|
350
332
|
|
|
351
|
-
|
|
333
|
+
// Detener
|
|
334
|
+
stopListening(restartCall);
|
|
352
335
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
336
|
+
// Pequeño delay y luego iniciar de nuevo
|
|
337
|
+
getActivity().runOnUiThread(() -> {
|
|
338
|
+
// Usar postDelayed con Runnable
|
|
339
|
+
getActivity()
|
|
340
|
+
.getWindow()
|
|
341
|
+
.getDecorView()
|
|
342
|
+
.postDelayed(new Runnable() {
|
|
343
|
+
@Override
|
|
344
|
+
public void run() {
|
|
345
|
+
startListeningInternal(restartCall, lang);
|
|
346
|
+
call.resolve();
|
|
347
|
+
}
|
|
348
|
+
}, RESTART_COOLDOWN_MS);
|
|
358
349
|
});
|
|
359
350
|
}
|
|
360
351
|
|