Skip to content

Commit 8aa2bfe

Browse files
committed
docs: document onWebViewRecreated and onWebViewRecreatedListener
1 parent 0506e7f commit 8aa2bfe

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

AnkiDroid/src/main/java/com/ichi2/anki/workarounds/SafeWebViewLayout.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,27 @@ open class SafeWebViewLayout :
217217
}
218218
}
219219

220+
/**
221+
* It is called by [SafeWebViewLayout.onRenderProcessGone] after its internal [WebView] is replaced,
222+
* due to a render process crash or the system killing it to free memory.
223+
*
224+
* The host [Fragment] must always implement this interface. In debug builds a missing implementation
225+
* will throw at [SafeWebViewLayout.onAttachedToWindow]
226+
*/
220227
fun interface OnWebViewRecreatedListener {
228+
/**
229+
* It is called by [SafeWebViewLayout.onRenderProcessGone] with the new [WebView] after
230+
* the old instance has been removed and destroyed. The implementations must reapply
231+
* all the clients,settings and content that were configured on the original [WebView]
232+
* because the previous configuration is not retained.
233+
*
234+
*`super.onWebviewRecreated(webview)` must be called when overriding this method in a subclass.
235+
*
236+
* To manually trigger this path,call `webviewLayout.loadUrl("chrome://crash")`.
237+
* Automated testing would require an instrumentation test, a unit test is not sufficient.
238+
*
239+
*
240+
* @param webView the new [webView],already attached to [SafeWebViewLayout]
241+
*/
221242
fun onWebViewRecreated(webView: WebView)
222243
}

0 commit comments

Comments
 (0)