Skip to content

Commit b08bbe6

Browse files
committed
Added listener to check when page finishes loading.
1 parent 5cf9009 commit b08bbe6

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

aceeditor/src/main/java/com/susmit/aceeditor/AceEditor.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,23 @@ public class AceEditor extends WebView
2222
Context context;
2323
private PopupWindow pw;
2424
private View popupView;
25+
2526
private ResultReceivedListener received;
27+
private OnLoadedEditorListener onLoadedEditorListener;
28+
2629
private LayoutInflater inflater;
2730
private float x;
2831
private float y;
2932
private boolean actAfterSelect;
3033
private int requestedValue;
3134

35+
private boolean loadedUI;
36+
3237
@SuppressLint("SetJavaScriptEnabled")
3338
public AceEditor(Context context)
3439
{
3540
super(context);
41+
loadedUI = false;
3642
this.context = context;
3743
initialize();
3844
}
@@ -42,6 +48,7 @@ public AceEditor(Context context)
4248
public AceEditor(Context context, AttributeSet attrs)
4349
{
4450
super(context, attrs);
51+
loadedUI = false;
4552
this.context = context;
4653
initialize();
4754
}
@@ -60,6 +67,13 @@ public void onReceived(String text, int FLAG_VALUE) {
6067
}
6168
});
6269

70+
setOnLoadedEditorListener(new OnLoadedEditorListener() {
71+
@Override
72+
public void onCreate() {
73+
74+
}
75+
});
76+
6377
setWebChromeClient(new WebChromeClient() {
6478
@Override
6579
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
@@ -72,7 +86,11 @@ public boolean onJsAlert(WebView view, String url, String message, JsResult resu
7286
setWebViewClient(new WebViewClient() {
7387
@Override
7488
public void onPageFinished(WebView view, String url) {
75-
89+
if(!loadedUI)
90+
{
91+
loadedUI = true;
92+
onLoadedEditorListener.onCreate();
93+
}
7694
}
7795

7896
@Override
@@ -231,6 +249,11 @@ public void setResultReceivedListener(ResultReceivedListener listener)
231249
this.received = listener;
232250
}
233251

252+
public void setOnLoadedEditorListener(OnLoadedEditorListener listener)
253+
{
254+
this.onLoadedEditorListener = listener;
255+
}
256+
234257
public void requestText()
235258
{
236259
requestedValue = Request.VALUE_TEXT;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.susmit.aceeditor;
2+
3+
/**
4+
* Created by susmit on 25/1/18.
5+
*/
6+
7+
public interface OnLoadedEditorListener {
8+
void onCreate();
9+
}

0 commit comments

Comments
 (0)