You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
delay Dialog.dismiss() by 10ms to work around NewPipe race condition
This commit is contained in:
@@ -93,14 +93,18 @@ public class Dialog implements Window.Callback, DialogInterface {
|
|||||||
|
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
System.out.println("dismissing the Dialog " + Dialog.this);
|
System.out.println("dismissing the Dialog " + Dialog.this);
|
||||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
// HACK: dismissing the Dialog takes some time in AOSP, as the request goes back and forth between the application
|
||||||
|
// and the system server. We replicate this behavior by adding 10 ms delay.
|
||||||
|
// This Hack is required for NewPipe RouterActivity which has a race condition. It subscribes an rxJava observable
|
||||||
|
// and immediately calls Dialog.dismiss(). The OnDismissListener would unsubscribes the observable again.
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
nativeClose(nativePtr);
|
nativeClose(nativePtr);
|
||||||
if (onDismissListener != null)
|
if (onDismissListener != null)
|
||||||
onDismissListener.onDismiss(Dialog.this);
|
onDismissListener.onDismiss(Dialog.this);
|
||||||
}
|
}
|
||||||
});
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Window getWindow() {
|
public Window getWindow() {
|
||||||
|
|||||||
Reference in New Issue
Block a user