Fix bug with search
invalidateOptionsMenu was called way too often because setLoadingState would fire on every console message
This commit is contained in:
parent
7be1575e50
commit
189f57afdd
@ -1,6 +1,11 @@
|
||||
// created to start cleaning up "window" interaction
|
||||
//
|
||||
|
||||
window.currentPane = '';
|
||||
|
||||
window.show = function(id) {
|
||||
if(window.currentPane == id) return;
|
||||
window.currentPane = id;
|
||||
window.hideall();
|
||||
|
||||
runHooks("paneChanged", id);
|
||||
|
@ -257,6 +257,7 @@ addHook('search', function(query) {
|
||||
if(!isNaN(ll[0]) && !isNaN(ll[1])) {
|
||||
query.addResult({
|
||||
title: query.term,
|
||||
description: 'geo coordinates',
|
||||
position: L.latLng(parseFloat(ll[0]), parseFloat(ll[1])),
|
||||
});
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class IITC_Mobile extends Activity
|
||||
private boolean mPersistentZoom = false;
|
||||
private final Stack<String> mDialogStack = new Stack<String>();
|
||||
private String mPermalink = null;
|
||||
private String mSearchTerm = null;
|
||||
private String mSearchTerm = "";
|
||||
|
||||
// Used for custom back stack handling
|
||||
private final Stack<Pane> mBackStack = new Stack<IITC_NavigationHelper.Pane>();
|
||||
@ -501,6 +501,19 @@ public class IITC_Mobile extends Activity
|
||||
mIitcWebView.loadUrl("javascript: window.show('" + pane.name + "');");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_SEARCH) {
|
||||
mSearchMenuItem.expandActionView();
|
||||
|
||||
final SearchView tv = (SearchView) mSearchMenuItem.getActionView();
|
||||
tv.setQuery(mSearchTerm, false);
|
||||
tv.requestFocus();
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
@ -515,13 +528,17 @@ public class IITC_Mobile extends Activity
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(final String query) {
|
||||
mSearchTerm = query;
|
||||
search(query, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(final String query) {
|
||||
search(query, false);
|
||||
if (!query.isEmpty()) {
|
||||
mSearchTerm = query;
|
||||
search(query, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -539,22 +556,14 @@ public class IITC_Mobile extends Activity
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_SEARCH) {
|
||||
mSearchMenuItem.expandActionView();
|
||||
mSearchMenuItem.getActionView().requestFocus();
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(final Menu menu) {
|
||||
boolean visible = false;
|
||||
if (mNavigationHelper != null) visible = !mNavigationHelper.isDrawerOpened();
|
||||
if (mIsLoading) visible = false;
|
||||
|
||||
((SearchView) menu.findItem(R.id.menu_search).getActionView()).setQuery(mSearchTerm, false);
|
||||
|
||||
for (int i = 0; i < menu.size(); i++) {
|
||||
final MenuItem item = menu.getItem(i);
|
||||
final boolean enabled = mAdvancedMenu.contains(item.getTitle());
|
||||
@ -759,22 +768,23 @@ public class IITC_Mobile extends Activity
|
||||
}
|
||||
|
||||
public void setLoadingState(final boolean isLoading) {
|
||||
if (isLoading == mIsLoading) return;
|
||||
|
||||
if (mSearchTerm != null && !mSearchTerm.isEmpty() && mIsLoading && !isLoading) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
search(mSearchTerm, true);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
mIsLoading = isLoading;
|
||||
mNavigationHelper.onLoadingStateChanged();
|
||||
mUserLocation.onLoadingStateChanged();
|
||||
invalidateOptionsMenu();
|
||||
updateViews();
|
||||
if (!isLoading) mFileManager.updatePlugins(false);
|
||||
|
||||
if (mSearchTerm != null && !isLoading) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
search(mSearchTerm, true);
|
||||
mSearchTerm = null;
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateViews() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user