mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Search: Wait for page to load before displaying search results [#606]
This commit is contained in:
parent
e2aa551feb
commit
5ddf50d5b5
@ -16,14 +16,17 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx.xowa.addons.wikis.searchs.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*;
|
||||
import gplx.core.threads.*;
|
||||
import gplx.xowa.guis.cbks.js.*; import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.addons.wikis.searchs.specials.htmls.*; import gplx.xowa.addons.wikis.searchs.searchers.*; import gplx.xowa.addons.wikis.searchs.searchers.rslts.*;
|
||||
public class Srch_special_cmd implements Gfo_invk, Srch_rslt_cbk, Xog_tab_close_lnr {
|
||||
private final Srch_special_searcher mgr; private final Srch_search_qry qry;
|
||||
public final Xow_wiki wiki; private final Xog_tab_close_mgr tab_close_mgr; private final Xog_js_wkr js_wkr;
|
||||
private final Xopg_tab_data tab_data;
|
||||
private Srch_html_row_wkr html_row_wkr; private final boolean async;
|
||||
public final byte[] key; private boolean canceled = false;
|
||||
public Srch_special_cmd(Srch_special_searcher mgr, Srch_search_qry qry, Xow_wiki wiki, Xog_tab_close_mgr tab_close_mgr, Xog_js_wkr js_wkr, byte[] key, boolean search_is_async) {
|
||||
this.mgr = mgr; this.qry = qry; this.wiki = wiki; this.tab_close_mgr = tab_close_mgr; this.js_wkr = js_wkr; this.key = key;
|
||||
public Srch_special_cmd(Srch_special_searcher mgr, Srch_search_qry qry, Xow_wiki wiki, Xopg_tab_data tab_data, byte[] key, boolean search_is_async) {
|
||||
this.mgr = mgr; this.qry = qry; this.wiki = wiki;
|
||||
this.tab_data = tab_data; this.tab_close_mgr = tab_data.Close_mgr(); this.js_wkr = tab_data.Tab().Html_itm(); this.key = key;
|
||||
this.async = wiki.App().Mode().Tid_is_gui() && search_is_async;
|
||||
}
|
||||
public void On_cancel() {
|
||||
@ -41,6 +44,12 @@ public class Srch_special_cmd implements Gfo_invk, Srch_rslt_cbk, Xog_tab_close_
|
||||
Search_db();
|
||||
}
|
||||
private void Search_db() {
|
||||
for (int loop = 0; loop < 20; loop++) {
|
||||
if (tab_data.Gui_loaded())
|
||||
break;
|
||||
else
|
||||
Thread_adp_.Sleep(1000);
|
||||
}
|
||||
synchronized (mgr) { // THREAD: needed else multiple Special:Search pages will fail at startup; DATE:2016-03-27
|
||||
tab_close_mgr.Add(this);
|
||||
// DEPRECATE: causes search to fail when using go back / go forward; DELETE:2016-05; DATE:2016-03-27
|
||||
|
@ -38,7 +38,7 @@ public class Srch_special_searcher {
|
||||
rslt_list = cbk_synchronous.Rslts();
|
||||
}
|
||||
else {
|
||||
Srch_special_cmd cmd = new Srch_special_cmd(this, qry, wiki, page.Tab_data().Close_mgr(), page.Tab_data().Tab().Html_itm(), key, search_is_async);
|
||||
Srch_special_cmd cmd = new Srch_special_cmd(this, qry, wiki, page.Tab_data(), key, search_is_async);
|
||||
cancel_hash.Add(key, cmd);
|
||||
cmd.Search(); // do search; will return immediately b/c async
|
||||
rslt_list = new Srch_rslt_list(); // NOTE: create an empty rslt which will be populated by async calls
|
||||
|
@ -67,6 +67,7 @@ public class Xog_tab_itm_read_mgr {
|
||||
html_itm.Scroll_page_by_bmk_gui();
|
||||
else
|
||||
Gfo_invk_.Invk_by_val(tab.Html_itm().Cmd_async(), Xog_html_itm.Invk_html_elem_focus, Xog_html_itm.Elem_id__xowa_edit_data_box); // NOTE: must be async, else won't work; DATE:2014-06-05
|
||||
new_page.Tab_data().Gui_loaded_y_();
|
||||
}
|
||||
public static void Update_selected_tab_blank(Xog_win_itm win) {Update_selected_tab(win, null, null);} // called when all tabs are null
|
||||
public static void Update_selected_tab(Xog_win_itm win, Xoa_url url, Xoa_ttl ttl) {
|
||||
|
@ -19,9 +19,11 @@ public class Xopg_tab_data {
|
||||
public Xog_tab_itm Tab() {return tab;} public void Tab_(Xog_tab_itm v) {this.tab = v;} private Xog_tab_itm tab;
|
||||
public boolean Cancel_show() {return cancel_show;} public void Cancel_show_y_() {this.cancel_show = true;} private boolean cancel_show; // used for Special:Search
|
||||
public Xog_tab_close_mgr Close_mgr() {return close_mgr;} private final Xog_tab_close_mgr close_mgr = new Xog_tab_close_mgr();
|
||||
public boolean Gui_loaded() {return gui_loaded;} private boolean gui_loaded; public void Gui_loaded_y_() {gui_loaded = true;}
|
||||
public void Clear() {
|
||||
this.cancel_show = false;
|
||||
this.tab = null;
|
||||
close_mgr.Clear();
|
||||
this.gui_loaded = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user