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
|
// created to start cleaning up "window" interaction
|
||||||
//
|
//
|
||||||
|
|
||||||
|
window.currentPane = '';
|
||||||
|
|
||||||
window.show = function(id) {
|
window.show = function(id) {
|
||||||
|
if(window.currentPane == id) return;
|
||||||
|
window.currentPane = id;
|
||||||
window.hideall();
|
window.hideall();
|
||||||
|
|
||||||
runHooks("paneChanged", id);
|
runHooks("paneChanged", id);
|
||||||
|
@ -257,6 +257,7 @@ addHook('search', function(query) {
|
|||||||
if(!isNaN(ll[0]) && !isNaN(ll[1])) {
|
if(!isNaN(ll[0]) && !isNaN(ll[1])) {
|
||||||
query.addResult({
|
query.addResult({
|
||||||
title: query.term,
|
title: query.term,
|
||||||
|
description: 'geo coordinates',
|
||||||
position: L.latLng(parseFloat(ll[0]), parseFloat(ll[1])),
|
position: L.latLng(parseFloat(ll[0]), parseFloat(ll[1])),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class IITC_Mobile extends Activity
|
|||||||
private boolean mPersistentZoom = false;
|
private boolean mPersistentZoom = false;
|
||||||
private final Stack<String> mDialogStack = new Stack<String>();
|
private final Stack<String> mDialogStack = new Stack<String>();
|
||||||
private String mPermalink = null;
|
private String mPermalink = null;
|
||||||
private String mSearchTerm = null;
|
private String mSearchTerm = "";
|
||||||
|
|
||||||
// Used for custom back stack handling
|
// Used for custom back stack handling
|
||||||
private final Stack<Pane> mBackStack = new Stack<IITC_NavigationHelper.Pane>();
|
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 + "');");
|
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
|
@Override
|
||||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// 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() {
|
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(final String query) {
|
public boolean onQueryTextSubmit(final String query) {
|
||||||
|
mSearchTerm = query;
|
||||||
search(query, true);
|
search(query, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextChange(final String query) {
|
public boolean onQueryTextChange(final String query) {
|
||||||
search(query, false);
|
if (!query.isEmpty()) {
|
||||||
|
mSearchTerm = query;
|
||||||
|
search(query, false);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -539,22 +556,14 @@ public class IITC_Mobile extends Activity
|
|||||||
return true;
|
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
|
@Override
|
||||||
public boolean onPrepareOptionsMenu(final Menu menu) {
|
public boolean onPrepareOptionsMenu(final Menu menu) {
|
||||||
boolean visible = false;
|
boolean visible = false;
|
||||||
if (mNavigationHelper != null) visible = !mNavigationHelper.isDrawerOpened();
|
if (mNavigationHelper != null) visible = !mNavigationHelper.isDrawerOpened();
|
||||||
if (mIsLoading) visible = false;
|
if (mIsLoading) visible = false;
|
||||||
|
|
||||||
|
((SearchView) menu.findItem(R.id.menu_search).getActionView()).setQuery(mSearchTerm, false);
|
||||||
|
|
||||||
for (int i = 0; i < menu.size(); i++) {
|
for (int i = 0; i < menu.size(); i++) {
|
||||||
final MenuItem item = menu.getItem(i);
|
final MenuItem item = menu.getItem(i);
|
||||||
final boolean enabled = mAdvancedMenu.contains(item.getTitle());
|
final boolean enabled = mAdvancedMenu.contains(item.getTitle());
|
||||||
@ -759,22 +768,23 @@ public class IITC_Mobile extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadingState(final boolean isLoading) {
|
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;
|
mIsLoading = isLoading;
|
||||||
mNavigationHelper.onLoadingStateChanged();
|
mNavigationHelper.onLoadingStateChanged();
|
||||||
mUserLocation.onLoadingStateChanged();
|
mUserLocation.onLoadingStateChanged();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
updateViews();
|
updateViews();
|
||||||
if (!isLoading) mFileManager.updatePlugins(false);
|
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() {
|
private void updateViews() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user