use of com.orgzly.android.query.user.DottedQueryBuilder in project orgzly-android by orgzly.
the class MainActivity method setupSearchView.
/**
* SearchView setup and query text listeners.
* TODO: http://developer.android.com/training/search/setup.html
*/
private void setupSearchView(Menu menu) {
final MenuItem searchItem = menu.findItem(R.id.activity_action_search);
final SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setQueryHint(getString(R.string.search_hint));
/* When user starts the search, fill the search box with text depending on current fragment. */
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/* Make search as wide as possible. */
ViewGroup.LayoutParams layoutParams = searchView.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
/* For Query fragment, fill the box with full query. */
String q = DisplayManager.getDisplayedQuery(getSupportFragmentManager());
if (q != null) {
searchView.setQuery(q + " ", false);
} else {
/* If searching from book, add book name to query. */
Book book = getActiveFragmentBook();
if (book != null) {
DottedQueryBuilder builder = new DottedQueryBuilder();
String query = builder.build(new Query(new Condition.InBook(book.getName())));
searchView.setQuery(query + " ", false);
}
}
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String str) {
return false;
}
@Override
public boolean onQueryTextSubmit(String str) {
if (BuildConfig.LOG_DEBUG)
LogUtils.d(TAG, str);
/* Close search. */
searchItem.collapseActionView();
DisplayManager.displayQuery(getSupportFragmentManager(), str.trim());
return true;
}
});
}
use of com.orgzly.android.query.user.DottedQueryBuilder in project orgzly-android by orgzly.
the class MainActivity method setupSearchView.
/**
* SearchView setup and query text listeners.
* TODO: http://developer.android.com/training/search/setup.html
*/
private void setupSearchView(Menu menu) {
final MenuItem searchItem = menu.findItem(R.id.activity_action_search);
final SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setQueryHint(getString(R.string.search_hint));
/* When user starts the search, fill the search box with text depending on current fragment. */
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/* Make search as wide as possible. */
ViewGroup.LayoutParams layoutParams = searchView.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
/* For Query fragment, fill the box with full query. */
String q = DisplayManager.getDisplayedQuery(getSupportFragmentManager());
if (q != null) {
searchView.setQuery(q + " ", false);
} else {
/* If searching from book, add book name to query. */
Book book = getActiveFragmentBook();
if (book != null) {
DottedQueryBuilder builder = new DottedQueryBuilder();
String query = builder.build(new Query(new Condition.InBook(book.getName())));
searchView.setQuery(query + " ", false);
}
}
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String str) {
return false;
}
@Override
public boolean onQueryTextSubmit(String str) {
if (BuildConfig.LOG_DEBUG)
LogUtils.d(TAG, str);
/* Close search. */
searchItem.collapseActionView();
DisplayManager.displayQuery(getSupportFragmentManager(), str.trim());
return true;
}
});
}
Aggregations